changeset 15696:710ef6879d5b

Tests for module 'isatty'. * modules/isatty-tests: New file. * tests/test-isatty.c: New file.
author Bruno Haible <bruno@clisp.org>
date Tue, 20 Sep 2011 22:19:24 +0200
parents 7ff473baf3d5
children a4ad24b6e079
files ChangeLog modules/isatty-tests tests/test-isatty.c
diffstat 3 files changed, 65 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
 2011-09-20  Bruno Haible  <bruno@clisp.org>
 
+	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.
new file mode 100644
--- /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
new file mode 100644
--- /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 <http://www.gnu.org/licenses/>.  */
+
+#include <config.h>
+
+#include <unistd.h>
+
+#include "signature.h"
+SIGNATURE_CHECK (isatty, int, (int));
+
+#include <errno.h>
+
+#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;
+}