Hash :
07c46bbd
Author :
Date :
2024-05-25T11:44:21
tests: Before declaring a SKIP, test if there were ASSERT failures. * HACKING: Document idiom to use with test_exit_status. * tests/test-c32isalnum.c (main): If there were ASSERT failures, report them instead of declaring SKIP. * tests/test-c32isalpha.c (main): Likewise. * tests/test-c32isblank.c (main): Likewise. * tests/test-c32iscntrl.c (main): Likewise. * tests/test-c32isdigit.c (main): Likewise. * tests/test-c32isgraph.c (main): Likewise. * tests/test-c32islower.c (main): Likewise. * tests/test-c32isprint.c (main): Likewise. * tests/test-c32ispunct.c (main): Likewise. * tests/test-c32isspace.c (main): Likewise. * tests/test-c32isupper.c (main): Likewise. * tests/test-c32isxdigit.c (main): Likewise. * tests/test-c32rtomb.c (main): Likewise. * tests/test-c32rtomb-w32.c (main): Likewise. * tests/test-c32snrtombs.c (main): Likewise. * tests/test-c32srtombs.c (main): Likewise. * tests/test-c32stombs.c (main): Likewise. * tests/test-c32tolower.c (main): Likewise. * tests/test-c32toupper.c (main): Likewise. * tests/test-canonicalize.c (main): Likewise. * tests/test-canonicalize-lgpl.c (main): Likewise. * tests/test-duplocale.c (main): Likewise. * tests/test-fbufmode.c (main): Likewise. * tests/test-fenv-except-state-3.c (main): Likewise. * tests/test-fenv-except-trapping-1.c (main): Likewise. * tests/test-fenv-except-trapping-2.c (main): Likewise. * tests/test-fnmatch.c (main): Likewise. * tests/test-fnmatch-w32.c (main): Likewise. * tests/test-fpurge.c (main): Likewise. * tests/test-freadable.c (main): Likewise. * tests/test-fseek.c (main): Likewise. * tests/test-fseeko.c (main): Likewise. * tests/test-ftell.c (main): Likewise. * tests/test-ftell3.c (main): Likewise. * tests/test-ftello.c (main): Likewise. * tests/test-ftello3.c (main): Likewise. * tests/test-fwritable.c (main): Likewise. * tests/test-fwriting.c (main): Likewise. * tests/test-getrandom.c (main): Likewise. * tests/test-mbrlen-w32.c (main): Likewise. * tests/test-mbrtoc16.c (main): Likewise. * tests/test-mbrtoc16-w32.c (main): Likewise. * tests/test-mbrtoc32.c (main): Likewise. * tests/test-mbrtoc32-w32.c (main): Likewise. * tests/test-mbrtowc-w32.c (main): Likewise. * tests/test-mbsnrtoc32s.c (main): Likewise. * tests/test-mbsrtoc32s.c (main): Likewise. * tests/test-mbstoc32s.c (main): Likewise. * tests/test-nl_langinfo2.c (main): Likewise. * tests/test-nstrftime.c (main): Likewise. * tests/test-passfd.c (main): Likewise. * tests/test-posix_spawn-script.c (main): Likewise. * tests/test-posix_spawnp-script.c (main): Likewise. * tests/test-ptsname.c (main): Likewise. * tests/test-ptsname_r.c (main): Likewise. * tests/test-remove.c (main): Likewise. * tests/test-strfmon_l.c (main): Likewise. * tests/test-utime.c (main): Likewise. * tests/test-wcrtomb-w32.c (main): Likewise. * tests/test-execute-script.c (main): Obey CONTINUE_AFTER_ASSERT better. * tests/test-spawn-pipe-script.c (main): Likewise. * tests/test-linkat.c (main): Use the common idiom.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80
/* Test of ftello() function.
Copyright (C) 2007-2024 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
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
#include <config.h>
/* 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 <stdio.h>
#include <string.h>
#include "macros.h"
#define TESTFILE "t-ftello3.tmp"
int
main (void)
{
FILE *fp;
/* Create a file with some contents. */
fp = fopen (TESTFILE, "w");
if (fp == NULL)
goto skip;
if (fwrite ("foogarsh", 1, 8, fp) < 8)
goto skip;
if (fclose (fp))
goto skip;
/* The file's contents is now "foogarsh". */
/* Try writing after reading to EOF. */
fp = fopen (TESTFILE, "r+");
if (fp == NULL)
goto skip;
if (fseek (fp, -1, SEEK_END))
goto skip;
ASSERT (getc (fp) == 'h');
ASSERT (getc (fp) == EOF);
ASSERT (ftello (fp) == 8);
ASSERT (ftello (fp) == 8);
ASSERT (putc ('!', fp) == '!');
ASSERT (ftello (fp) == 9);
ASSERT (fclose (fp) == 0);
fp = fopen (TESTFILE, "r");
if (fp == NULL)
goto skip;
{
char buf[10];
ASSERT (fread (buf, 1, 10, fp) == 9);
ASSERT (memcmp (buf, "foogarsh!", 9) == 0);
}
ASSERT (fclose (fp) == 0);
/* The file's contents is now "foogarsh!". */
remove (TESTFILE);
return test_exit_status;
skip:
remove (TESTFILE);
if (test_exit_status != EXIT_SUCCESS)
return test_exit_status;
fprintf (stderr, "Skipping test: prerequisite file operations failed.\n");
return 77;
}