Warning: That file was not part of the compilation database. It may have many parsing errors.

1/* Test for bug in fflush synchronization behavior. */
2
3#include <stdio.h>
4#include <stdlib.h>
5#include <string.h>
6
7
8static char *fname;
9
10static void prepare (void);
11#define PREPARE(argc, argv) prepare ()
12
13
14#define TEST_FUNCTION do_test ()
15static int do_test (void);
16#include "../test-skeleton.c"
17
18
19static void
20prepare (void)
21{
22 int fd = create_temp_file ("bug-mmap-fflush.", &fname);
23 if (fd == -1)
24 exit (3);
25 /* We don't need the descriptor. */
26 close (fd);
27}
28
29
30static int
31do_test (void)
32{
33 FILE *f;
34 off_t o;
35 char buffer[1024];
36
37 snprintf (buffer, sizeof (buffer), "echo 'From foo@bar.com' > %s", fname);
38 system (buffer);
39 f = fopen (fname, "r");
40 fseek (f, 0, SEEK_END);
41 o = ftello (f);
42 fseek (f, 0, SEEK_SET);
43 fflush (f);
44 snprintf (buffer, sizeof (buffer), "echo 'From bar@baz.edu' >> %s", fname);
45 system (buffer);
46 fseek (f, o, SEEK_SET);
47 if (fgets (buffer, 1024, f) == NULL)
48 exit (1);
49 if (strncmp (buffer, "From ", 5) != 0)
50 exit (1);
51 fclose (f);
52 exit (0);
53}
54

Warning: That file was not part of the compilation database. It may have many parsing errors.