source: trunk/src/libctests/glibc/stdio-common/test-fwrite.c@ 2196

Last change on this file since 2196 was 2089, checked in by bird, 20 years ago

testcase adjustments.

  • Property cvs2svn:cvs-rev set to 1.2
  • Property svn:eol-style set to native
  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 1.4 KB
Line 
1#include <stdio.h>
2#include <string.h>
3
4int
5main (int argc, char *argv[])
6{
7 FILE *f = tmpfile ();
8 char obuf[99999], ibuf[sizeof obuf];
9 char *line;
10 size_t linesz;
11
12 if (! f)
13 {
14 perror ("tmpfile");
15 return 1;
16 }
17
18 if (fputs ("line\n", f) == EOF)
19 {
20 perror ("fputs");
21 return 1;
22 }
23
24 memset (obuf, 'z', sizeof obuf);
25 memset (ibuf, 'y', sizeof ibuf);
26
27 if (fwrite (obuf, sizeof obuf, 1, f) != 1)
28 {
29 perror ("fwrite");
30 return 1;
31 }
32
33 rewind (f);
34
35 line = NULL;
36 linesz = 0;
37#ifdef HAVE_GETLINE
38 if (getline (&line, &linesz, f) != 5)
39 {
40 perror ("getline");
41 return 1;
42 }
43#else
44 char fgetbuf [80];
45 line = fgets (fgetbuf, sizeof(fgetbuf), f);
46 if (!line)
47 {
48 perror ("gets");
49 return 1;
50 }
51#endif
52 if (strcmp (line, "line\n"))