[PATCH] kernel32/tests: Drop path test workarounds for Windows <= 2000

Alex Henrie alexhenrie24 at gmail.com
Tue Jan 4 01:24:32 CST 2022


Signed-off-by: Alex Henrie <alexhenrie24 at gmail.com>
---
Dropping support for very old Windows versions allows us to enable the
test for SearchPathW with a null filename.
---
 dlls/kernel32/tests/path.c | 82 ++++++++++----------------------------
 1 file changed, 20 insertions(+), 62 deletions(-)

diff --git a/dlls/kernel32/tests/path.c b/dlls/kernel32/tests/path.c
index 2955be0da9c..db376eef24a 100644
--- a/dlls/kernel32/tests/path.c
+++ b/dlls/kernel32/tests/path.c
@@ -350,8 +350,7 @@ static void test_InitPathA(CHAR *newdir, CHAR *curDrive, CHAR *otherDrive)
      "GetTempPathA returned a path that did not end in '\\'\n");
   lstrcpyA(tmpstr,"aaaaaaaa");
   len1=GetTempPathA(len,tmpstr);
-  ok(len1==len+1 || broken(len1 == len), /* WinME */
-     "GetTempPathA should return string length %d instead of %d\n",len+1,len1);
+  ok(len1==len+1,"GetTempPathA should return string length %d instead of %d\n",len+1,len1);
 
 /* Test GetTmpFileNameA */
   ok((id=GetTempFileNameA(tmppath,"path",0,newdir)),"GetTempFileNameA failed\n");
@@ -364,25 +363,20 @@ static void test_InitPathA(CHAR *newdir, CHAR *curDrive, CHAR *otherDrive)
   ok(DeleteFileA(newdir),"Couldn't delete the temporary file we just created\n");     
 
   id=GetTempFileNameA(tmppath,NULL,0,newdir);
-/* Windows 95, 98 return 0==id, while Windows 2000, XP return 0!=id */
-  if (id)
-  {
-    sprintf(tmpstr,"%.4x.tmp",id & 0xffff);
-    sprintf(tmpstr1,"%x.tmp",id & 0xffff);
-    ok(lstrcmpiA(newdir+lstrlenA(tmppath),tmpstr)==0 ||
-       lstrcmpiA(newdir+lstrlenA(tmppath),tmpstr1)==0,
-       "GetTempFileNameA returned '%s' which doesn't match '%s' or '%s'. id=%x\n",
-       newdir,tmpstr,tmpstr1,id);
-    ok(DeleteFileA(newdir),"Couldn't delete the temporary file we just created\n");
-  }
+  sprintf(tmpstr,"%.4x.tmp",id & 0xffff);
+  sprintf(tmpstr1,"%x.tmp",id & 0xffff);
+  ok(lstrcmpiA(newdir+lstrlenA(tmppath),tmpstr)==0 ||
+     lstrcmpiA(newdir+lstrlenA(tmppath),tmpstr1)==0,
+     "GetTempFileNameA returned '%s' which doesn't match '%s' or '%s'. id=%x\n",
+     newdir,tmpstr,tmpstr1,id);
+  ok(DeleteFileA(newdir),"Couldn't delete the temporary file we just created\n");
 
   for(unique=0;unique<3;unique++) {
     /* Nonexistent path */
     sprintf(invalid_dir, "%s\\%s",tmppath,"non_existent_dir_1jwj3y32nb3");
     SetLastError(0xdeadbeef);
     ok(!GetTempFileNameA(invalid_dir,"tfn",unique,newdir),"GetTempFileNameA should have failed\n");
-    ok(GetLastError()==ERROR_DIRECTORY || broken(GetLastError()==ERROR_PATH_NOT_FOUND)/*win98*/,
-    "got %d, expected ERROR_DIRECTORY\n", GetLastError());
+    ok(GetLastError()==ERROR_DIRECTORY,"got %u, expected ERROR_DIRECTORY\n", GetLastError());
 
     /* Check return value for unique !=0 */
     if(unique) {
@@ -489,12 +483,12 @@ static void test_CurrentDirectoryA(CHAR *origdir, CHAR *newdir)
   SetLastError( 0xdeadbeef );
   strcpy( buffer, "foo" );
   len = GetCurrentDirectoryA( 65536, buffer );
-  ok( (len != 0 && len < MAX_PATH) || broken(!len), /* nt4 */ "GetCurrentDirectoryA failed %u err %u\n", len, GetLastError() );
+  ok( (len != 0 && len < MAX_PATH), "GetCurrentDirectoryA failed %u err %u\n", len, GetLastError() );
   if (len) ok( !strcmp( buffer, origdir ), "wrong result %s\n", buffer );
   SetLastError( 0xdeadbeef );
   strcpy( buffer, "foo" );
   len = GetCurrentDirectoryA( 2 * 65536, buffer );
-  ok( (len != 0 && len < MAX_PATH) || broken(!len), /* nt4 */ "GetCurrentDirectoryA failed %u err %u\n", len, GetLastError() );
+  ok( (len != 0 && len < MAX_PATH), "GetCurrentDirectoryA failed %u err %u\n", len, GetLastError() );
   if (len) ok( !strcmp( buffer, origdir ), "wrong result %s\n", buffer );
   HeapFree( GetProcessHeap(), 0, buffer );
 
@@ -1004,11 +998,6 @@ static void test_GetTempPathW(char* tmp_dir)
 
     lstrcpyW(buf, fooW);
     len = GetTempPathW(MAX_PATH, buf);
-    if (len == 0 && GetLastError() == ERROR_CALL_NOT_IMPLEMENTED)
-    {
-        win_skip("GetTempPathW is not available\n");
-        return;
-    }
     ok(lstrcmpiW(buf, tmp_dirW) == 0, "GetTempPathW returned an incorrect temporary path\n");
     ok(len == lstrlenW(buf), "returned length should be equal to the length of string\n");
 
@@ -1185,12 +1174,6 @@ static void test_GetLongPathNameA(void)
 
     SetLastError(0xdeadbeef);
     length = GetLongPathNameA(temppath2, NULL, 0);
-    if (length == 0 && GetLastError() == ERROR_BAD_NET_NAME)
-    {
-        win_skip("UNC syntax tests don't work on Win98/WinMe\n");
-        DeleteFileA(tempfile);
-        return;
-    }
     ok(length == explength, "Wrong length %d, expected %d\n", length, explength);
 
     length = GetLongPathNameA(temppath2, NULL, MAX_PATH);
@@ -1275,11 +1258,6 @@ static void test_GetLongPathNameW(void)
 
     SetLastError(0xdeadbeef); 
     length = GetLongPathNameW(NULL,NULL,0);
-    if (GetLastError() == ERROR_CALL_NOT_IMPLEMENTED)
-    {
-        win_skip("GetLongPathNameW is not implemented\n");
-        return;
-    }
     ok(0==length,"GetLongPathNameW returned %d but expected 0\n",length);
     ok(GetLastError()==ERROR_INVALID_PARAMETER,"GetLastError returned %d but expected ERROR_INVALID_PARAMETER\n",GetLastError());
 
@@ -1371,13 +1349,7 @@ static void test_GetShortPathNameW(void)
     HANDLE file;
     int ret;
 
-    SetLastError(0xdeadbeef);
     GetTempPathW( MAX_PATH, tmppath );
-    if (GetLastError() == ERROR_CALL_NOT_IMPLEMENTED)
-    {
-        win_skip("GetTempPathW is not implemented\n");
-        return;
-    }
 
     lstrcpyW( path, tmppath );
     lstrcatW( path, test_path );
@@ -1462,11 +1434,8 @@ static void test_GetSystemDirectory(void)
 
     SetLastError(0xdeadbeef);
     res = GetSystemDirectoryA(NULL, total-1);
-    /* 95+NT: total (includes the terminating Zero)
-       98+ME: 0 with ERROR_INVALID_PARAMETER */
-    ok( (res == total) || (!res && (GetLastError() == ERROR_INVALID_PARAMETER)),
-        "returned %d with %d (expected '%d' or: '0' with "
-        "ERROR_INVALID_PARAMETER)\n", res, GetLastError(), total);
+    ok( res == total, "returned %u with %u (expected '%u')\n",
+        res, GetLastError(), total );
 
     if (total > MAX_PATH) return;
 
@@ -1521,11 +1490,8 @@ static void test_GetWindowsDirectory(void)
 
     SetLastError(0xdeadbeef);
     res = GetWindowsDirectoryA(NULL, total-1);
-    /* 95+NT: total (includes the terminating Zero)
-       98+ME: 0 with ERROR_INVALID_PARAMETER */
-    ok( (res == total) || (!res && (GetLastError() == ERROR_INVALID_PARAMETER)),
-        "returned %d with %d (expected '%d' or: '0' with "
-        "ERROR_INVALID_PARAMETER)\n", res, GetLastError(), total);
+    ok( res == total, "returned %u with %u (expected '%u')\n",
+        res, GetLastError(), total );
 
     if (total > MAX_PATH) return;
 
@@ -1912,11 +1878,11 @@ static void test_SearchPathW(void)
     HANDLE handle;
     DWORD ret;
 
-if (0)
-{
-    /* NULL filename, crashes on nt4 */
-    SearchPathW(pathW, NULL, NULL, ARRAY_SIZE(buffW), buffW, &ptrW);
-}
+    /* NULL filename */
+    ret = SearchPathW(pathW, NULL, NULL, ARRAY_SIZE(buffW), buffW, &ptrW);
+    ok(ret == 0, "Expected failure, got %d\n", ret);
+    ok(GetLastError() == ERROR_INVALID_PARAMETER,
+      "Expected ERROR_INVALID_PARAMETER, got %#x\n", GetLastError());
 
     GetWindowsDirectoryW(pathW, ARRAY_SIZE(pathW));
 
@@ -2105,14 +2071,6 @@ static void test_GetFullPathNameW(void)
         {emptyW, MAX_PATH, output, &filepart, 1},
     };
 
-    SetLastError(0xdeadbeef);
-    ret = GetFullPathNameW(NULL, 0, NULL, NULL);
-    if (!ret && GetLastError() == ERROR_CALL_NOT_IMPLEMENTED)
-    {
-        win_skip("GetFullPathNameW is not available\n");
-        return;
-    }
-
     for (i = 0; i < ARRAY_SIZE(invalid_parameters); i++)
     {
         SetLastError(0xdeadbeef);
-- 
2.34.1




More information about the wine-devel mailing list