aboutsummaryrefslogtreecommitdiff
path: root/stdio-common
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2002-07-25 01:30:57 +0000
committerUlrich Drepper <drepper@redhat.com>2002-07-25 01:30:57 +0000
commit78ce5a3bbb6ce2ef0c43f5bd575708ff2c7715b9 (patch)
tree7d2ef4ff321a1ddd37f9a9a40399a60b5101bb94 /stdio-common
parent66bff4092be47f02a6189f092b9dd1d8c6de2626 (diff)
downloadglibc-78ce5a3bbb6ce2ef0c43f5bd575708ff2c7715b9.tar
glibc-78ce5a3bbb6ce2ef0c43f5bd575708ff2c7715b9.tar.gz
glibc-78ce5a3bbb6ce2ef0c43f5bd575708ff2c7715b9.tar.bz2
glibc-78ce5a3bbb6ce2ef0c43f5bd575708ff2c7715b9.zip
Update.
2002-07-24 Ulrich Drepper <drepper@redhat.com> * libio/fileops.c (_IO_file_seekoff_mmap): Do use fp->_offset to compute current position. * stdio-common/tst-fseek.c (main): Improve error messages. * libio/tst-freopen.c (main): Remove unused variable. * libio/fileops.c (_IO_file_seekoff_mmap): Set fp->_offset after succesful seek call. Simply error checking. 2002-07-25 Jakub Jelinek <jakub@redhat.com> * config.h.in: Use __ASSEMBLER__ test macro not ASSEMBLER. * sysdeps/ia64/fpu/libm_support.h: Likewise.
Diffstat (limited to 'stdio-common')
-rw-r--r--stdio-common/tst-fseek.c156
1 files changed, 73 insertions, 83 deletions
diff --git a/stdio-common/tst-fseek.c b/stdio-common/tst-fseek.c
index 243dcd35a7..461bb5491d 100644
--- a/stdio-common/tst-fseek.c
+++ b/stdio-common/tst-fseek.c
@@ -1,5 +1,5 @@
/* Tests of fseek and fseeko.
- Copyright (C) 2000,01 Free Software Foundation, Inc.
+ Copyright (C) 2000, 2001, 2002 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@redhat.com>, 2000.
@@ -63,7 +63,7 @@ main (void)
if (fwrite (outstr, sizeof (outstr) - 1, 1, fp) != 1)
{
- puts ("write error");
+ printf ("%d: write error\n", __LINE__);
result = 1;
goto out;
}
@@ -71,248 +71,240 @@ main (void)
/* The EOF flag must be reset. */
if (fgetc (fp) != EOF)
{
- puts ("managed to read at end of file");
+ printf ("%d: managed to read at end of file\n", __LINE__);
result = 1;
}
else if (! feof (fp))
{
- puts ("EOF flag not set");
+ printf ("%d: EOF flag not set\n", __LINE__);
result = 1;
}
if (fseek (fp, 0, SEEK_CUR) != 0)
{
- puts ("fseek(fp, 0, SEEK_CUR) failed");
+ printf ("%d: fseek(fp, 0, SEEK_CUR) failed\n", __LINE__);
result = 1;
}
else if (feof (fp))
{
- puts ("fseek() didn't reset EOF flag");
+ printf ("%d: fseek() didn't reset EOF flag\n", __LINE__);
result = 1;
}
/* Do the same for fseeko(). */
-#ifdef USE_IN_LIBIO
if (fgetc (fp) != EOF)
{
- puts ("managed to read at end of file");
+ printf ("%d: managed to read at end of file\n", __LINE__);
result = 1;
}
else if (! feof (fp))
{
- puts ("EOF flag not set");
+ printf ("%d: EOF flag not set\n", __LINE__);
result = 1;
}
if (fseeko (fp, 0, SEEK_CUR) != 0)
{
- puts ("fseek(fp, 0, SEEK_CUR) failed");
+ printf ("%d: fseek(fp, 0, SEEK_CUR) failed\n", __LINE__);
result = 1;
}
else if (feof (fp))
{
- puts ("fseek() didn't reset EOF flag");
+ printf ("%d: fseek() didn't reset EOF flag\n", __LINE__);
result = 1;
}
-#endif
/* Go back to the beginning of the file: absolute. */
if (fseek (fp, 0, SEEK_SET) != 0)
{
- puts ("fseek(fp, 0, SEEK_SET) failed");
+ printf ("%d: fseek(fp, 0, SEEK_SET) failed\n", __LINE__);
result = 1;
}
else if (fflush (fp) != 0)
{
- puts ("fflush() failed");
+ printf ("%d: fflush() failed\n", __LINE__);
result = 1;
}
else if (lseek (fd, 0, SEEK_CUR) != 0)
{
- puts ("lseek() returned different position");
+ printf ("%d: lseek() returned different position\n", __LINE__);
result = 1;
}
else if (fread (buf, sizeof (outstr) - 1, 1, fp) != 1)
{
- puts ("fread() failed");
+ printf ("%d: fread() failed\n", __LINE__);
result = 1;
}
else if (memcmp (buf, outstr, sizeof (outstr) - 1) != 0)
{
- puts ("content after fseek(,,SEEK_SET) wrong");
+ printf ("%d: content after fseek(,,SEEK_SET) wrong\n", __LINE__);
result = 1;
}
-#ifdef USE_IN_LIBIO
/* Now with fseeko. */
if (fseeko (fp, 0, SEEK_SET) != 0)
{
- puts ("fseeko(fp, 0, SEEK_SET) failed");
+ printf ("%d: fseeko(fp, 0, SEEK_SET) failed\n", __LINE__);
result = 1;
}
else if (fflush (fp) != 0)
{
- puts ("fflush() failed");
+ printf ("%d: fflush() failed\n", __LINE__);
result = 1;
}
else if (lseek (fd, 0, SEEK_CUR) != 0)
{
- puts ("lseek() returned different position");
+ printf ("%d: lseek() returned different position\n", __LINE__);
result = 1;
}
else if (fread (buf, sizeof (outstr) - 1, 1, fp) != 1)
{
- puts ("fread() failed");
+ printf ("%d: fread() failed\n", __LINE__);
result = 1;
}
else if (memcmp (buf, outstr, sizeof (outstr) - 1) != 0)
{
- puts ("content after fseeko(,,SEEK_SET) wrong");
+ printf ("%d: content after fseeko(,,SEEK_SET) wrong\n", __LINE__);
result = 1;
}
-#endif
/* Go back to the beginning of the file: relative. */
if (fseek (fp, -(sizeof (outstr) - 1), SEEK_CUR) != 0)
{
- puts ("fseek(fp, 0, SEEK_SET) failed");
+ printf ("%d: fseek(fp, 0, SEEK_SET) failed\n", __LINE__);
result = 1;
}
else if (fflush (fp) != 0)
{
- puts ("fflush() failed");
+ printf ("%d: fflush() failed\n", __LINE__);
result = 1;
}
else if (lseek (fd, 0, SEEK_CUR) != 0)
{
- puts ("lseek() returned different position");
+ printf ("%d: lseek() returned different position\n", __LINE__);
result = 1;
}
else if (fread (buf, sizeof (outstr) - 1, 1, fp) != 1)
{
- puts ("fread() failed");
+ printf ("%d: fread() failed\n", __LINE__);
result = 1;
}
else if (memcmp (buf, outstr, sizeof (outstr) - 1) != 0)
{
- puts ("content after fseek(,,SEEK_SET) wrong");
+ printf ("%d: content after fseek(,,SEEK_SET) wrong\n", __LINE__);
result = 1;
}
-#ifdef USE_IN_LIBIO
/* Now with fseeko. */
if (fseeko (fp, -(sizeof (outstr) - 1), SEEK_CUR) != 0)
{
- puts ("fseeko(fp, 0, SEEK_SET) failed");
+ printf ("%d: fseeko(fp, 0, SEEK_SET) failed\n", __LINE__);
result = 1;
}
else if (fflush (fp) != 0)
{
- puts ("fflush() failed");
+ printf ("%d: fflush() failed\n", __LINE__);
result = 1;
}
else if (lseek (fd, 0, SEEK_CUR) != 0)
{
- puts ("lseek() returned different position");
+ printf ("%d: lseek() returned different position\n", __LINE__);
result = 1;
}
else if (fread (buf, sizeof (outstr) - 1, 1, fp) != 1)
{
- puts ("fread() failed");
+ printf ("%d: fread() failed\n", __LINE__);
result = 1;
}
else if (memcmp (buf, outstr, sizeof (outstr) - 1) != 0)
{
- puts ("content after fseeko(,,SEEK_SET) wrong");
+ printf ("%d: content after fseeko(,,SEEK_SET) wrong\n", __LINE__);
result = 1;
}
-#endif
/* Go back to the beginning of the file: from the end. */
if (fseek (fp, -(sizeof (outstr) - 1), SEEK_END) != 0)
{
- puts ("fseek(fp, 0, SEEK_SET) failed");
+ printf ("%d: fseek(fp, 0, SEEK_SET) failed\n", __LINE__);
result = 1;
}
else if (fflush (fp) != 0)
{
- puts ("fflush() failed");
+ printf ("%d: fflush() failed\n", __LINE__);
result = 1;
}
else if (lseek (fd, 0, SEEK_CUR) != 0)
{
- puts ("lseek() returned different position");
+ printf ("%d: lseek() returned different position\n", __LINE__);
result = 1;
}
else if (fread (buf, sizeof (outstr) - 1, 1, fp) != 1)
{
- puts ("fread() failed");
+ printf ("%d: fread() failed\n", __LINE__);
result = 1;
}
else if (memcmp (buf, outstr, sizeof (outstr) - 1) != 0)
{
- puts ("content after fseek(,,SEEK_SET) wrong");
+ printf ("%d: content after fseek(,,SEEK_SET) wrong\n", __LINE__);
result = 1;
}
-#ifdef USE_IN_LIBIO
/* Now with fseeko. */
if (fseeko (fp, -(sizeof (outstr) - 1), SEEK_END) != 0)
{
- puts ("fseeko(fp, 0, SEEK_SET) failed");
+ printf ("%d: fseeko(fp, 0, SEEK_SET) failed\n", __LINE__);
result = 1;
}
else if (fflush (fp) != 0)
{
- puts ("fflush() failed");
+ printf ("%d: fflush() failed\n", __LINE__);
result = 1;
}
else if (lseek (fd, 0, SEEK_CUR) != 0)
{
- puts ("lseek() returned different position");
+ printf ("%d: lseek() returned different position\n", __LINE__);
result = 1;
}
else if (fread (buf, sizeof (outstr) - 1, 1, fp) != 1)
{
- puts ("fread() failed");
+ printf ("%d: fread() failed\n", __LINE__);
result = 1;
}
else if (memcmp (buf, outstr, sizeof (outstr) - 1) != 0)
{
- puts ("content after fseeko(,,SEEK_SET) wrong");
+ printf ("%d: content after fseeko(,,SEEK_SET) wrong\n", __LINE__);
result = 1;
}
-#endif
if (fwrite (outstr, sizeof (outstr) - 1, 1, fp) != 1)
{
- puts ("write error 2");
+ printf ("%d: write error 2\n", __LINE__);
result = 1;
goto out;
}
if (fwrite (outstr, sizeof (outstr) - 1, 1, fp) != 1)
{
- puts ("write error 3");
+ printf ("%d: write error 3\n", __LINE__);
result = 1;
goto out;
}
if (fwrite (outstr, sizeof (outstr) - 1, 1, fp) != 1)
{
- puts ("write error 4");
+ printf ("%d: write error 4\n", __LINE__);
result = 1;
goto out;
}
if (fwrite (outstr, sizeof (outstr) - 1, 1, fp) != 1)
{
- puts ("write error 5");
+ printf ("%d: write error 5\n", __LINE__);
result = 1;
goto out;
}
if (fputc ('1', fp) == EOF || fputc ('2', fp) == EOF)
{
- puts ("cannot add characters at the end");
+ printf ("%d: cannot add characters at the end\n", __LINE__);
result = 1;
goto out;
}
@@ -320,7 +312,7 @@ main (void)
/* Check the access time. */
if (fstat64 (fd, &st1) < 0)
{
- puts ("fstat64() before fseeko() failed\n");
+ printf ("%d: fstat64() before fseeko() failed\n\n", __LINE__);
result = 1;
}
else
@@ -329,7 +321,7 @@ main (void)
if (fseek (fp, -(2 + 2 * (sizeof (outstr) - 1)), SEEK_CUR) != 0)
{
- puts ("fseek() after write characters failed");
+ printf ("%d: fseek() after write characters failed\n", __LINE__);
result = 1;
goto out;
}
@@ -343,27 +335,27 @@ main (void)
if (fstat64 (fd, &st2) < 0)
{
- puts ("fstat64() after fseeko() failed\n");
+ printf ("%d: fstat64() after fseeko() failed\n\n", __LINE__);
result = 1;
}
if (st1.st_ctime >= t)
{
- puts ("st_ctime not updated");
+ printf ("%d: st_ctime not updated\n", __LINE__);
result = 1;
}
if (st1.st_mtime >= t)
{
- puts ("st_mtime not updated");
+ printf ("%d: st_mtime not updated\n", __LINE__);
result = 1;
}
if (st1.st_ctime >= st2.st_ctime)
{
- puts ("st_ctime not changed");
+ printf ("%d: st_ctime not changed\n", __LINE__);
result = 1;
}
if (st1.st_mtime >= st2.st_mtime)
{
- puts ("st_mtime not changed");
+ printf ("%d: st_mtime not changed\n", __LINE__);
result = 1;
}
}
@@ -372,7 +364,7 @@ main (void)
if (fread (buf, 1, 2 + 2 * (sizeof (outstr) - 1), fp)
!= 2 + 2 * (sizeof (outstr) - 1))
{
- puts ("reading 2 records plus bits failed");
+ printf ("%d: reading 2 records plus bits failed\n", __LINE__);
result = 1;
}
else if (memcmp (buf, outstr, sizeof (outstr) - 1) != 0
@@ -381,23 +373,23 @@ main (void)
|| buf[2 * (sizeof (outstr) - 1)] != '1'
|| buf[2 * (sizeof (outstr) - 1) + 1] != '2')
{
- puts ("reading records failed");
+ printf ("%d: reading records failed\n", __LINE__);
result = 1;
}
else if (ungetc ('9', fp) == EOF)
{
- puts ("ungetc() failed");
+ printf ("%d: ungetc() failed\n", __LINE__);
result = 1;
}
else if (fseek (fp, -(2 + 2 * (sizeof (outstr) - 1)), SEEK_END) != 0)
{
- puts ("fseek after ungetc failed");
+ printf ("%d: fseek after ungetc failed\n", __LINE__);
result = 1;
}
else if (fread (buf, 1, 2 + 2 * (sizeof (outstr) - 1), fp)
!= 2 + 2 * (sizeof (outstr) - 1))
{
- puts ("reading 2 records plus bits failed");
+ printf ("%d: reading 2 records plus bits failed\n", __LINE__);
result = 1;
}
else if (memcmp (buf, outstr, sizeof (outstr) - 1) != 0
@@ -405,82 +397,80 @@ main (void)
sizeof (outstr) - 1) != 0
|| buf[2 * (sizeof (outstr) - 1)] != '1')
{
- puts ("reading records for the second time failed");
+ printf ("%d: reading records for the second time failed\n", __LINE__);
result = 1;
}
else if (buf[2 * (sizeof (outstr) - 1) + 1] == '9')
{
- puts ("unget character not ignored");
+ printf ("%d: unget character not ignored\n", __LINE__);
result = 1;
}
else if (buf[2 * (sizeof (outstr) - 1) + 1] != '2')
{
- puts ("unget somehow changed character");
+ printf ("%d: unget somehow changed character\n", __LINE__);
result = 1;
}
fclose (fp);
-#ifdef USE_IN_LIBIO
fp = fopen (fname, "r");
if (fp == NULL)
{
- puts ("fopen() failed\n");
+ printf ("%d: fopen() failed\n\n", __LINE__);
result = 1;
}
else if (fstat64 (fileno (fp), &st1) < 0)
{
- puts ("fstat64() before fseeko() failed\n");
+ printf ("%d: fstat64() before fseeko() failed\n\n", __LINE__);
result = 1;
}
else if (fseeko (fp, 0, SEEK_END) != 0)
{
- puts ("fseeko(fp, 0, SEEK_END) failed");
+ printf ("%d: fseeko(fp, 0, SEEK_END) failed\n", __LINE__);
result = 1;
}
else if (ftello (fp) != st1.st_size)
{
- printf ("fstat64 st_size %zd ftello %zd\n", st1.st_size,
- ftello (fp));
+ printf ("%d: fstat64 st_size %zd ftello %zd\n", __LINE__,
+ (size_t) st1.st_size, (size_t) ftello (fp));
result = 1;
}
else
- puts ("SEEK_END works");
+ printf ("%d: SEEK_END works\n", __LINE__);
if (fp != NULL)
fclose (fp);
fp = fopen (fname, "r");
if (fp == NULL)
{
- puts ("fopen() failed\n");
+ printf ("%d: fopen() failed\n\n", __LINE__);
result = 1;
}
else if (fstat64 (fileno (fp), &st1) < 0)
{
- puts ("fstat64() before fgetc() failed\n");
+ printf ("%d: fstat64() before fgetc() failed\n\n", __LINE__);
result = 1;
}
else if (fgetc (fp) == EOF)
{
- puts ("fgetc() before fseeko() failed\n");
+ printf ("%d: fgetc() before fseeko() failed\n\n", __LINE__);
result = 1;
}
else if (fseeko (fp, 0, SEEK_END) != 0)
{
- puts ("fseeko(fp, 0, SEEK_END) failed");
+ printf ("%d: fseeko(fp, 0, SEEK_END) failed\n", __LINE__);
result = 1;
}
else if (ftello (fp) != st1.st_size)
{
- printf ("fstat64 st_size %zd ftello %zd\n", st1.st_size,
- ftello (fp));
+ printf ("%d: fstat64 st_size %zd ftello %zd\n", __LINE__,
+ (size_t) st1.st_size, (size_t) ftello (fp));
result = 1;
}
else
- puts ("SEEK_END works");
+ printf ("%d: SEEK_END works\n", __LINE__);
if (fp != NULL)
fclose (fp);
-#endif
out:
unlink (fname);