# HG changeset patch # User Bruno Haible # Date 1316553395 -7200 # Node ID 95514a6910a3b9f889a5bd0b8bddf3ff69cb40b5 # Parent 3a20a51c132304fec811bd2cf365e8805682434c 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 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +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. diff --git a/doc/posix-functions/grantpt.texi b/doc/posix-functions/grantpt.texi --- a/doc/posix-functions/grantpt.texi +++ b/doc/posix-functions/grantpt.texi @@ -15,4 +15,7 @@ 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 --- /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 --- /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; +}