pdrfork(2) tests: split basic_usage
into pdrfork(2) call itself, and basic_usage_tail() that checks the pdrfork(2) results. Tested by: pho Reviewed by: markj Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D55306
This commit is contained in:
@@ -36,17 +36,12 @@
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
static void basic_usage(int rfflags) {
|
||||
int pd = -1;
|
||||
pid_t pid, pd_pid, waited_pid;
|
||||
static void
|
||||
basic_usage_tail(int pd, pid_t pid)
|
||||
{
|
||||
pid_t pd_pid, waited_pid;
|
||||
int r, status;
|
||||
|
||||
pid = pdrfork(&pd, 0, rfflags);
|
||||
ATF_REQUIRE_MSG(pid >= 0, "rfork failed with %s", strerror(errno));
|
||||
if (pid == 0) {
|
||||
/* In child */
|
||||
_exit(0);
|
||||
}
|
||||
ATF_REQUIRE_MSG(pd >= 0, "rfork did not return a process descriptor");
|
||||
r = pdgetpid(pd, &pd_pid);
|
||||
ATF_CHECK_EQ_MSG(r, 0, "pdgetpid failed: %s", strerror(errno));
|
||||
@@ -62,6 +57,21 @@ static void basic_usage(int rfflags) {
|
||||
ATF_CHECK_EQ(ECHILD, errno);
|
||||
}
|
||||
|
||||
static void
|
||||
basic_usage(int rfflags)
|
||||
{
|
||||
int pd = -1;
|
||||
pid_t pid;
|
||||
|
||||
pid = pdrfork(&pd, 0, rfflags);
|
||||
ATF_REQUIRE_MSG(pid >= 0, "rfork failed with %s", strerror(errno));
|
||||
if (pid == 0) {
|
||||
/* In child */
|
||||
_exit(0);
|
||||
}
|
||||
basic_usage_tail(pd, pid);
|
||||
}
|
||||
|
||||
/* pdrfork does not return a process descriptor to the child */
|
||||
ATF_TC_WITHOUT_HEAD(child_gets_no_pidfd);
|
||||
ATF_TC_BODY(child_gets_no_pidfd, tc)
|
||||
|
||||
Reference in New Issue
Block a user