pwrite tests: EBADF tests.
authorBruno Haible <bruno@clisp.org>
Tue, 20 Sep 2011 20:14:38 +0000 (22:14 +0200)
committerBruno Haible <bruno@clisp.org>
Tue, 20 Sep 2011 21:27:56 +0000 (23:27 +0200)
* tests/test-pwrite.c (main): Add tests for EBADF.

ChangeLog
tests/test-pwrite.c

index ac63818..ff64014 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
 2011-09-20  Bruno Haible  <bruno@clisp.org>
 
+       pwrite tests: EBADF tests.
+       * tests/test-pwrite.c (main): Add tests for EBADF.
+
        pread tests: EBADF tests.
        * tests/test-pread.c (main): Add tests for EBADF.
 
index 0139391..5875b5a 100644 (file)
@@ -76,5 +76,20 @@ main (void)
     ASSERT (close (fd) == 0);
     ASSERT (strcmp ("W1W3W5W7W9",buf) == 0);
   }
+
+  /* Test behaviour for invalid file descriptors.  */
+  {
+    char byte = 'x';
+    errno = 0;
+    ASSERT (pwrite (-1, &byte, 1, 0) == -1);
+    ASSERT (errno == EBADF);
+  }
+  {
+    char byte = 'x';
+    errno = 0;
+    ASSERT (pwrite (99, &byte, 1, 0) == -1);
+    ASSERT (errno == EBADF);
+  }
+
   return 0;
 }