* configure.in (libc_cv_gnu89_inline): Only do compile test.
[glibc/pb-stable.git] / libio / bug-wfflush.c
bloba8fd61e997f3a3a6abebbd31961553e56f8f8c2f
1 /* Test program for bug in wide streams. */
3 #include <stdio.h>
4 #include <wchar.h>
6 static void do_prepare (void);
7 #define PREPARE(argc, argv) do_prepare ()
8 static int do_test (void);
9 #define TEST_FUNCTION do_test ()
10 #include <test-skeleton.c>
12 static char *temp_file;
14 static void
15 do_prepare (void)
17 int fd = create_temp_file ("bug-ungetc.", &temp_file);
18 if (fd == -1)
20 printf ("cannot create temporary file: %m\n");
21 exit (1);
23 write (fd, "1!", 2);
24 close (fd);
27 static int
28 do_test (void)
30 FILE *f = fopen (temp_file, "r+");
32 if (f == NULL)
34 printf ("fopen: %m\n");
35 return 1;
38 #define L_(s) L##s
39 //#define fwscanf fscanf
40 //#define fwprintf fprintf
42 int i;
43 if (fwscanf (f, L_("%d!"), &i) != 1)
45 printf ("fwscanf failed\n");
46 return 1;
49 rewind (f);
50 if (ferror (f))
52 printf ("rewind: %m\n");
53 return 1;
56 if (fputws (L_("1!"), f) == EOF)
58 printf ("fputws: %m\n");
59 return 1;
62 if (fflush (f) != 0)
64 printf ("fflush: %m\n");
65 return 1;
68 if (fclose (f) != 0)
70 printf ("fclose: %m\n");
71 return 1;
74 puts ("Test succeeded.");
75 return 0;