summaryrefslogtreecommitdiff
path: root/tests/test-fseeko.c
diff options
context:
space:
mode:
authorEric Blake <ebb9@byu.net>2009-02-25 07:42:31 -0700
committerEric Blake <ebb9@byu.net>2009-02-25 13:47:14 -0700
commit5812ea3e47b3db87cc42c99b1d3cd8e44c8c0af3 (patch)
tree967794499721d4dcae3060650073f3103d4ea9b4 /tests/test-fseeko.c
parent1e3dd41e4d5de03c45c850b2a6c2d989cb272d36 (diff)
downloadgnulib-5812ea3e47b3db87cc42c99b1d3cd8e44c8c0af3.tar.gz
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.
Diffstat (limited to 'tests/test-fseeko.c')
-rw-r--r--tests/test-fseeko.c19
1 files changed, 16 insertions, 3 deletions
diff --git a/tests/test-fseeko.c b/tests/test-fseeko.c
index 3a1383b3d3..9c284da500 100644
--- a/tests/test-fseeko.c
+++ b/tests/test-fseeko.c
@@ -1,5 +1,5 @@
/* 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
@@ -33,6 +33,10 @@
} \
while (0)
+#ifndef FUNC_UNGETC_BROKEN
+# define FUNC_UNGETC_BROKEN 0
+#endif
+
int
main (int argc, char **argv)
{
@@ -50,10 +54,19 @@ 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. */