changeset 16939:76ca51754604

ptsname test: Extend test. * tests/test-ptsname.c: Include <errno.h>. (main): Test behaviour with invalid file descriptor.
author Bruno Haible <bruno@clisp.org>
date Sun, 24 Jun 2012 14:53:43 +0200
parents 7bd21b317d8e
children f0c9b2dc0596
files ChangeLog tests/test-ptsname.c
diffstat 2 files changed, 18 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- 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
--- a/tests/test-ptsname.c
+++ b/tests/test-ptsname.c
@@ -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 @@
 #endif
 
   {
+    char *result;
+
+    errno = 0;
+    result = ptsname (-1);
+    ASSERT (result == NULL);
+    ASSERT (errno == EBADF
+            || errno == ENOTTY /* seen on glibc */
+           );
+  }
+
+  {
     int fd;
     char *result;