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

Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Alexandre Julliard 2020-09-14 19:07:27 +02:00
parent ad22785cb3
commit 8a5e603000
3 changed files with 14 additions and 19 deletions

View File

@ -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);
}

View File

@ -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);

View File

@ -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. */
{