From: Bruno Haible Date: Tue, 20 Sep 2011 21:16:35 +0000 (+0200) Subject: Tests for module 'grantpt'. X-Git-Tag: v0.1~1805 X-Git-Url: http://erislabs.org.uk/gitweb/?a=commitdiff_plain;h=3fb17463419b9e53c2067a9ac1e4e76770af4d40;p=gnulib.git 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. --- diff --git a/ChangeLog b/ChangeLog index 21682097c..557fa44a1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,12 @@ 2011-09-20 Bruno Haible + 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 + freopen tests: EBADF tests. * tests/test-freopen.c: Include errno.h, unistd.h. (main): Add tests for EBADF, commented out for the moment. diff --git a/doc/posix-functions/grantpt.texi b/doc/posix-functions/grantpt.texi index e283ada66..53c9b4891 100644 --- a/doc/posix-functions/grantpt.texi +++ b/doc/posix-functions/grantpt.texi @@ -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 index 000000000..b1fdae23f --- /dev/null +++ b/modules/grantpt-tests @@ -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 index 000000000..e32add86b --- /dev/null +++ b/tests/test-grantpt.c @@ -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 . */ + +#include + +#include + +#include "signature.h" +SIGNATURE_CHECK (grantpt, int, (int)); + +#include + +#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; +}