Aric Stewart : msvcrt: Modify dir test to create its own directory to ensure the

Alexandre Julliard julliard at wine.codeweavers.com
Wed Jan 11 14:34:27 CST 2006


Module: wine
Branch: refs/heads/master
Commit: 4bc3b16b449d0508f16f324e82228d752d4792da
URL:    http://source.winehq.org/git/?p=wine.git;a=commit;h=4bc3b16b449d0508f16f324e82228d752d4792da

Author: Aric Stewart <aric at codeweavers.com>
Date:   Wed Jan 11 20:55:38 2006 +0100

msvcrt: Modify dir test to create its own directory to ensure the
directory exists for the test. Using the temp dir as the root.

---

 dlls/msvcrt/tests/dir.c |   49 +++++++++++++++++++++++++++++++++++++++--------
 1 files changed, 41 insertions(+), 8 deletions(-)

diff --git a/dlls/msvcrt/tests/dir.c b/dlls/msvcrt/tests/dir.c
index 5e12f84..b7d1aa2 100644
--- a/dlls/msvcrt/tests/dir.c
+++ b/dlls/msvcrt/tests/dir.c
@@ -34,22 +34,55 @@
 void test_fullpath()
 {
     char full[MAX_PATH];
+    char tmppath[MAX_PATH];
+    char level1[MAX_PATH];
+    char level2[MAX_PATH];
+    char teststring[MAX_PATH];
     char *freeme;
+    BOOL rc,free1,free2;
 
-    SetCurrentDirectory("C:\\Windows\\System\\");
+    free1=free2=TRUE;
+    GetTempPath(MAX_PATH,tmppath);
+    strcpy(level1,tmppath);
+    strcat(level1,"msvcrt-test\\");
 
-    ok(_fullpath(full,"test", MAX_PATH)>0,"_fullpath failed\n");
-    ok(strcmp(full,"C:\\Windows\\System\\test")==0,"Invalid Path\n");
-    ok(_fullpath(full,"\\test", MAX_PATH)>0,"_fullpath failed\n");
-    ok(strcmp(full,"C:\\test")==0,"Invalid Path\n");
-    ok(_fullpath(full,"..\\test", MAX_PATH)>0,"_fullpath failed\n");
-    ok(strcmp(full,"C:\\Windows\\test")==0,"Invalid Path\n");
+    rc = CreateDirectory(level1,NULL);
+    if (!rc && GetLastError()==ERROR_ALREADY_EXISTS)
+        free1=FALSE;
+
+    strcpy(level2,level1);
+    strcat(level2,"nextlevel\\");
+    rc = CreateDirectory(level2,NULL);
+    if (!rc && GetLastError()==ERROR_ALREADY_EXISTS)
+        free2=FALSE;
+    SetCurrentDirectory(level2);
+
+    ok(_fullpath(full,"test", MAX_PATH)!=NULL,"_fullpath failed\n");
+    strcpy(teststring,level2);
+    strcat(teststring,"test");
+    ok(strcmp(full,teststring)==0,"Invalid Path returned %s\n",full);
+    ok(_fullpath(full,"\\test", MAX_PATH)!=NULL,"_fullpath failed\n");
+    strncpy(teststring,level2,3);
+    teststring[3]=0;
+    strcat(teststring,"test");
+    ok(strcmp(full,teststring)==0,"Invalid Path returned %s\n",full);
+    ok(_fullpath(full,"..\\test", MAX_PATH)!=NULL,"_fullpath failed\n");
+    strcpy(teststring,level1);
+    strcat(teststring,"test");
+    ok(strcmp(full,teststring)==0,"Invalid Path returned %s\n",full);
     ok(_fullpath(full,"..\\test", 10)==NULL,"_fullpath failed to generate error\n");
 
     freeme = _fullpath(NULL,"test", 0);
     ok(freeme!=NULL,"No path returned\n");
-    ok(strcmp(freeme,"C:\\Windows\\System\\test")==0,"Invalid Path\n");
+    strcpy(teststring,level2);
+    strcat(teststring,"test");
+    ok(strcmp(freeme,teststring)==0,"Invalid Path returned %s\n",freeme);
     free(freeme);
+
+    if (free2)
+        RemoveDirectory(level2);
+    if (free1)
+        RemoveDirectory(level1);
 }
 
 START_TEST(dir)




More information about the wine-cvs mailing list