From: "Erich E. Hoover" erich.e.hoover@gmail.com
Signed-off-by: Erich E. Hoover erich.e.hoover@gmail.com --- dlls/kernel32/tests/path.c | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-)
diff --git a/dlls/kernel32/tests/path.c b/dlls/kernel32/tests/path.c index ca1cbf30ec..ce75f99b63 100644 --- a/dlls/kernel32/tests/path.c +++ b/dlls/kernel32/tests/path.c @@ -1806,10 +1806,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;
if (!pSearchPathA) @@ -1883,6 +1884,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 = pSearchPathA(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 = pSearchPathA(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)