From 52dad573f699c4202ab719e4ec602b22abfd83bf Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Tue, 20 Sep 2011 22:19:24 +0200 Subject: [PATCH] Tests for module 'isatty'. * modules/isatty-tests: New file. * tests/test-isatty.c: New file. --- ChangeLog | 4 ++++ modules/isatty-tests | 13 +++++++++++++ tests/test-isatty.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 65 insertions(+) create mode 100644 modules/isatty-tests create mode 100644 tests/test-isatty.c diff --git a/ChangeLog b/ChangeLog index b41afd371..2ee54d819 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,9 @@ 2011-09-20 Bruno Haible + Tests for module 'isatty'. + * modules/isatty-tests: New file. + * tests/test-isatty.c: New file. + Tests for module 'write'. * modules/write-tests: New file. * tests/test-write.c: New file. diff --git a/modules/isatty-tests b/modules/isatty-tests new file mode 100644 index 000000000..ce699e3f7 --- /dev/null +++ b/modules/isatty-tests @@ -0,0 +1,13 @@ +Files: +tests/test-isatty.c +tests/signature.h +tests/macros.h + +Depends-on: +unistd + +configure.ac: + +Makefile.am: +TESTS += test-isatty +check_PROGRAMS += test-isatty diff --git a/tests/test-isatty.c b/tests/test-isatty.c new file mode 100644 index 000000000..dba8854dd --- /dev/null +++ b/tests/test-isatty.c @@ -0,0 +1,48 @@ +/* Test isatty() function. + 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 (isatty, int, (int)); + +#include + +#include "macros.h" + +int +main (void) +{ + /* Test behaviour for invalid file descriptors. */ + { + errno = 0; + ASSERT (isatty (-1) == 0); + ASSERT (errno == EBADF + || errno == 0 /* seen on Solaris 10 */ + ); + } + { + errno = 0; + ASSERT (isatty (99) == 0); + ASSERT (errno == EBADF + || errno == 0 /* seen on Solaris 10 */ + ); + } + + return 0; +} -- 2.11.0