* tests/test-fseek.c (main): Also test eof handling.
* tests/test-fseeko.c (main): Likewise.
Reported by Larry Jones.
Signed-off-by: Eric Blake <ebb9@byu.net>
+2007-12-13 Eric Blake <ebb9@byu.net>
+
+ Beef up fseek tests.
+ * tests/test-fseek.c (main): Also test eof handling.
+ * tests/test-fseeko.c (main): Likewise.
+ Reported by Larry Jones.
+
2007-12-13 Larry Jones <lawrence.jones@siemens.com> (tiny change)
Fix fseeko on BSD-based platforms.
{
/* Assume stdin is seekable iff argc > 1. */
int expected = argc > 1 ? 0 : -1;
- return fseek (stdin, 0, SEEK_CUR) != expected;
+ if (fseek (stdin, 0, SEEK_CUR) != expected)
+ return 1;
+ if (argc > 1)
+ {
+ /* Test that fseek resets end-of-file marker. */
+ if (fseek (stdin, 0, SEEK_END))
+ return 1;
+ if (fgetc (stdin) != EOF)
+ return 1;
+ if (!feof (stdin))
+ return 1;
+ if (fseek (stdin, 0, SEEK_END))
+ return 1;
+ if (feof (stdin))
+ return 1;
+ }
+ return 0;
}
/* Exit with success only if fseek/fseeko agree. */
int r1 = fseeko (stdin, (off_t)0, SEEK_CUR);
int r2 = fseek (stdin, (long)0, SEEK_CUR);
- return ! (r1 == r2 && r1 == expected);
+ if (r1 != r2 || r1 != expected)
+ return 1;
+ if (argc > 1)
+ {
+ /* Test that fseek resets end-of-file marker. */
+ if (fseeko (stdin, (off_t) 0, SEEK_END))
+ return 1;
+ if (fgetc (stdin) != EOF)
+ return 1;
+ if (!feof (stdin))
+ return 1;
+ if (fseeko (stdin, (off_t) 0, SEEK_END))
+ return 1;
+ if (feof (stdin))
+ return 1;
+ }
+ return 0;
}