Changeset View
Changeset View
Standalone View
Standalone View
lib/libc/tests/gen/posix_spawn_test.c
Show First 20 Lines • Show All 87 Lines • ▼ Show 20 Lines | if (error == 0) { | ||||
ATF_REQUIRE(WIFEXITED(status) && WEXITSTATUS(status) == 127); | ATF_REQUIRE(WIFEXITED(status) && WEXITSTATUS(status) == 127); | ||||
} else { | } else { | ||||
ATF_REQUIRE(error == ENOENT); | ATF_REQUIRE(error == ENOENT); | ||||
waitres = waitpid(-1, NULL, 0); | waitres = waitpid(-1, NULL, 0); | ||||
ATF_REQUIRE(waitres == -1 && errno == ECHILD); | ATF_REQUIRE(waitres == -1 && errno == ECHILD); | ||||
} | } | ||||
} | } | ||||
ATF_TC_WITHOUT_HEAD(posix_spawnp_enoexec_fallback); | |||||
ATF_TC_BODY(posix_spawnp_enoexec_fallback, tc) | |||||
{ | |||||
char buf[FILENAME_MAX]; | |||||
char *myargs[2]; | |||||
int error, status; | |||||
pid_t pid, waitres; | |||||
snprintf(buf, sizeof(buf), "%s/spawnp_enoexec.sh", | |||||
atf_tc_get_config_var(tc, "srcdir")); | |||||
myargs[0] = buf; | |||||
myargs[1] = NULL; | |||||
error = posix_spawnp(&pid, myargs[0], NULL, NULL, myargs, myenv); | |||||
ATF_REQUIRE(error == 0); | |||||
waitres = waitpid(pid, &status, 0); | |||||
ATF_REQUIRE(waitres == pid); | |||||
ATF_REQUIRE(WIFEXITED(status) && WEXITSTATUS(status) == 42); | |||||
} | |||||
ATF_TC_WITHOUT_HEAD(posix_spawnp_enoexec_fallback_null_argv0); | |||||
ATF_TC_BODY(posix_spawnp_enoexec_fallback_null_argv0, tc) | |||||
{ | |||||
char buf[FILENAME_MAX]; | |||||
char *myargs[1]; | |||||
int error, status; | |||||
pid_t pid, waitres; | |||||
snprintf(buf, sizeof(buf), "%s/spawnp_enoexec.sh", | |||||
atf_tc_get_config_var(tc, "srcdir")); | |||||
myargs[0] = NULL; | |||||
error = posix_spawnp(&pid, buf, NULL, NULL, myargs, myenv); | |||||
ATF_REQUIRE(error == 0); | |||||
waitres = waitpid(pid, &status, 0); | |||||
ATF_REQUIRE(waitres == pid); | |||||
ATF_REQUIRE(WIFEXITED(status) && WEXITSTATUS(status) == 42); | |||||
} | |||||
ATF_TP_ADD_TCS(tp) | ATF_TP_ADD_TCS(tp) | ||||
{ | { | ||||
ATF_TP_ADD_TC(tp, posix_spawn_simple_test); | ATF_TP_ADD_TC(tp, posix_spawn_simple_test); | ||||
ATF_TP_ADD_TC(tp, posix_spawn_no_such_command_negative_test); | ATF_TP_ADD_TC(tp, posix_spawn_no_such_command_negative_test); | ||||
ATF_TP_ADD_TC(tp, posix_spawnp_enoexec_fallback); | |||||
ATF_TP_ADD_TC(tp, posix_spawnp_enoexec_fallback_null_argv0); | |||||
return (atf_no_error()); | return (atf_no_error()); | ||||
} | } |