X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;f=tests%2Ftest-ftell.c;h=54ede0515c3f545b27e97bfb636d0b46978684ac;hb=2f681c52f62c1bb9c9dd3fe5cd7a32ec384c34c7;hp=092be192d61b33edc15b953a621c16ce2f658478;hpb=e135441c120410c222891af756b35e079ba579b1;p=gnulib.git diff --git a/tests/test-ftell.c b/tests/test-ftell.c index 092be192d..54ede0515 100644 --- a/tests/test-ftell.c +++ b/tests/test-ftell.c @@ -1,5 +1,5 @@ /* Test of ftell() function. - Copyright (C) 2007, 2008 Free Software Foundation, Inc. + Copyright (C) 2007-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 @@ -18,22 +18,20 @@ #include +/* None of the files accessed by this test are large, so disable the + fseek link warning if we are not using the gnulib fseek module. */ +#define _GL_NO_LARGE_FILES #include -#include + +#include "signature.h" +SIGNATURE_CHECK (ftell, long, (FILE *)); #include "binary-io.h" +#include "macros.h" -#define ASSERT(expr) \ - do \ - { \ - if (!(expr)) \ - { \ - fprintf (stderr, "%s:%d: assertion failed\n", __FILE__, __LINE__); \ - fflush (stderr); \ - abort (); \ - } \ - } \ - while (0) +#ifndef FUNC_UNGETC_BROKEN +# define FUNC_UNGETC_BROKEN 0 +#endif int main (int argc, char **argv) @@ -80,21 +78,30 @@ 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); + } +#if !defined __MINT__ /* FreeMiNT has problems seeking past end of file */ /* Test ftell beyond end of file. */ ASSERT (fseek (stdin, 0, SEEK_END) == 0); ch = ftell (stdin); ASSERT (fseek (stdin, 10, SEEK_END) == 0); ASSERT (ftell (stdin) == ch + 10); +#endif return 0; }