1 #define _XOPEN_SOURCE 700
11 #define TEST(r, f, x, m) ( \
12 ((r) = (f)) == (x) || \
13 (error("%s failed (" m ")\n", #f, r, x), 0) )
15 #define TEST_E(f) ( (errno = 0), (f) || \
16 (error("%s failed (errno = %d \"%s\")\n", #f, errno, strerror(errno)), 0) )
18 void test_spawn(void) {
24 posix_spawn_file_actions_t fa;
27 TEST(r, posix_spawn_file_actions_init(&fa), 0, "%d != %d");
28 TEST(r, posix_spawn_file_actions_addclose(&fa, p[0]), 0, "%d != %d");
29 TEST(r, posix_spawn_file_actions_adddup2(&fa, p[1], 1), 0, "%d != %d");
30 TEST(r, posix_spawn_file_actions_addclose(&fa, p[1]), 0, "%d != %d");
31 TEST(r, posix_spawnp(&pid, "echo", &fa, 0, (char *[]){"echo","hello",0}, 0), 0, "%d != %d");
33 TEST(r, waitpid(pid, &status, 0), pid, "%d != %d");
34 TEST(r, read(p[0], foo, sizeof foo), 6, "%d != %d");
36 TEST(r, posix_spawn_file_actions_destroy(&fa), 0, "%d != %d");