]> git.ipfire.org Git - thirdparty/glibc.git/blame - libio/bug-mmap-fflush.c
sparc (64bit): Regenerate ulps
[thirdparty/glibc.git] / libio / bug-mmap-fflush.c
CommitLineData
acbee5f6
RM
1/* Test for bug in fflush synchronization behavior. */
2
3#include <stdio.h>
4#include <stdlib.h>
5#include <string.h>
6
934b77ac
UD
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)
acbee5f6
RM
32{
33 FILE *f;
34 off_t o;
934b77ac 35 char buffer[1024];
acbee5f6 36
934b77ac
UD
37 snprintf (buffer, sizeof (buffer), "echo 'From foo@bar.com' > %s", fname);
38 system (buffer);
39 f = fopen (fname, "r");
acbee5f6
RM
40 fseek (f, 0, SEEK_END);
41 o = ftello (f);
42 fseek (f, 0, SEEK_SET);
43 fflush (f);
934b77ac
UD
44 snprintf (buffer, sizeof (buffer), "echo 'From bar@baz.edu' >> %s", fname);
45 system (buffer);
acbee5f6
RM
46 fseek (f, o, SEEK_SET);
47 if (fgets (buffer, 1024, f) == NULL)
934b77ac 48 exit (1);
acbee5f6 49 if (strncmp (buffer, "From ", 5) != 0)
934b77ac 50 exit (1);
acbee5f6
RM
51 fclose (f);
52 exit (0);
53}