Commit 690a9003 authored by Erich E. Hoover's avatar Erich E. Hoover Committed by Alexandre Julliard

kernel32: Add SearchPath test demonstrating the priority of the working directory.

parent 91f96b28
......@@ -1820,10 +1820,11 @@ static void test_SearchPathA(void)
static const CHAR testdeprelA[] = "./testdep.dll";
static const CHAR kernel32A[] = "kernel32.dll";
static const CHAR fileA[] = "";
CHAR pathA[MAX_PATH], buffA[MAX_PATH], path2A[MAX_PATH];
CHAR *ptrA = NULL;
CHAR pathA[MAX_PATH], buffA[MAX_PATH], path2A[MAX_PATH], path3A[MAX_PATH], curdirA[MAX_PATH];
CHAR tmpdirA[MAX_PATH], *ptrA = NULL;
ULONG_PTR cookie;
HANDLE handle;
BOOL bret;
DWORD ret;
GetWindowsDirectoryA(pathA, ARRAY_SIZE(pathA));
......@@ -1915,6 +1916,28 @@ static void test_SearchPathA(void)
ret = pDeactivateActCtx(0, cookie);
ok(ret, "failed to deactivate context, %u\n", GetLastError());
pReleaseActCtx(handle);
/* test the search path priority of the working directory */
GetTempPathA(sizeof(tmpdirA), tmpdirA);
ret = GetCurrentDirectoryA(MAX_PATH, curdirA);
ok(ret, "failed to obtain working directory.\n");
sprintf(pathA, "%s\\%s", tmpdirA, kernel32A);
ret = SearchPathA(NULL, kernel32A, NULL, sizeof(path2A)/sizeof(CHAR), path2A, NULL);
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);
bret = CopyFileA(path2A, path3A, FALSE);
ok(bret != 0, "failed to copy test executable to launch directory, %u\n", GetLastError());
bret = SetCurrentDirectoryA(tmpdirA);
ok(bret, "failed to change working directory\n");
ret = SearchPathA(NULL, kernel32A, ".exe", sizeof(buffA), buffA, NULL);
ok(ret && ret == strlen(buffA), "got %d\n", ret);
ok(strcmp(buffA, path3A) == 0, "expected %s, got %s\n", path3A, buffA);
bret = SetCurrentDirectoryA(curdirA);
ok(bret, "failed to reset working directory\n");
DeleteFileA(path3A);
DeleteFileA(pathA);
}
static void test_SearchPathW(void)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment