bug-gnulib
[Top][All Lists]
Advanced

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

ptsname test


From: Bruno Haible
Subject: ptsname test
Date: Sun, 24 Jun 2012 14:56:34 +0200
User-agent: KMail/4.7.4 (Linux/3.1.10-1.9-desktop; KDE/4.7.4; x86_64; ; )

On all platforms, ptsname() sets errno when the argument is an invalid
file descriptor. Even through POSIX does not require it [1], it's safe to
check it.

[1] http://pubs.opengroup.org/onlinepubs/9699919799/functions/ptsname.html


2012-06-24  Bruno Haible  <address@hidden>

        ptsname test: Extend test.
        * tests/test-ptsname.c: Include <errno.h>.
        (main): Test behaviour with invalid file descriptor.

--- tests/test-ptsname.c.orig   Sun Jun 24 14:51:29 2012
+++ tests/test-ptsname.c        Sun Jun 24 14:42:35 2012
@@ -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;
 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]