ptsname test: Extend test.
authorBruno Haible <bruno@clisp.org>
Sun, 24 Jun 2012 12:53:43 +0000 (14:53 +0200)
committerBruno Haible <bruno@clisp.org>
Sun, 24 Jun 2012 12:54:20 +0000 (14:54 +0200)
* tests/test-ptsname.c: Include <errno.h>.
(main): Test behaviour with invalid file descriptor.

ChangeLog
tests/test-ptsname.c

index df89859..45173a4 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2012-06-24  Bruno Haible  <bruno@clisp.org>
+
+       ptsname test: Extend test.
+       * tests/test-ptsname.c: Include <errno.h>.
+       (main): Test behaviour with invalid file descriptor.
+
 2012-06-23  Paul Eggert  <eggert@cs.ucla.edu>
 
        time: fix obsolete comment
index 06c78ea..d27e7d6 100644 (file)
@@ -21,6 +21,7 @@
 #include "signature.h"
 SIGNATURE_CHECK (ptsname, char *, (int));
 
+#include <errno.h>
 #include <fcntl.h>
 #include <signal.h>
 #include <stdio.h>
@@ -63,6 +64,17 @@ main (void)
 #endif
 
   {
+    char *result;
+
+    errno = 0;
+    result = ptsname (-1);
+    ASSERT (result == NULL);
+    ASSERT (errno == EBADF
+            || errno == ENOTTY /* seen on glibc */
+           );
+  }
+
+  {
     int fd;
     char *result;