sparc: Fix sparc64 memmove length comparison (BZ 31266)
[glibc.git] / libio / bug-wfflush.c
blobd1b9d8e9de18215762e140a8116c5bf00a01c838
1 /* Test program for bug in wide streams. */
3 #include <stdio.h>
4 #include <wchar.h>
6 #include <support/xunistd.h>
8 static void do_prepare (void);
9 #define PREPARE(argc, argv) do_prepare ()
10 static int do_test (void);
11 #define TEST_FUNCTION do_test ()
12 #include <test-skeleton.c>
14 static char *temp_file;
16 static void
17 do_prepare (void)
19 int fd = create_temp_file ("bug-ungetc.", &temp_file);
20 if (fd == -1)
22 printf ("cannot create temporary file: %m\n");
23 exit (1);
25 xwrite (fd, "1!", 2);
26 close (fd);
29 static int
30 do_test (void)
32 FILE *f = fopen (temp_file, "r+");
34 if (f == NULL)
36 printf ("fopen: %m\n");
37 return 1;
40 #define L_(s) L##s
41 //#define fwscanf fscanf
42 //#define fwprintf fprintf
44 int i;
45 if (fwscanf (f, L_("%d!"), &i) != 1)
47 printf ("fwscanf failed\n");
48 return 1;
51 rewind (f);
52 if (ferror (f))
54 printf ("rewind: %m\n");
55 return 1;
58 if (fputws (L_("1!"), f) == EOF)
60 printf ("fputws: %m\n");
61 return 1;
64 if (fflush (f) != 0)
66 printf ("fflush: %m\n");
67 return 1;
70 if (fclose (f) != 0)
72 printf ("fclose: %m\n");
73 return 1;
76 puts ("Test succeeded.");
77 return 0;