support: Add support_set_vma_name
[glibc.git] / stdio-common / bug5.c
blobdfa19aed551d8f08b99ac123bc3c5129ec238483
1 /* If stdio is working correctly, after this is run infile and outfile
2 will have the same contents. If the bug (found in GNU C library 0.3)
3 exhibits itself, outfile will be missing the 2nd through 1023rd
4 characters. */
6 #include <stdio.h>
7 #include <stdlib.h>
8 #include <unistd.h>
10 #include <support/support.h>
12 static char buf[8192];
14 int
15 main (void)
17 FILE *in;
18 FILE *out;
19 static char inname[] = OBJPFX "bug5test.in";
20 static char outname[] = OBJPFX "bug5test.out";
21 char *printbuf;
22 size_t i;
23 int result;
25 /* Create a test file. */
26 in = fopen (inname, "w+");
27 if (in == NULL)
29 perror (inname);
30 return 1;
32 for (i = 0; i < 1000; ++i)
33 fprintf (in, "%Zu\n", i);
35 out = fopen (outname, "w");
36 if (out == NULL)
38 perror (outname);
39 return 1;
41 if (fseek (in, 0L, SEEK_SET) != 0)
42 abort ();
43 putc (getc (in), out);
44 i = fread (buf, 1, sizeof (buf), in);
45 if (i == 0)
47 perror ("fread");
48 return 1;
50 if (fwrite (buf, 1, i, out) != i)
52 perror ("fwrite");
53 return 1;
55 fclose (in);
56 fclose (out);
58 puts ("There should be no further output from this test.");
59 fflush (stdout);
61 /* We must remove this entry to assure the `cmp' binary does not use
62 the perhaps incompatible new shared libraries. */
63 unsetenv ("LD_LIBRARY_PATH");
65 printbuf = xasprintf ("cmp %s %s", inname, outname);
66 result = system (printbuf);
67 remove (inname);
68 remove (outname);
70 exit ((result != 0));