Re: Fix msvcrt file test, take 2

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Here is a review of write_read subtest.  It supercedes
my previous patch, which should not be applied.  I wrote:

> On Windows, files opened with _O_RDONLY receive the
> read-only attribute and hence can't be unlinked.

Of course it's not _O_RDONLY what counts, but the lack of
_S_IWRITE in the mode argument.  I must have been drunk, sorry.

> What's more, errno is set to ENOENT on XP, contrary to MSDN.

Which gave me a hard time finding out the real problem. :)

> So we have to change the mode before attempting the deletion.

ChangeLog: Fix undeleted temporary file.
           Correct error messages and comments, break long lines.

> Feri.

Index: dlls/msvcrt/tests/file.c
===================================================================
RCS file: /home/wine/wine/dlls/msvcrt/tests/file.c,v
retrieving revision 1.6
diff -u -r1.6 file.c
--- dlls/msvcrt/tests/file.c	24 Oct 2003 00:24:08 -0000	1.6
+++ dlls/msvcrt/tests/file.c	22 Dec 2003 14:01:34 -0000
@@ -185,35 +185,50 @@
   char btext[LLEN];
 
   tempf=_tempnam(".","wne");
-  ok((tempfd = _open(tempf,_O_CREAT|_O_TRUNC|_O_TEXT|_O_RDWR,_S_IREAD | _S_IWRITE)) != -1,"Can't open"); /* open in TEXT mode */
-  ok(_write(tempfd,mytext,strlen(mytext)) == lstrlenA(mytext), "_write _O_TEXT bad return value");
+  ok((tempfd = _open(tempf,_O_CREAT|_O_TRUNC|_O_TEXT|_O_RDWR,
+                     _S_IREAD | _S_IWRITE)) != -1,
+     "Can't open '%s': %d", tempf, errno); /* open in TEXT mode */
+  ok(_write(tempfd,mytext,strlen(mytext)) == lstrlenA(mytext),
+     "_write _O_TEXT bad return value");
   _close(tempfd);
   tempfd = _open(tempf,_O_RDONLY|_O_BINARY,0); /* open in BINARY mode */
-  ok(_read(tempfd,btext,LLEN) == lstrlenA(dostext), "_read _O_BINARY got bad length");
-  ok( memcmp(dostext,btext,strlen(dostext)) == 0,"problems with _O_TEXT _write and _O_BINARY _write");
-  ok( btext[strlen(dostext)-2] == '\r', "CR not written");
+  ok(_read(tempfd,btext,LLEN) == lstrlenA(dostext),
+     "_read _O_BINARY got bad length");
+  ok( memcmp(dostext,btext,strlen(dostext)) == 0,
+      "problems with _O_TEXT _write / _O_BINARY _read");
+  ok( btext[strlen(dostext)-2] == '\r', "CR not written or read");
   _close(tempfd);
   tempfd = _open(tempf,_O_RDONLY|_O_TEXT); /* open in TEXT mode */
-  ok(_read(tempfd,btext,LLEN) == lstrlenA(mytext), "_read _O_TEXT got bad length");
-  ok( memcmp(mytext,btext,strlen(mytext)) == 0,"problems with _O_TEXT _write / _write");
+  ok(_read(tempfd,btext,LLEN) == lstrlenA(mytext),
+     "_read _O_TEXT got bad length");
+  ok( memcmp(mytext,btext,strlen(mytext)) == 0,
+      "problems with _O_TEXT _write / _read");
   _close(tempfd);
-  ok(unlink(tempf) !=-1 ,"Can't unlink");
+  ok(unlink(tempf) !=-1 ,"Can't unlink '%s': %d", tempf, errno);
 
   tempf=_tempnam(".","wne");
-  ok((tempfd = _open(tempf,_O_CREAT|_O_TRUNC|_O_BINARY|_O_RDWR,0)) != -1,"Can't open %s",tempf); /* open in BINARY mode */
-  ok(_write(tempfd,dostext,strlen(dostext)) == lstrlenA(dostext), "_write _O_TEXT bad return value");
+  ok((tempfd = _open(tempf,_O_CREAT|_O_TRUNC|_O_BINARY|_O_RDWR,0)) != -1,
+     "Can't open '%s': %d", tempf, errno); /* open in BINARY mode */
+  ok(_write(tempfd,dostext,strlen(dostext)) == lstrlenA(dostext),
+     "_write _O_BINARY bad return value");
   _close(tempfd);
   tempfd = _open(tempf,_O_RDONLY|_O_BINARY,0); /* open in BINARY mode */
-  ok(_read(tempfd,btext,LLEN) == lstrlenA(dostext), "_read _O_BINARY got bad length");
-  ok( memcmp(dostext,btext,strlen(dostext)) == 0,"problems with _O_TEXT _write and _O_BINARY _write");
-  ok( btext[strlen(dostext)-2] == '\r', "CR not written");
+  ok(_read(tempfd,btext,LLEN) == lstrlenA(dostext),
+     "_read _O_BINARY got bad length");
+  ok( memcmp(dostext,btext,strlen(dostext)) == 0,
+      "problems with _O_BINARY _write / _read");
+  ok( btext[strlen(dostext)-2] == '\r', "CR not written or read");
   _close(tempfd);
   tempfd = _open(tempf,_O_RDONLY|_O_TEXT); /* open in TEXT mode */
-  ok(_read(tempfd,btext,LLEN) == lstrlenA(mytext), "_read _O_TEXT got bad length");
-  ok( memcmp(mytext,btext,strlen(mytext)) == 0,"problems with _O_TEXT _write / _write");
+  ok(_read(tempfd,btext,LLEN) == lstrlenA(mytext),
+     "_read _O_TEXT got bad length");
+  ok( memcmp(mytext,btext,strlen(mytext)) == 0,
+      "problems with _O_BINARY _write / _O_TEXT _read");
   _close(tempfd);
 
-  unlink(tempf);
+  ok(_chmod (tempf, _S_IREAD | _S_IWRITE) == 0,
+     "Can't chmod '%s' to read-write: %d", tempf, errno);
+  ok(unlink(tempf) !=-1 ,"Can't unlink '%s': %d", tempf, errno);
 }
 
 static void test_tmpnam( void )


[Index of Archives]     [Gimp for Windows]     [Red Hat]     [Samba]     [Yosemite Camping]     [Graphics Cards]     [Wine Home]

  Powered by Linux