[PATCH 2/2] kernel32/tests: Add SearchPath() test for file name with multiple extension delimiters.

Nikolay Sivov nsivov at codeweavers.com
Mon Oct 22 03:39:36 CDT 2018


Signed-off-by: Nikolay Sivov <nsivov at codeweavers.com>
---
 dlls/kernel32/tests/path.c | 51 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 51 insertions(+)

diff --git a/dlls/kernel32/tests/path.c b/dlls/kernel32/tests/path.c
index ad8a34296a..94467b1b82 100644
--- a/dlls/kernel32/tests/path.c
+++ b/dlls/kernel32/tests/path.c
@@ -1826,9 +1826,33 @@ static void test_SearchPathA(void)
     ok(GetLastError() == ERROR_INVALID_PARAMETER,
       "Expected ERROR_INVALID_PARAMETER, got %x\n", GetLastError());
 
+    GetTempPathA(ARRAY_SIZE(pathA), pathA);
+    strcpy(path2A, pathA);
+    strcat(path2A, "testfile.ext.ext2");
+
+    handle = CreateFileA(path2A, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, 0);
+    ok(handle != INVALID_HANDLE_VALUE, "Failed to create test file.\n");
+    CloseHandle(handle);
+
+    buffA[0] = 0;
+    ret = SearchPathA(pathA, "testfile.ext", NULL, ARRAY_SIZE(buffA), buffA, NULL);
+    ok(!ret, "Unexpected return value %u.\n", ret);
+
+    buffA[0] = 0;
+    ret = SearchPathA(pathA, "testfile.ext", ".ext2", ARRAY_SIZE(buffA), buffA, NULL);
+    ok(!ret, "Unexpected return value %u.\n", ret);
+
+    buffA[0] = 0;
+    ret = SearchPathA(pathA, "testfile.ext.ext2", NULL, ARRAY_SIZE(buffA), buffA, NULL);
+    ok(ret && ret == strlen(path2A), "got %d\n", ret);
+
+    DeleteFileA(path2A);
+
     if (!pActivateActCtx)
         return;
 
+    GetWindowsDirectoryA(pathA, ARRAY_SIZE(pathA));
+
     create_manifest_file("testdep1.manifest", manifest_dep);
     create_manifest_file("main.manifest", manifest_main);
 
@@ -1879,12 +1903,15 @@ static void test_SearchPathA(void)
 
 static void test_SearchPathW(void)
 {
+    static const WCHAR fileext2W[] = {'t','e','s','t','f','i','l','e','.','e','x','t','.','e','x','t','2',0};
+    static const WCHAR fileextW[] = {'t','e','s','t','f','i','l','e','.','e','x','t',0};
     static const WCHAR testdeprelW[] = {'.','/','t','e','s','t','d','e','p','.','d','l','l',0};
     static const WCHAR testdepW[] = {'t','e','s','t','d','e','p','.','d','l','l',0};
     static const WCHAR testdep1W[] = {'t','e','s','t','d','e','p',0};
     static const WCHAR kernel32dllW[] = {'k','e','r','n','e','l','3','2','.','d','l','l',0};
     static const WCHAR kernel32W[] = {'k','e','r','n','e','l','3','2',0};
     static const WCHAR ole32W[] = {'o','l','e','3','2',0};
+    static const WCHAR ext2W[] = {'.','e','x','t','2',0};
     static const WCHAR extW[] = {'.','e','x','t',0};
     static const WCHAR dllW[] = {'.','d','l','l',0};
     static const WCHAR fileW[] = { 0 };
@@ -1909,9 +1936,33 @@ if (0)
     ok(GetLastError() == ERROR_INVALID_PARAMETER,
       "Expected ERROR_INVALID_PARAMETER, got %x\n", GetLastError());
 
+    GetTempPathW(ARRAY_SIZE(pathW), pathW);
+    lstrcpyW(path2W, pathW);
+    lstrcatW(path2W, fileext2W);
+
+    handle = CreateFileW(path2W, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, 0);
+    ok(handle != INVALID_HANDLE_VALUE, "Failed to create test file.\n");
+    CloseHandle(handle);
+
+    buffW[0] = 0;
+    ret = SearchPathW(pathW, fileextW, NULL, ARRAY_SIZE(buffW), buffW, NULL);
+    ok(!ret, "Unexpected return value %u.\n", ret);
+
+    buffW[0] = 0;
+    ret = SearchPathW(pathW, fileextW, ext2W, ARRAY_SIZE(buffW), buffW, NULL);
+    ok(!ret, "Unexpected return value %u.\n", ret);
+
+    buffW[0] = 0;
+    ret = SearchPathW(pathW, fileext2W, NULL, ARRAY_SIZE(buffW), buffW, NULL);
+    ok(ret && ret == lstrlenW(path2W), "got %d\n", ret);
+
+    DeleteFileW(path2W);
+
     if (!pActivateActCtx)
         return;
 
+    GetWindowsDirectoryW(pathW, ARRAY_SIZE(pathW));
+
     create_manifest_file("testdep1.manifest", manifest_dep);
     create_manifest_file("main.manifest", manifest_main);
 
-- 
2.19.1




More information about the wine-devel mailing list