ptsname test: Avoid failure on Solaris.
authorBruno Haible <bruno@clisp.org>
Sat, 25 Dec 2010 18:18:27 +0000 (19:18 +0100)
committerBruno Haible <bruno@clisp.org>
Sat, 25 Dec 2010 18:18:27 +0000 (19:18 +0100)
* tests/test-ptsname.c (main): For Solaris, use the recommended way to
open a pseudo-terminal; don't use BSD-style ptys.
* doc/posix-functions/ptsname.texi: Document the limitation on Solaris.

ChangeLog
doc/posix-functions/ptsname.texi
tests/test-ptsname.c

index adc21adaafbb70297ea20a59e387067660d4d439..c4e609cc56f5e3a72b0700899487621773897e70 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2010-12-25  Bruno Haible  <bruno@clisp.org>
+
+       ptsname test: Avoid failure on Solaris.
+       * tests/test-ptsname.c (main): For Solaris, use the recommended way to
+       open a pseudo-terminal; don't use BSD-style ptys.
+       * doc/posix-functions/ptsname.texi: Document the limitation on Solaris.
+
 2010-12-25  Bruno Haible  <bruno@clisp.org>
 
        ptsname: Avoid ERANGE failure on some systems.
index dd04337e9b07698cf5d2362c220030bd265f048c..912a4500d6472e7fb1871a7a1e4257bb418c0487 100644 (file)
@@ -15,4 +15,7 @@ MacOS X 10.3, OpenBSD 3.8, mingw, BeOS.
 
 Portability problems not fixed by Gnulib:
 @itemize
+@item
+On Solaris 11 2010-11, this function fails on all BSD-style @file{/dev/pty*}
+device files.
 @end itemize
index 8c95100a298292aad316ad98753c90d48da90e6a..13596da1ffda968d6a187070b125ecf4d23933fd 100644 (file)
@@ -77,6 +77,30 @@ main (void)
     close (fd);
   }
 
+#if defined __sun
+  /* Solaris has BSD-style /dev/pty[p-r][0-9a-f] files, but the function
+     ptsname() does not work on them.  */
+  {
+    int fd;
+    char *result;
+
+    /* Open the controlling tty of the current process.  */
+    fd = open ("/dev/ptmx", O_RDWR | O_NOCTTY);
+    if (fd < 0)
+      {
+        fprintf (stderr, "Skipping test: cannot open pseudo-terminal\n");
+        return 77;
+      }
+
+    result = ptsname (fd);
+    ASSERT (result != NULL);
+    ASSERT (memcmp (result, "/dev/pts/", 9) == 0);
+
+    close (fd);
+  }
+
+#else
+
   /* Try various master names of MacOS X: /dev/pty[p-w][0-9a-f]  */
   {
     int char1;
@@ -135,5 +159,7 @@ main (void)
           }
   }
 
+#endif
+
   return 0;
 }