summary refs log tree commit diff
path: root/stdio-common
diff options
context:
space:
mode:
authorSiddhesh Poyarekar <siddhesh@redhat.com>2012-12-06 11:10:18 +0530
committerSiddhesh Poyarekar <siddhesh@redhat.com>2012-12-06 11:10:18 +0530
commit7728c57488f3d75c6c2865ef36eae262daf8947a (patch)
treecccb0785afa177acd0f458d044daade6f9660009 /stdio-common
parent17aa0516c859f3130f2339cc75c6d89a3f30161c (diff)
downloadglibc-7728c57488f3d75c6c2865ef36eae262daf8947a.tar.gz
glibc-7728c57488f3d75c6c2865ef36eae262daf8947a.tar.xz
glibc-7728c57488f3d75c6c2865ef36eae262daf8947a.zip
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.
Diffstat (limited to 'stdio-common')
-rw-r--r--stdio-common/tst-put-error.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/stdio-common/tst-put-error.c b/stdio-common/tst-put-error.c
index 5209cce173..71c110324a 100644
--- a/stdio-common/tst-put-error.c
+++ b/stdio-common/tst-put-error.c
@@ -34,20 +34,30 @@ do_test (void)
   FILE *fp = fdopen (fd, "w");
   if (fp == NULL)
     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);
   close (fd);
   unlink (tmpl);
+
   int n = fprintf (fp, "hello world\n");
   printf ("fprintf = %d\n", n);
   if (n >= 0)
     error (EXIT_FAILURE, 0, "first fprintf succeeded");
+
   n = fprintf (fp, "hello world\n");
   printf ("fprintf = %d\n", n);
   if (n >= 0)
     error (EXIT_FAILURE, 0, "second fprintf succeeded");
 
   /* Padded printing takes a different code path.  */
-  n = fprintf (fp, "%10000000s", "foo");
+  n = fprintf (fp, "%100s\n", "foo");
   printf ("fprintf = %d\n", n);
   if (n >= 0)
     error (EXIT_FAILURE, 0, "padded fprintf succeeded");