1 /* Derived from the test case in
2 http://sourceware.org/bugzilla/show_bug.cgi?id=1078. */
12 static void prepare (void);
13 #define PREPARE(argc, argv) prepare ()
15 static int do_test (void);
16 #define TEST_FUNCTION do_test ()
18 #include "../test-skeleton.c"
24 fd
= create_temp_file ("tst-fwrite.", NULL
);
27 puts ("cannot create temporary file");
36 FILE* f
= fdopen (fd
, "w+");
38 puts ("cannot create stream");
41 puts ("Opened temp file");
43 if (fwrite ("a", 1, 1, f
) != 1)
45 puts ("1st fwrite failed");
48 puts ("Wrote a byte");
52 size_t i
= fread (buffer
, 1, sizeof (buffer
), f
);
53 printf ("Read %zu bytes\n", i
);
55 for (i
= 0; i
< OUT_SIZE
; i
++)
57 if (fwrite ("n", 1, 1, f
) != 1)
59 printf ("fwrite in loop round %zu failed\n", i
);
63 if ((i
+ 1) % 1000 == 0)
64 printf ("wrote %zu bytes ...\n", i
+ 1);
67 printf ("Wrote %i bytes [done]\n", OUT_SIZE
);