Tests for module 'grantpt'.
authorBruno Haible <bruno@clisp.org>
Tue, 20 Sep 2011 21:16:35 +0000 (23:16 +0200)
committerBruno Haible <bruno@clisp.org>
Tue, 20 Sep 2011 21:28:05 +0000 (23:28 +0200)
* modules/grantpt-tests: New file.
* tests/test-grantpt.c: New file.
* doc/posix-functions/grantpt.texi: Mention the Cygwin 1.7 problem.

ChangeLog
doc/posix-functions/grantpt.texi
modules/grantpt-tests [new file with mode: 0644]
tests/test-grantpt.c [new file with mode: 0644]

index 2168209..557fa44 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
 2011-09-20  Bruno Haible  <bruno@clisp.org>
 
+       Tests for module 'grantpt'.
+       * modules/grantpt-tests: New file.
+       * tests/test-grantpt.c: New file.
+       * doc/posix-functions/grantpt.texi: Mention the Cygwin 1.7 problem.
+
+2011-09-20  Bruno Haible  <bruno@clisp.org>
+
        freopen tests: EBADF tests.
        * tests/test-freopen.c: Include errno.h, unistd.h.
        (main): Add tests for EBADF, commented out for the moment.
index e283ada..53c9b48 100644 (file)
@@ -15,4 +15,7 @@ MacOS X 10.3, OpenBSD 3.8, Minix 3.1.8, mingw, MSVC 9, BeOS.
 
 Portability problems not fixed by Gnulib:
 @itemize
+@item
+This function reports success for invalid file descriptors on some platforms:
+Cygwin 1.7.9.
 @end itemize
diff --git a/modules/grantpt-tests b/modules/grantpt-tests
new file mode 100644 (file)
index 0000000..b1fdae2
--- /dev/null
@@ -0,0 +1,12 @@
+Files:
+tests/test-grantpt.c
+tests/signature.h
+tests/macros.h
+
+Depends-on:
+
+configure.ac:
+
+Makefile.am:
+TESTS += test-grantpt
+check_PROGRAMS += test-grantpt
diff --git a/tests/test-grantpt.c b/tests/test-grantpt.c
new file mode 100644 (file)
index 0000000..e32add8
--- /dev/null
@@ -0,0 +1,50 @@
+/* Test acquiring ownership of the slave side of a pseudo-terminal.
+   Copyright (C) 2011 Free Software Foundation, Inc.
+
+   This program is free software: you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+#include <config.h>
+
+#include <stdlib.h>
+
+#include "signature.h"
+SIGNATURE_CHECK (grantpt, int, (int));
+
+#include <errno.h>
+
+#include "macros.h"
+
+int
+main (void)
+{
+  /* Test behaviour for invalid file descriptors.  */
+  {
+    errno = 0;
+    ASSERT (grantpt (-1) == -1);
+    ASSERT (errno == EBADF
+            || errno == EINVAL /* seen on FreeBSD 6.4 */
+            || errno == 0 /* seen on Solaris 8 */
+           );
+  }
+  {
+    errno = 0;
+    ASSERT (grantpt (99) == -1);
+    ASSERT (errno == EBADF
+            || errno == EINVAL /* seen on FreeBSD 6.4 */
+            || errno == 0 /* seen on Solaris 8 */
+           );
+  }
+
+  return 0;
+}