changeset 8886:b828a58c6933

Tests for module 'fseek'.
author Bruno Haible <bruno@clisp.org>
date Mon, 28 May 2007 15:07:41 +0000
parents 3995f1e5ccc7
children 42187fcef367
files ChangeLog modules/fseek-tests tests/test-fseek.c tests/test-fseek.sh
diffstat 4 files changed, 52 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
 2007-05-28  Bruno Haible  <bruno@clisp.org>
 
+	* modules/fseek-tests: New file.
+	* tests/test-fseek.c: New file, based on tests/test-fseeko.c.
+	* tests/test-fseek.sh: New file, based on tests/test-fseeko.sh.
+
 	* lib/fseek.c: New file.
 	* modules/fseek: New file.
 	* m4/fseek.m4: New file.
new file mode 100644
--- /dev/null
+++ b/modules/fseek-tests
@@ -0,0 +1,13 @@
+Files:
+tests/test-fseek.c
+tests/test-fseek.sh
+
+Depends-on:
+
+configure.ac:
+
+Makefile.am:
+TESTS += test-fseek.sh
+TESTS_ENVIRONMENT += EXEEXT='@EXEEXT@' srcdir='$(srcdir)'
+check_PROGRAMS += test-fseek
+EXTRA_DIST += test-fseek.sh
new file mode 100644
--- /dev/null
+++ b/tests/test-fseek.c
@@ -0,0 +1,30 @@
+/* Test of fseek() function.
+   Copyright (C) 2007 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 2, 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, write to the Free Software Foundation,
+   Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
+
+/* Written by Bruno Haible <bruno@clisp.org>, 2007.  */
+
+#include <config.h>
+
+#include <stdio.h>
+
+int
+main (int argc, char **argv)
+{
+  /* Assume stdin is seekable iff argc > 1.  */
+  int expected = argc > 1 ? 0 : -1;
+  return fseek (stdin, 0, SEEK_CUR) != expected;
+}
new file mode 100755
--- /dev/null
+++ b/tests/test-fseek.sh
@@ -0,0 +1,5 @@
+#!/bin/sh
+
+./test-fseek${EXEEXT} 1 < "$srcdir/test-fseek.sh" || exit 1
+echo hi | ./test-fseek${EXEEXT} || exit 1
+exit 0