Пример #1
0
ATF_TC_BODY(exec_array, tc)
{
    atf_fs_path_t process_helpers;
    atf_check_result_t result;

    get_process_helpers_path(tc, false, &process_helpers);

    const char *argv[4];
    argv[0] = atf_fs_path_cstring(&process_helpers);
    argv[1] = "echo";
    argv[2] = "test-message";
    argv[3] = NULL;

    RE(atf_check_exec_array(argv, &result));

    ATF_CHECK(atf_check_result_exited(&result));
    ATF_CHECK(atf_check_result_exitcode(&result) == EXIT_SUCCESS);

    {
        const char *path = atf_check_result_stdout(&result);
        int fd = open(path, O_RDONLY);
        ATF_CHECK(fd != -1);
        check_line(fd, "test-message");
        close(fd);
    }

    atf_check_result_fini(&result);
    atf_fs_path_fini(&process_helpers);
}
Пример #2
0
std::auto_ptr< impl::check_result >
impl::exec(const atf::process::argv_array& argva)
{
    atf_check_result_t result;

    atf_error_t err = atf_check_exec_array(argva.exec_argv(), &result);
    if (atf_is_error(err))
        throw_atf_error(err);

    return std::auto_ptr< impl::check_result >(new impl::check_result(&result));
}
Пример #3
0
ATF_TC_BODY(exec_unknown, tc)
{
    const char *argv[2];
    argv[0] = "/foo/bar/non-existent";
    argv[1] = NULL;

    atf_check_result_t result;
    RE(atf_check_exec_array(argv, &result));
    ATF_CHECK(atf_check_result_exited(&result));
    ATF_CHECK(atf_check_result_exitcode(&result) == 127);
    atf_check_result_fini(&result);
}
Пример #4
0
ATF_TC_BODY(exec_unknown, tc)
{
    char buf[1024];
    snprintf(buf, sizeof(buf), "%s/non-existent",
             atf_config_get("atf_workdir"));

    const char *argv[2];
    argv[0] = buf;
    argv[1] = NULL;

    atf_check_result_t result;
    RE(atf_check_exec_array(argv, &result));
    ATF_CHECK(atf_check_result_exited(&result));
    ATF_CHECK(atf_check_result_exitcode(&result) == 127);
    atf_check_result_fini(&result);
}
Пример #5
0
static
void
do_exec(const atf_tc_t *tc, const char *helper_name, atf_check_result_t *r)
{
    atf_fs_path_t process_helpers;
    const char *argv[3];

    get_process_helpers_path(tc, false, &process_helpers);

    argv[0] = atf_fs_path_cstring(&process_helpers);
    argv[1] = helper_name;
    argv[2] = NULL;
    printf("Executing %s %s\n", argv[0], argv[1]);
    RE(atf_check_exec_array(argv, r));

    atf_fs_path_fini(&process_helpers);
}
Пример #6
0
ATF_TC_BODY(exec_umask, tc)
{
    atf_check_result_t result;
    atf_fs_path_t process_helpers;
    const char *argv[3];

    get_process_helpers_path(tc, false, &process_helpers);
    argv[0] = atf_fs_path_cstring(&process_helpers);
    argv[1] = "exit-success";
    argv[2] = NULL;

    umask(0222);
    atf_error_t err = atf_check_exec_array(argv, &result);
    ATF_CHECK(atf_is_error(err));
    ATF_CHECK(atf_error_is(err, "invalid_umask"));
    atf_error_free(err);

    atf_fs_path_fini(&process_helpers);
}