inet_pton tests, fix regression test case
[libc-test.git] / src / regression / rewind-clear-error.c
blobe5375900069032473fd8f1f8fa46eb874c3a303c
1 // commit: a6238c30d169cbac6bc4c4977622242063e32270 2011-02-22
2 // rewind should clear error
3 #include <stdio.h>
4 #include <unistd.h>
5 #include "test.h"
7 int main(void)
9 char buf[1];
10 size_t n;
11 int fd;
13 // make sure fread fails
14 fd = dup(0);
15 close(0);
17 n = fread(buf, 1, sizeof buf, stdin);
18 if (n != 0 || !ferror(stdin))
19 t_error("fread(stdin) should have failed, got %d ferror %d feof %d\n",
20 n, ferror(stdin), feof(stdin));
21 if (dup(fd) != 0)
22 t_error("dup failed\n");
24 rewind(stdin);
25 if (ferror(stdin))
26 t_error("rewind failed to clear ferror\n");
27 return t_status;