10 static void do_prepare (void);
11 #define PREPARE(argc, argv) do_prepare ()
12 static int do_test (void);
13 #define TEST_FUNCTION do_test ()
14 #include <test-skeleton.c>
20 static const char pattern[] = "12345678901234567890";
21 int fd = create_temp_file ("bug-fseek.", &fname);
24 printf ("cannot create temporary file: %m\n");
28 if (write (fd, pattern, sizeof (pattern)) != sizeof (pattern))
30 perror ("short write");
46 if ((f = fopen (fname, "r")) == (FILE *) NULL)
48 perror ("fopen(\"r\")");
53 if (fseek (f, -10, SEEK_CUR) == 0)
55 printf ("fseek() for r to before start of file worked!\n");
58 else if (errno != EINVAL)
61 fseek() for r to before start of file did not set errno to EINVAL. \
70 if ((f = fopen (fname, "r+")) == (FILE *) NULL)
72 perror ("fopen(\"r+\")");
77 if (fseek (f, -10, SEEK_CUR) == 0)
79 printf ("fseek() for r+ to before start of file worked!\n");
82 else if (errno != EINVAL)
85 fseek() for r+ to before start of file did not set errno to EINVAL. \
94 if ((f = fopen (fname, "r+")) == (FILE *) NULL)
96 perror ("fopen(\"r+\")");
102 puts ("ftell failed");
106 if (fseek (f, -10, SEEK_CUR) == 0)
108 printf ("fseek() for r+ to before start of file worked!\n");
111 else if (errno != EINVAL)
114 fseek() for r+ to before start of file did not set errno to EINVAL. \