[PATCH 3/3] kernel32/tests: Add a test for opening short paths of differing case.

Charles Davis cdavis at mymail.mines.edu
Wed Oct 27 20:46:46 CDT 2010


---
 dlls/kernel32/tests/path.c |   25 +++++++++++++++++++++++++
 1 files changed, 25 insertions(+), 0 deletions(-)

diff --git a/dlls/kernel32/tests/path.c b/dlls/kernel32/tests/path.c
index 0065ebf..3ebb99a 100644
--- a/dlls/kernel32/tests/path.c
+++ b/dlls/kernel32/tests/path.c
@@ -555,6 +555,27 @@ static void test_CleanupPathA(CHAR *origdir, CHAR *curdir)
   ok(RemoveDirectoryA(curdir),"RemoveDirectoryA failed\n");
 }
 
+/* test that short path name functions work regardless of case */
+static void test_ShortPathCase(const char *tmpdir, const char *dirname,
+                               const char *filename)
+{
+    char buf[MAX_PATH], shortbuf[MAX_PATH];
+    HANDLE hndl;
+    int i;
+
+    sprintf(buf,"%s\\%s\\%s",tmpdir,dirname,filename);
+    GetShortPathNameA(buf,shortbuf,MAX_PATH);
+    hndl = CreateFileA(shortbuf,GENERIC_READ|GENERIC_WRITE,0,NULL,OPEN_EXISTING,0,NULL);
+    ok(hndl!=INVALID_HANDLE_VALUE,"CreateFileA failed\n");
+    CloseHandle(hndl);
+    /* Now for the real test */
+    for(i=0;i<MAX_PATH && shortbuf[i];i++)
+        shortbuf[i]=(rand() % 2) ? tolower(shortbuf[i]) : toupper(shortbuf[i]);
+    hndl = CreateFileA(shortbuf,GENERIC_READ|GENERIC_WRITE,0,NULL,OPEN_EXISTING,0,NULL);
+    ok(hndl!=INVALID_HANDLE_VALUE,"CreateFileA failed\n");
+    CloseHandle(hndl);
+}
+
 /* This routine will test Get(Full|Short|Long)PathNameA */
 static void test_PathNameA(CHAR *curdir, CHAR curDrive, CHAR otherDrive)
 {
@@ -878,6 +899,10 @@ static void test_PathNameA(CHAR *curdir, CHAR curDrive, CHAR otherDrive)
     sprintf(tmpstr,"Long File %c",funny_chars[i]);
     test_FunnyChars(curdir,curdir_short,tmpstr,valid,tmpstr1);
   }
+  /* Now try it on mixed case short names */
+  test_ShortPathCase(curdir,SHORTDIR,LONGFILE);
+  test_ShortPathCase(curdir,LONGDIR,SHORTFILE);
+  test_ShortPathCase(curdir,LONGDIR,LONGFILE);
 }
 
 static void test_GetTempPathA(char* tmp_dir)
-- 
1.7.3.2




More information about the wine-patches mailing list