* sysdeps/unix/sysv/linux/sh/Makefile: Remove sys/io.h
[glibc.git] / dirent / tst-fdopendir2.c
blob3720809dc2673f2b0ab762df47ca94df882c6e6b
1 #include <errno.h>
2 #include <dirent.h>
3 #include <stdio.h>
4 #include <unistd.h>
7 static int
8 do_test (void)
10 char tmpl[] = "/tmp/tst-fdopendir2-XXXXXX";
11 int fd = mkstemp (tmpl);
12 if (fd == -1)
14 puts ("cannot open temp file");
15 return 1;
18 errno = 0;
19 DIR *d = fdopendir (fd);
21 int e = errno;
23 close (fd);
24 unlink (tmpl);
26 if (d != NULL)
28 puts ("fdopendir with normal file descriptor did not fail");
29 return 1;
31 if (e != ENOTDIR)
33 printf ("fdopendir set errno to %d, not %d as expected\n", e, ENOTDIR);
34 return 1;
37 return 0;
40 #define TEST_FUNCTION do_test ()
41 #include "../test-skeleton.c"