1 #define _XOPEN_SOURCE 700
12 error("%s failed (errno = %d)\n", #c, errno); \
15 void test_fdopen(void)
17 char tmp[] = "/tmp/testsuite-XXXXXX";
22 TEST((fd = mkstemp(tmp)) > 2);
23 TEST(write(fd, "hello", 6)==6);
24 TEST(f = fdopen(fd, "rb"));
27 TEST(fseeko(f, 0, SEEK_SET)==0);
28 TEST(fgets(foo, sizeof foo, f));
29 if (strcmp(foo,"hello") != 0)
30 error("fgets read back wrong message: \"%s\" wanted: \"hello\"\n", foo);
34 TEST(unlink(tmp) != -1);