Alexandre Julliard : kernel32/tests: Avoid assumptions about the current working directory.

Alexandre Julliard julliard at winehq.org
Mon Sep 14 14:58:21 CDT 2020


Module: wine
Branch: master
Commit: 8a5e603000c1337657b1e3256284c1f9b4e84581
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=8a5e603000c1337657b1e3256284c1f9b4e84581

Author: Alexandre Julliard <julliard at winehq.org>
Date:   Mon Sep 14 19:07:27 2020 +0200

kernel32/tests: Avoid assumptions about the current working directory.

Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/kernel32/tests/actctx.c  | 21 ++++++---------------
 dlls/kernel32/tests/path.c    |  3 ++-
 dlls/kernel32/tests/process.c |  9 ++++++---
 3 files changed, 14 insertions(+), 19 deletions(-)

diff --git a/dlls/kernel32/tests/actctx.c b/dlls/kernel32/tests/actctx.c
index 2093959d98..1bcb25a53f 100644
--- a/dlls/kernel32/tests/actctx.c
+++ b/dlls/kernel32/tests/actctx.c
@@ -36,16 +36,6 @@ static NTSTATUS(NTAPI *pRtlFindActivationContextSectionString)(DWORD,const GUID
 static BOOLEAN (NTAPI *pRtlCreateUnicodeStringFromAsciiz)(PUNICODE_STRING, PCSZ);
 static VOID    (NTAPI *pRtlFreeUnicodeString)(PUNICODE_STRING);
 
-static const char* strw(LPCWSTR x)
-{
-    static char buffer[1024];
-    char*       p = buffer;
-
-    if (!x) return "(nil)";
-    else while ((*p++ = *x++));
-    return buffer;
-}
-
 #ifdef __i386__
 #define ARCH "x86"
 #elif defined __x86_64__
@@ -622,7 +612,7 @@ static const detailed_info_t detailed_info0 = {
 static const detailed_info_t detailed_info1 = {
     1, 1, 1, ACTIVATION_CONTEXT_PATH_TYPE_WIN32_FILE, manifest_path,
     ACTIVATION_CONTEXT_PATH_TYPE_NONE, ACTIVATION_CONTEXT_PATH_TYPE_WIN32_FILE,
-    work_dir,
+    app_dir,
 };
 
 static const detailed_info_t detailed_info1_child = {
@@ -635,7 +625,7 @@ static const detailed_info_t detailed_info1_child = {
 static const detailed_info_t detailed_info2 = {
     1, 2, 3, ACTIVATION_CONTEXT_PATH_TYPE_WIN32_FILE, manifest_path,
     ACTIVATION_CONTEXT_PATH_TYPE_NONE, ACTIVATION_CONTEXT_PATH_TYPE_WIN32_FILE,
-    work_dir,
+    app_dir,
 };
 
 static void test_detailed_info(HANDLE handle, const detailed_info_t *exinfo, int line)
@@ -706,7 +696,8 @@ static void test_detailed_info(HANDLE handle, const detailed_info_t *exinfo, int
         ok_(__FILE__, line)(detailed_info->lpAppDirPath != NULL, "detailed_info->lpAppDirPath == NULL\n");
         if(detailed_info->lpAppDirPath)
             ok_(__FILE__, line)(!lstrcmpiW(exinfo->app_dir, detailed_info->lpAppDirPath),
-               "unexpected detailed_info->lpAppDirPath\n%s\n",strw(detailed_info->lpAppDirPath));
+                                "unexpected detailed_info->lpAppDirPath %s / %s\n",
+                                wine_dbgstr_w(detailed_info->lpAppDirPath), wine_dbgstr_w( exinfo->app_dir ));
     }else {
         ok_(__FILE__, line)(detailed_info->lpAppDirPath == NULL, "detailed_info->lpAppDirPath != NULL\n");
     }
@@ -864,7 +855,7 @@ static void test_info_in_assembly(HANDLE handle, DWORD id, const info_in_assembl
     if(info->lpAssemblyEncodedAssemblyIdentity && exinfo->encoded_assembly_id) {
         ok_(__FILE__, line)(!lstrcmpW(info->lpAssemblyEncodedAssemblyIdentity, exinfo->encoded_assembly_id),
            "unexpected info->lpAssemblyEncodedAssemblyIdentity %s / %s\n",
-           strw(info->lpAssemblyEncodedAssemblyIdentity), wine_dbgstr_w(exinfo->encoded_assembly_id));
+           wine_dbgstr_w(info->lpAssemblyEncodedAssemblyIdentity), wine_dbgstr_w(exinfo->encoded_assembly_id));
     }
     if(exinfo->manifest_path) {
         ok_(__FILE__, line)(info->lpAssemblyManifestPath != NULL, "info->lpAssemblyManifestPath == NULL\n");
@@ -882,7 +873,7 @@ static void test_info_in_assembly(HANDLE handle, DWORD id, const info_in_assembl
         ok_(__FILE__, line)(info->lpAssemblyDirectoryName != NULL, "info->lpAssemblyDirectoryName == NULL\n");
     else
         ok_(__FILE__, line)(info->lpAssemblyDirectoryName == NULL, "info->lpAssemblyDirectoryName = %s\n",
-           strw(info->lpAssemblyDirectoryName));
+           wine_dbgstr_w(info->lpAssemblyDirectoryName));
     HeapFree(GetProcessHeap(), 0, info);
 }
 
diff --git a/dlls/kernel32/tests/path.c b/dlls/kernel32/tests/path.c
index 0e45ad44ff..f49af6d5bf 100644
--- a/dlls/kernel32/tests/path.c
+++ b/dlls/kernel32/tests/path.c
@@ -1877,7 +1877,8 @@ static void test_SearchPathA(void)
     ok(ret && ret == strlen(path2A), "got %d\n", ret);
     bret = CopyFileA(path2A, pathA, FALSE);
     ok(bret != 0, "failed to copy test executable to temp directory, %u\n", GetLastError());
-    sprintf(path3A, "%s%s%s", curdirA, curdirA[strlen(curdirA)-1] != '\\' ? "\\" : "", kernel32A);
+    GetModuleFileNameA( GetModuleHandleA(0), path3A, sizeof(path3A) );
+    strcpy( strrchr( path3A, '\\' ) + 1, kernel32A );
     bret = CopyFileA(path2A, path3A, FALSE);
     ok(bret != 0, "failed to copy test executable to launch directory, %u\n", GetLastError());
     bret = SetCurrentDirectoryA(tmpdirA);
diff --git a/dlls/kernel32/tests/process.c b/dlls/kernel32/tests/process.c
index ca991ea170..b0371c615e 100644
--- a/dlls/kernel32/tests/process.c
+++ b/dlls/kernel32/tests/process.c
@@ -935,6 +935,11 @@ static void test_CommandLine(void)
     release_memory();
     DeleteFileA(resfile);
 
+    GetFullPathNameA(selfname, MAX_PATH, fullpath, &lpFilePart);
+    assert ( lpFilePart != 0);
+    *(lpFilePart -1 ) = 0;
+    SetCurrentDirectoryA( fullpath );
+
     /* Test for Bug1330 to show that XP doesn't change '/' to '\\' in argv[0]
      * and " escaping.
      */
@@ -970,9 +975,6 @@ static void test_CommandLine(void)
     DeleteFileA(resfile);
 
     get_file_name(resfile);
-    GetFullPathNameA(selfname, MAX_PATH, fullpath, &lpFilePart);
-    assert ( lpFilePart != 0);
-    *(lpFilePart -1 ) = 0;
     p = strrchr(fullpath, '\\');
     /* Use exename to avoid buffer containing things like 'C:' */
     if (p) sprintf(buffer, "..%s/%s process dump \"%s\"", p, exename, resfile);
@@ -1010,6 +1012,7 @@ static void test_CommandLine(void)
     okChildStringWA("Arguments", "CommandLineW", buffer2);
     release_memory();
     DeleteFileA(resfile);
+    SetCurrentDirectoryA( base );
 
     if (0) /* Test crashes on NT-based Windows. */
     {




More information about the wine-cvs mailing list