(do_ypcall): Don't free dom_binding twice.
[glibc/history.git] / stdio-common / test-fwrite.c
blobce541699310f23e7da78f420f7380676388076d8
1 #include <stdio.h>
2 #include <string.h>
4 int
5 main (int argc, char *argv[])
7 FILE *f = tmpfile ();
8 char obuf[99999], ibuf[sizeof obuf];
9 char *line;
10 size_t linesz;
12 if (! f)
14 perror ("tmpfile");
15 return 1;
18 if (fputs ("line\n", f) == EOF)
20 perror ("fputs");
21 return 1;
24 memset (obuf, 'z', sizeof obuf);
25 memset (ibuf, 'y', sizeof ibuf);
27 if (fwrite (obuf, sizeof obuf, 1, f) != 1)
29 perror ("fwrite");
30 return 1;
33 rewind (f);
35 line = NULL;
36 linesz = 0;
37 if (getline (&line, &linesz, f) != 5)
39 perror ("getline");
40 return 1;
42 if (strcmp (line, "line\n"))
44 puts ("Lines differ. Test FAILED!");
45 return 1;
48 if (fread (ibuf, sizeof ibuf, 1, f) != 1)
50 perror ("fread");
51 return 1;
54 if (memcmp (ibuf, obuf, sizeof ibuf))
56 puts ("Buffers differ. Test FAILED!");
57 return 1;
60 asprintf (&line, "\
61 GDB is free software and you are welcome to distribute copies of it\n\
62 under certain conditions; type \"show copying\" to see the conditions.\n\
63 There is absolutely no warranty for GDB; type \"show warranty\" for details.\n\
64 ");
66 puts ("Test succeeded.");
67 return 0;