mirror of
https://sourceware.org/git/glibc.git
synced 2025-07-29 11:41:21 +03:00
Add newline to last test in stdio-common/tst-put-error.c
The newline ensures that the buffer is flushed and the test executes as expected.
This commit is contained in:
@ -1,3 +1,8 @@
|
|||||||
|
2012-12-06 Siddhesh Poyarekar <siddhesh@redhat.com>
|
||||||
|
|
||||||
|
* stdio-common/tst-put-error.c (do_test): Add newline to the
|
||||||
|
padded test to ensure flush.
|
||||||
|
|
||||||
2012-12-05 Jeff Law <law@redhat.com>
|
2012-12-05 Jeff Law <law@redhat.com>
|
||||||
|
|
||||||
* sunrpc/etc.rpc (fedfs_admin): Add entry.
|
* sunrpc/etc.rpc (fedfs_admin): Add entry.
|
||||||
|
@ -34,20 +34,30 @@ do_test (void)
|
|||||||
FILE *fp = fdopen (fd, "w");
|
FILE *fp = fdopen (fd, "w");
|
||||||
if (fp == NULL)
|
if (fp == NULL)
|
||||||
error (EXIT_FAILURE, errno, "fdopen");
|
error (EXIT_FAILURE, errno, "fdopen");
|
||||||
|
|
||||||
|
/* All of the tests below verify that flushing buffers result in failure of
|
||||||
|
the fprintf calls. We ensure that the buffer is flushed at the end of
|
||||||
|
each fprintf call by doing two things - setting the file pointer to
|
||||||
|
line-buffered so that it is flushed whenever it encounters a newline and
|
||||||
|
then ensuring that there is a newline in each of the format strings we
|
||||||
|
pass to fprintf. */
|
||||||
|
|
||||||
setlinebuf (fp);
|
setlinebuf (fp);
|
||||||
close (fd);
|
close (fd);
|
||||||
unlink (tmpl);
|
unlink (tmpl);
|
||||||
|
|
||||||
int n = fprintf (fp, "hello world\n");
|
int n = fprintf (fp, "hello world\n");
|
||||||
printf ("fprintf = %d\n", n);
|
printf ("fprintf = %d\n", n);
|
||||||
if (n >= 0)
|
if (n >= 0)
|
||||||
error (EXIT_FAILURE, 0, "first fprintf succeeded");
|
error (EXIT_FAILURE, 0, "first fprintf succeeded");
|
||||||
|
|
||||||
n = fprintf (fp, "hello world\n");
|
n = fprintf (fp, "hello world\n");
|
||||||
printf ("fprintf = %d\n", n);
|
printf ("fprintf = %d\n", n);
|
||||||
if (n >= 0)
|
if (n >= 0)
|
||||||
error (EXIT_FAILURE, 0, "second fprintf succeeded");
|
error (EXIT_FAILURE, 0, "second fprintf succeeded");
|
||||||
|
|
||||||
/* Padded printing takes a different code path. */
|
/* Padded printing takes a different code path. */
|
||||||
n = fprintf (fp, "%10000000s", "foo");
|
n = fprintf (fp, "%100s\n", "foo");
|
||||||
printf ("fprintf = %d\n", n);
|
printf ("fprintf = %d\n", n);
|
||||||
if (n >= 0)
|
if (n >= 0)
|
||||||
error (EXIT_FAILURE, 0, "padded fprintf succeeded");
|
error (EXIT_FAILURE, 0, "padded fprintf succeeded");
|
||||||
|
Reference in New Issue
Block a user