futimens is in POSIX 2008.
[glibc/history.git] / libio / tst-ext2.c
blobed72efa0c75c5d2d786694d8ef621d3e6edb20ed
1 #include <stdio.h>
2 #include <stdio_ext.h>
5 static char *fname;
7 #define PREPARE(argc, argv) \
8 do { \
9 int fd = create_temp_file ("tst-ext2", &fname); \
10 if (fd == -1) \
11 { \
12 puts ("cannot create temporary file"); \
13 exit (1); \
14 } \
15 close (fd); \
16 } while (0)
19 static int
20 do_test (void)
22 int res = 0;
24 FILE *fp;
26 fp = fopen (fname, "w");
27 printf ("Initial state for write-only stream: %d %d\n",
28 __freading (fp) != 0, __fwriting (fp) != 0);
29 res |= ((__freading (fp) != 0) != 0
30 || (__fwriting (fp) != 0) != 1);
31 fclose (fp);
33 fp = fopen (fname, "r");
34 printf ("Initial state for read-only stream: %d %d\n",
35 __freading (fp) != 0, __fwriting (fp) != 0);
36 res |= ((__freading (fp) != 0) != 1
37 || (__fwriting (fp) != 0) != 0);
38 fclose (fp);
40 fp = fopen (fname, "r+");
41 printf ("Initial state for read-write stream: %d %d\n",
42 __freading (fp) != 0, __fwriting (fp) != 0);
43 res |= ((__freading (fp) != 0) != 0
44 || (__fwriting (fp) != 0) != 0);
45 fclose (fp);
47 fp = fopen (fname, "w+");
48 printf ("Initial state for read-write stream: %d %d\n",
49 __freading (fp) != 0, __fwriting (fp) != 0);
50 res |= ((__freading (fp) != 0) != 0
51 || (__fwriting (fp) != 0) != 0);
52 fclose (fp);
54 return res;
57 #define TEST_FUNCTION do_test ()
58 #include "../test-skeleton.c"