* m4/ungetc.m4: New file.
* modules/fseek-tests: Split test, so ungetc dependency is
separate from rest of test.
* modules/fseeko-tests: Likewise.
* modules/ftell-tests: Likewise.
* modules/ftello-tests: Likewise.
* tests/test-fseek.c (main): Isolate ungetc dependency.
* tests/test-fseeko.c (main): Likewise.
* tests/test-ftell.c (main): Likewise.
* tests/test-ftello.c (main): Likewise.
* tests/test-fseek2.sh: New file.
* tests/test-fseeko2.sh: Likewise.
* tests/test-ftell2.sh: Likewise.
* tests/test-ftello2.sh: Likewise.
+2009-02-25 Eric Blake <ebb9@byu.net>
+
+ tests: skip fseek/ftell tests if ungetc is broken
+ * m4/ungetc.m4: New file.
+ * modules/fseek-tests: Split test, so ungetc dependency is
+ separate from rest of test.
+ * modules/fseeko-tests: Likewise.
+ * modules/ftell-tests: Likewise.
+ * modules/ftello-tests: Likewise.
+ * tests/test-fseek.c (main): Isolate ungetc dependency.
+ * tests/test-fseeko.c (main): Likewise.
+ * tests/test-ftell.c (main): Likewise.
+ * tests/test-ftello.c (main): Likewise.
+ * tests/test-fseek2.sh: New file.
+ * tests/test-fseeko2.sh: Likewise.
+ * tests/test-ftell2.sh: Likewise.
+ * tests/test-ftello2.sh: Likewise.
+
2009-02-25 Ondřej Vašík <ovasik@redhat.com>
test-getaddrinfo: fix usage of skip return code 77
the parent of a directory specified on the command-line.
2009-02-17 James Youngman <jay@gnu.org>
- Bruno Haible <bruno@clisp.org>
+ Bruno Haible <bruno@clisp.org>
* m4/include_next.m4: Reformulate comment.
--- /dev/null
+# ungetc.m4 serial 1
+dnl Copyright (C) 2009 Free Software Foundation, Inc.
+dnl This file is free software; the Free Software Foundation
+dnl gives unlimited permission to copy and/or distribute it,
+dnl with or without modifications, as long as this notice is preserved.
+
+AC_DEFUN_ONCE([gl_FUNC_UNGETC_WORKS],
+[
+ AC_REQUIRE([AC_PROG_CC])
+
+ AC_CACHE_CHECK([whether ungetc works on arbitrary bytes],
+ [gl_cv_func_ungetc_works],
+ [AC_RUN_IFELSE([AC_LANG_PROGRAM([[
+#include <stdio.h>
+ ]], [FILE *f; long l;
+ if (!(f = fopen ("conftest.tmp", "w+"))) return 1;
+ if (fputs ("abc", f) < 0) return 2;
+ rewind (f);
+ if (fgetc (f) != 'a') return 3;
+ if (fgetc (f) != 'b') return 4;
+ if (ungetc ('d', f) != 'd') return 5;
+ if (ftell (f) != 1) return 6;
+ if (fgetc (f) != 'd') return 7;
+ if (ftell (f) != 2) return 8;
+ if (fseek (f, 0, SEEK_CUR) != 0) return 9;
+ if (ftell (f) != 2) return 10;
+ if (fgetc (f) != 'c') return 11;
+ fclose (f); remove ("conftest.tmp");])],
+ [gl_cv_func_ungetc_works=yes], [gl_cv_func_ungetc_works=no],
+ [gl_cv_func_ungetc_works='guessing no'])
+ ])
+ if test "$gl_cv_func_ungetc_works" != yes; then
+ AC_DEFINE([FUNC_UNGETC_BROKEN], [1],
+ [Define to 1 if ungetc is broken when used on arbitrary bytes.])
+ fi
+])
Files:
tests/test-fseek.c
tests/test-fseek.sh
+tests/test-fseek2.sh
+m4/ungetc.m4
Depends-on:
configure.ac:
+gl_FUNC_UNGETC_WORKS
Makefile.am:
-TESTS += test-fseek.sh
+TESTS += test-fseek.sh test-fseek2.sh
TESTS_ENVIRONMENT += EXEEXT='@EXEEXT@' srcdir='$(srcdir)'
check_PROGRAMS += test-fseek
Files:
tests/test-fseeko.c
tests/test-fseeko.sh
+tests/test-fseeko2.sh
+m4/ungetc.m4
Depends-on:
configure.ac:
+gl_FUNC_UNGETC_WORKS
Makefile.am:
-TESTS += test-fseeko.sh
+TESTS += test-fseeko.sh test-fseeko2.sh
TESTS_ENVIRONMENT += EXEEXT='@EXEEXT@' srcdir='$(srcdir)'
check_PROGRAMS += test-fseeko
Files:
tests/test-ftell.c
tests/test-ftell.sh
+tests/test-ftell2.sh
+m4/ungetc.m4
Depends-on:
binary-io
configure.ac:
+gl_FUNC_UNGETC_WORKS
Makefile.am:
-TESTS += test-ftell.sh
+TESTS += test-ftell.sh test-ftell2.sh
TESTS_ENVIRONMENT += EXEEXT='@EXEEXT@' srcdir='$(srcdir)'
check_PROGRAMS += test-ftell
Files:
tests/test-ftello.c
tests/test-ftello.sh
+tests/test-ftello2.sh
+m4/ungetc.m4
Depends-on:
binary-io
configure.ac:
+gl_FUNC_UNGETC_WORKS
Makefile.am:
-TESTS += test-ftello.sh
+TESTS += test-ftello.sh test-ftello2.sh
TESTS_ENVIRONMENT += EXEEXT='@EXEEXT@' srcdir='$(srcdir)'
check_PROGRAMS += test-ftello
/* Test of fseek() function.
- Copyright (C) 2007, 2008 Free Software Foundation, Inc.
+ Copyright (C) 2007, 2008, 2009 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
} \
while (0)
+#ifndef FUNC_UNGETC_BROKEN
+# define FUNC_UNGETC_BROKEN 0
+#endif
+
int
main (int argc, char **argv)
{
ASSERT (ch == '#');
ASSERT (ungetc (ch, stdin) == ch);
ASSERT (fseek (stdin, 2, SEEK_SET) == 0);
- /* Test that fseek discards random ungetc data. */
ch = fgetc (stdin);
ASSERT (ch == '/');
- ASSERT (ungetc (ch ^ 0xff, stdin) == (ch ^ 0xff));
+ if (2 < argc)
+ {
+ if (FUNC_UNGETC_BROKEN)
+ {
+ fputs ("Skipping test: ungetc cannot handle arbitrary bytes\n",
+ stderr);
+ return 77;
+ }
+ /* Test that fseek discards random ungetc data. */
+ ASSERT (ungetc (ch ^ 0xff, stdin) == (ch ^ 0xff));
+ }
ASSERT (fseek (stdin, 0, SEEK_END) == 0);
ASSERT (fgetc (stdin) == EOF);
/* Test that fseek resets end-of-file marker. */
--- /dev/null
+#!/bin/sh
+
+exec ./test-fseek${EXEEXT} 1 2 < "$srcdir/test-fseek2.sh"
/* Test of fseeko() function.
- Copyright (C) 2007, 2008 Free Software Foundation, Inc.
+ Copyright (C) 2007, 2008, 2009 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
} \
while (0)
+#ifndef FUNC_UNGETC_BROKEN
+# define FUNC_UNGETC_BROKEN 0
+#endif
+
int
main (int argc, char **argv)
{
ASSERT (ch == '#');
ASSERT (ungetc (ch, stdin) == ch);
ASSERT (fseeko (stdin, 2, SEEK_SET) == 0);
- /* Test that fseek discards random ungetc data. */
ch = fgetc (stdin);
ASSERT (ch == '/');
- ASSERT (ungetc (ch ^ 0xff, stdin) == (ch ^ 0xff));
+ if (2 < argc)
+ {
+ if (FUNC_UNGETC_BROKEN)
+ {
+ fputs ("Skipping test: ungetc cannot handle arbitrary bytes\n",
+ stderr);
+ return 77;
+ }
+ /* Test that fseek discards random ungetc data. */
+ ASSERT (ungetc (ch ^ 0xff, stdin) == (ch ^ 0xff));
+ }
ASSERT (fseeko (stdin, 0, SEEK_END) == 0);
ASSERT (fgetc (stdin) == EOF);
/* Test that fseek resets end-of-file marker. */
--- /dev/null
+#!/bin/sh
+
+exec ./test-fseeko${EXEEXT} 1 2 < "$srcdir/test-fseeko2.sh"
/* Test of ftell() function.
- Copyright (C) 2007, 2008 Free Software Foundation, Inc.
+ Copyright (C) 2007, 2008, 2009 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
} \
while (0)
+#ifndef FUNC_UNGETC_BROKEN
+# define FUNC_UNGETC_BROKEN 0
+#endif
+
int
main (int argc, char **argv)
{
ASSERT (ch == '@');
ASSERT (ftell (stdin) == 3);
-#if !defined __hpux /* HP-UX 11 has a known bug here */
- /* Test ftell after ungetc without read. */
- ASSERT (fseek (stdin, 0, SEEK_CUR) == 0);
- ASSERT (ftell (stdin) == 3);
-#endif
-
- ch = ungetc ('~', stdin);
- ASSERT (ch == '~');
- ASSERT (ftell (stdin) == 2);
+ if (2 < argc)
+ {
+ if (FUNC_UNGETC_BROKEN)
+ {
+ fputs ("Skipping test: ungetc cannot handle arbitrary bytes\n",
+ stderr);
+ return 77;
+ }
+ /* Test ftell after ungetc without read. */
+ ASSERT (fseek (stdin, 0, SEEK_CUR) == 0);
+ ASSERT (ftell (stdin) == 3);
+
+ ch = ungetc ('~', stdin);
+ ASSERT (ch == '~');
+ ASSERT (ftell (stdin) == 2);
+ }
/* Test ftell beyond end of file. */
ASSERT (fseek (stdin, 0, SEEK_END) == 0);
--- /dev/null
+#!/bin/sh
+
+exec ./test-ftell${EXEEXT} 1 2 < "$srcdir/test-ftell2.sh"
/* Test of ftello() function.
- Copyright (C) 2007, 2008 Free Software Foundation, Inc.
+ Copyright (C) 2007, 2008, 2009 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
} \
while (0)
+#ifndef FUNC_UNGETC_BROKEN
+# define FUNC_UNGETC_BROKEN 0
+#endif
+
int
main (int argc, char **argv)
{
ASSERT (ftell (stdin) == 3);
ASSERT (ftello (stdin) == 3);
-#if !defined __hpux /* HP-UX 11 has a known bug here */
- /* Test ftell after ungetc without read. */
- ASSERT (fseek (stdin, 0, SEEK_CUR) == 0);
- ASSERT (ftell (stdin) == 3);
- ASSERT (ftello (stdin) == 3);
-#endif
-
- ch = ungetc ('~', stdin);
- ASSERT (ch == '~');
- ASSERT (ftell (stdin) == 2);
- ASSERT (ftello (stdin) == 2);
+ if (2 < argc)
+ {
+ if (FUNC_UNGETC_BROKEN)
+ {
+ fputs ("Skipping test: ungetc cannot handle arbitrary bytes\n",
+ stderr);
+ return 77;
+ }
+ /* Test ftell after ungetc without read. */
+ ASSERT (fseek (stdin, 0, SEEK_CUR) == 0);
+ ASSERT (ftell (stdin) == 3);
+ ASSERT (ftello (stdin) == 3);
+
+ ch = ungetc ('~', stdin);
+ ASSERT (ch == '~');
+ ASSERT (ftell (stdin) == 2);
+ ASSERT (ftello (stdin) == 2);
+ }
/* Test ftell beyond end of file. */
ASSERT (fseek (stdin, 0, SEEK_END) == 0);
--- /dev/null
+#!/bin/sh
+
+exec ./test-ftello${EXEEXT} 1 2 < "$srcdir/test-ftello2.sh"