update from main archive 961016
[glibc.git] / stdio-common / bug4.c
blobacf5b5433b51cd733815259a9df60a987e6e10b4
1 #ifdef _LIBC
2 #include <ansidecl.h>
3 #endif
4 #include <stdio.h>
5 #include <unistd.h>
6 #include <string.h>
8 int stdio_block_read = 1, stdio_block_write = 1;
10 int
11 DEFUN(main, (argc, argv),
12 int argc AND char **argv)
14 FILE *f;
15 int i;
16 char buffer[31];
17 const char filename[] = "/tmp/bugtest";
19 while ((i = getopt (argc, argv, "rw")) != EOF)
20 switch (i)
22 case 'r':
23 stdio_block_read = 0;
24 break;
25 case 'w':
26 stdio_block_write = 0;
27 break;
30 f = fopen(filename, "w+");
31 for (i=0; i<9000; i++) {
32 putc('x', f);
34 fseek(f, 8180L, 0);
35 fwrite("Where does this text come from?", 1, 31, f);
36 fseek(f, 8180L, 0);
37 fread(buffer, 1, 31, f);
38 fwrite(buffer, 1, 31, stdout);
39 fclose(f);
40 remove(filename);
42 if (!memcmp (buffer, "Where does this text come from?", 31))
44 puts ("\nTest succeeded.");
45 return 0;
47 else
49 puts ("\nTest FAILED!");
50 return 1;