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

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

index 557fa44..12a2c31 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
 2011-09-20  Bruno Haible  <bruno@clisp.org>
 
+       Tests for module 'unlockpt'.
+       * modules/unlockpt-tests: New file.
+       * tests/test-unlockpt.c: New file.
+       * doc/posix-functions/unlockpt.texi: Mention the Cygwin 1.7 problem.
+
        Tests for module 'grantpt'.
        * modules/grantpt-tests: New file.
        * tests/test-grantpt.c: New file.
index ea27164..2545660 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/unlockpt-tests b/modules/unlockpt-tests
new file mode 100644 (file)
index 0000000..fd4b5ac
--- /dev/null
@@ -0,0 +1,12 @@
+Files:
+tests/test-unlockpt.c
+tests/signature.h
+tests/macros.h
+
+Depends-on:
+
+configure.ac:
+
+Makefile.am:
+TESTS += test-unlockpt
+check_PROGRAMS += test-unlockpt
diff --git a/tests/test-unlockpt.c b/tests/test-unlockpt.c
new file mode 100644 (file)
index 0000000..e7861ea
--- /dev/null
@@ -0,0 +1,48 @@
+/* Test unlocking 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 (unlockpt, int, (int));
+
+#include <errno.h>
+
+#include "macros.h"
+
+int
+main (void)
+{
+  /* Test behaviour for invalid file descriptors.  */
+  {
+    errno = 0;
+    ASSERT (unlockpt (-1) == -1);
+    ASSERT (errno == EBADF
+            || errno == EINVAL /* seen on FreeBSD 6.4 */
+           );
+  }
+  {
+    errno = 0;
+    ASSERT (unlockpt (99) == -1);
+    ASSERT (errno == EBADF
+            || errno == EINVAL /* seen on FreeBSD 6.4 */
+           );
+  }
+
+  return 0;
+}