From: Bruno Haible Date: Sat, 25 Dec 2010 18:18:27 +0000 (+0100) Subject: ptsname test: Avoid failure on Solaris. X-Git-Tag: v0.1~3457 X-Git-Url: http://erislabs.net/gitweb/?a=commitdiff_plain;h=168fc669c003eebe51fb61480d363f8a44695083;p=gnulib.git 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. --- diff --git a/ChangeLog b/ChangeLog index adc21adaa..c4e609cc5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,12 @@ 2010-12-25 Bruno Haible + 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 + ptsname: Avoid ERANGE failure on some systems. * lib/ptsname.c (buffer): Increase size. diff --git a/doc/posix-functions/ptsname.texi b/doc/posix-functions/ptsname.texi index dd04337e9..912a4500d 100644 --- a/doc/posix-functions/ptsname.texi +++ b/doc/posix-functions/ptsname.texi @@ -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 diff --git a/tests/test-ptsname.c b/tests/test-ptsname.c index 8c95100a2..13596da1f 100644 --- a/tests/test-ptsname.c +++ b/tests/test-ptsname.c @@ -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; }