From: Bruno Haible Date: Tue, 20 Sep 2011 21:17:56 +0000 (+0200) Subject: Tests for module 'unlockpt'. X-Git-Tag: v0.1~1804 X-Git-Url: http://erislabs.org.uk/gitweb/?a=commitdiff_plain;h=0ac9362d3e63ada72bef1cb93bb20ef5b9d01e44;p=gnulib.git 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. --- diff --git a/ChangeLog b/ChangeLog index 557fa44a1..12a2c318f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,10 @@ 2011-09-20 Bruno Haible + 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. diff --git a/doc/posix-functions/unlockpt.texi b/doc/posix-functions/unlockpt.texi index ea27164cf..254566006 100644 --- a/doc/posix-functions/unlockpt.texi +++ b/doc/posix-functions/unlockpt.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/unlockpt-tests b/modules/unlockpt-tests new file mode 100644 index 000000000..fd4b5acb2 --- /dev/null +++ b/modules/unlockpt-tests @@ -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 index 000000000..e7861ea75 --- /dev/null +++ b/tests/test-unlockpt.c @@ -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 . */ + +#include + +#include + +#include "signature.h" +SIGNATURE_CHECK (unlockpt, int, (int)); + +#include + +#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; +}