[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: no new modules 'freading', 'fwriting'
From: |
Bruno Haible |
Subject: |
Re: no new modules 'freading', 'fwriting' |
Date: |
Sun, 29 Apr 2007 04:08:14 +0200 |
User-agent: |
KMail/1.5.4 |
Eric Blake wrote:
> > I got it the tests to work on both cygwin and
> > mingw as follows, so I think it is worth checking it in as a starting
> > point.
Now that fflush works, I'm adding back the fflush calls to the 'freading' and
'fwriting' tests.
2007-04-28 Bruno Haible <address@hidden>
* tests/test-fwriting.c (main): Also test the interaction between
fflush and fwriting.
* modules/fwriting-tests (Depends-on): Add fflush.
* tests/test-freading.c (main): Also test the interaction between
fflush and freading.
* modules/freading-tests (Depends-on): Add fflush.
*** tests/test-freading.c 26 Apr 2007 13:16:50 -0000 1.1
--- tests/test-freading.c 29 Apr 2007 02:04:38 -0000
***************
*** 57,62 ****
--- 57,67 ----
if (fgetc (fp) != 'b')
goto skip;
ASSERT (freading (fp));
+ fflush (fp);
+ ASSERT (freading (fp));
+ if (fgetc (fp) != 'a')
+ goto skip;
+ ASSERT (freading (fp));
if (fseek (fp, 0, SEEK_END))
goto skip;
ASSERT (freading (fp));
***************
*** 77,88 ****
ASSERT (freading (fp));
if (fseek (fp, 2, SEEK_CUR))
goto skip;
! /* freading (fp)) is undefined here, but fwriting is false. */
if (fgetc (fp) != 'b')
goto skip;
ASSERT (freading (fp));
if (fseek (fp, 0, SEEK_CUR) != 0)
goto skip;
if (fputc ('z', fp) != 'z')
goto skip;
ASSERT (!freading (fp));
--- 82,133 ----
ASSERT (freading (fp));
if (fseek (fp, 2, SEEK_CUR))
goto skip;
! /* freading (fp) is undefined here, but fwriting (fp) is false. */
if (fgetc (fp) != 'b')
goto skip;
ASSERT (freading (fp));
+ /* This fseek call is necessary when switching from reading to writing.
+ See the description of fopen(), ISO C 99 7.19.5.3.(6). */
+ if (fseek (fp, 0, SEEK_CUR) != 0)
+ goto skip;
+ /* freading (fp) is undefined here, but fwriting (fp) is false. */
+ if (fputc ('z', fp) != 'z')
+ goto skip;
+ ASSERT (!freading (fp));
+ if (fseek (fp, 0, SEEK_END))
+ goto skip;
+ ASSERT (!freading (fp));
+ if (fclose (fp))
+ goto skip;
+
+ /* Open it in read-write mode. POSIX requires a reposition (fseek,
+ fsetpos, rewind) or EOF when transitioning from read to write;
+ freading is only deterministic after input or output, but this
+ test case should be portable even on open, after reposition, and
+ at EOF. */
+ fp = fopen (TESTFILE, "r+");
+ if (fp == NULL)
+ goto skip;
+ ASSERT (!freading (fp));
+ if (fgetc (fp) != 'f')
+ goto skip;
+ ASSERT (freading (fp));
+ if (fseek (fp, 2, SEEK_CUR))
+ goto skip;
+ /* freading (fp) is undefined here, but fwriting (fp) is false. */
+ if (fgetc (fp) != 'b')
+ goto skip;
+ ASSERT (freading (fp));
+ fflush (fp);
+ /* freading (fp) is undefined here, but fwriting (fp) is false. */
+ if (fgetc (fp) != 'a')
+ goto skip;
+ ASSERT (freading (fp));
+ /* This fseek call is necessary when switching from reading to writing.
+ See the description of fopen(), ISO C 99 7.19.5.3.(6). */
if (fseek (fp, 0, SEEK_CUR) != 0)
goto skip;
+ /* freading (fp) is undefined here, but fwriting (fp) is false. */
if (fputc ('z', fp) != 'z')
goto skip;
ASSERT (!freading (fp));
*** tests/test-fwriting.c 26 Apr 2007 13:16:50 -0000 1.1
--- tests/test-fwriting.c 29 Apr 2007 02:04:38 -0000
***************
*** 57,62 ****
--- 57,67 ----
if (fgetc (fp) != 'b')
goto skip;
ASSERT (!fwriting (fp));
+ fflush (fp);
+ ASSERT (!fwriting (fp));
+ if (fgetc (fp) != 'a')
+ goto skip;
+ ASSERT (!fwriting (fp));
if (fseek (fp, 0, SEEK_END))
goto skip;
ASSERT (!fwriting (fp));
***************
*** 81,94 ****
if (fgetc (fp) != 'b')
goto skip;
ASSERT (!fwriting (fp));
if (fseek (fp, 0, SEEK_CUR) != 0)
goto skip;
if (fputc ('z', fp) != 'z')
goto skip;
ASSERT (fwriting (fp));
if (fseek (fp, 0, SEEK_END))
goto skip;
! /* fwriting (fp) is undefined here, but freading is false. */
if (fclose (fp))
goto skip;
--- 86,139 ----
if (fgetc (fp) != 'b')
goto skip;
ASSERT (!fwriting (fp));
+ /* This fseek call is necessary when switching from reading to writing.
+ See the description of fopen(), ISO C 99 7.19.5.3.(6). */
+ if (fseek (fp, 0, SEEK_CUR) != 0)
+ goto skip;
+ ASSERT (!fwriting (fp));
+ if (fputc ('z', fp) != 'z')
+ goto skip;
+ ASSERT (fwriting (fp));
+ if (fseek (fp, 0, SEEK_END))
+ goto skip;
+ /* fwriting (fp) is undefined here, but freading (fp) is false. */
+ if (fclose (fp))
+ goto skip;
+
+ /* Open it in read-write mode. POSIX requires a reposition (fseek,
+ fsetpos, rewind) or fflush when transitioning from write to read,
+ fwriting is only deterministic after input or output, but this
+ test case should be portable even on open, after reposition, and
+ after fflush. */
+ fp = fopen (TESTFILE, "r+");
+ if (fp == NULL)
+ goto skip;
+ ASSERT (!fwriting (fp));
+ if (fgetc (fp) != 'f')
+ goto skip;
+ ASSERT (!fwriting (fp));
+ if (fseek (fp, 2, SEEK_CUR))
+ goto skip;
+ ASSERT (!fwriting (fp));
+ if (fgetc (fp) != 'b')
+ goto skip;
+ ASSERT (!fwriting (fp));
+ fflush (fp);
+ ASSERT (!fwriting (fp));
+ if (fgetc (fp) != 'a')
+ goto skip;
+ ASSERT (!fwriting (fp));
+ /* This fseek call is necessary when switching from reading to writing.
+ See the description of fopen(), ISO C 99 7.19.5.3.(6). */
if (fseek (fp, 0, SEEK_CUR) != 0)
goto skip;
+ ASSERT (!fwriting (fp));
if (fputc ('z', fp) != 'z')
goto skip;
ASSERT (fwriting (fp));
if (fseek (fp, 0, SEEK_END))
goto skip;
! /* fwriting (fp) is undefined here, but freading (fp) is false. */
if (fclose (fp))
goto skip;
*** modules/freading-tests 26 Apr 2007 13:16:50 -0000 1.1
--- modules/freading-tests 29 Apr 2007 02:04:38 -0000
***************
*** 2,7 ****
--- 2,8 ----
tests/test-freading.c
Depends-on:
+ fflush
configure.ac:
*** modules/fwriting-tests 26 Apr 2007 13:16:50 -0000 1.1
--- modules/fwriting-tests 29 Apr 2007 02:04:38 -0000
***************
*** 2,7 ****
--- 2,8 ----
tests/test-fwriting.c
Depends-on:
+ fflush
configure.ac:
- no new modules 'freading', 'fwriting', Bruno Haible, 2007/04/13
- Re: no new modules 'freading', 'fwriting', Eric Blake, 2007/04/25
- Re: no new modules 'freading', 'fwriting', Eric Blake, 2007/04/26
- Re: no new modules 'freading', 'fwriting',
Bruno Haible <=
- Re: no new modules 'freading', 'fwriting', Bruno Haible, 2007/04/29
- Re: no new modules 'freading', 'fwriting', Bruno Haible, 2007/04/29
- Re: no new modules 'freading', 'fwriting', Bruno Haible, 2007/04/29