Пример #1
0
ATF_TC_BODY (status_exited, tc)
{
    {
        const int rawstatus = fork_and_wait_child (child_exit_success);

        atf_process_status_t s;

        RE (atf_process_status_init (&s, rawstatus));
        ATF_CHECK (atf_process_status_exited (&s));
        ATF_CHECK_EQ (atf_process_status_exitstatus (&s), EXIT_SUCCESS);
        ATF_CHECK (!atf_process_status_signaled (&s));
        atf_process_status_fini (&s);
    }

    {
        const int rawstatus = fork_and_wait_child (child_exit_failure);

        atf_process_status_t s;

        RE (atf_process_status_init (&s, rawstatus));
        ATF_CHECK (atf_process_status_exited (&s));
        ATF_CHECK_EQ (atf_process_status_exitstatus (&s), EXIT_FAILURE);
        ATF_CHECK (!atf_process_status_signaled (&s));
        atf_process_status_fini (&s);
    }
}
Пример #2
0
ATF_TC_BODY (status_signaled, tc)
{
    {
        const int rawstatus = fork_and_wait_child (child_sigkill);

        atf_process_status_t s;

        RE (atf_process_status_init (&s, rawstatus));
        ATF_CHECK (!atf_process_status_exited (&s));
        ATF_CHECK (atf_process_status_signaled (&s));
        ATF_CHECK_EQ (atf_process_status_termsig (&s), SIGKILL);
        ATF_CHECK (!atf_process_status_coredump (&s));
        atf_process_status_fini (&s);
    }

    {
        const int rawstatus = fork_and_wait_child (child_sigterm);

        atf_process_status_t s;

        RE (atf_process_status_init (&s, rawstatus));
        ATF_CHECK (!atf_process_status_exited (&s));
        ATF_CHECK (atf_process_status_signaled (&s));
        ATF_CHECK_EQ (atf_process_status_termsig (&s), SIGTERM);
        ATF_CHECK (!atf_process_status_coredump (&s));
        atf_process_status_fini (&s);
    }
}
Пример #3
0
atf_error_t
atf_process_child_wait(atf_process_child_t *c, atf_process_status_t *s)
{
    atf_error_t err;
    int status;

    if (waitpid(c->m_pid, &status, 0) == -1)
        err = atf_libc_error(errno, "Failed waiting for process %d",
                             c->m_pid);
    else {
        atf_process_child_fini(c);
        err = atf_process_status_init(s, status);
    }

    return err;
}
Пример #4
0
ATF_TC_BODY (status_coredump, tc)
{
    struct rlimit rl;

    rl.rlim_cur = RLIM_INFINITY;
    rl.rlim_max = RLIM_INFINITY;
    if (setrlimit (RLIMIT_CORE, &rl) == -1)
        atf_tc_skip ("Cannot unlimit the core file size; check limits " "manually");

    const int rawstatus = fork_and_wait_child (child_sigquit);

    atf_process_status_t s;

    RE (atf_process_status_init (&s, rawstatus));
    ATF_CHECK (!atf_process_status_exited (&s));
    ATF_CHECK (atf_process_status_signaled (&s));
    ATF_CHECK_EQ (atf_process_status_termsig (&s), SIGQUIT);
    ATF_CHECK (atf_process_status_coredump (&s));
    atf_process_status_fini (&s);
}