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

ChangeLog
tests/test-pread.c

index 642ac0e..ac63818 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
 2011-09-20  Bruno Haible  <bruno@clisp.org>
 
+       pread tests: EBADF tests.
+       * tests/test-pread.c (main): Add tests for EBADF.
+
        lseek tests: EBADF tests.
        * tests/test-lseek.c (main): Add more tests for EBADF.
 
index 3e35640..5515f59 100644 (file)
@@ -83,5 +83,19 @@ main (void)
     ASSERT (errno == ESPIPE);
   }
 
+  /* Test behaviour for invalid file descriptors.  */
+  {
+    char byte;
+    errno = 0;
+    ASSERT (pread (-1, &byte, 1, 0) == -1);
+    ASSERT (errno == EBADF);
+  }
+  {
+    char byte;
+    errno = 0;
+    ASSERT (pread (99, &byte, 1, 0) == -1);
+    ASSERT (errno == EBADF);
+  }
+
   return 0;
 }