Пример #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
static
std::auto_ptr< atf::check::check_result >
do_exec(const atf::tests::tc* tc, const char* helper_name)
{
    std::vector< std::string > argv;
    argv.push_back(get_process_helpers_path(*tc, false).str());
    argv.push_back(helper_name);
    std::cout << "Executing " << argv[0] << " " << argv[1] << "\n";

    atf::process::argv_array argva(argv);
    return atf::check::exec(argva);
}
Пример #3
0
static void do_exec (const atf_tc_t * tc, const char *helper_name, atf_process_status_t * s)
{
    atf_fs_path_t process_helpers;

    const char *argv[3];

    get_process_helpers_path (tc, true, &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_process_exec_array (s, &process_helpers, argv, NULL, NULL));
    atf_fs_path_fini (&process_helpers);
}
Пример #4
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);
}
Пример #5
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);
}
Пример #6
0
ATF_TC_BODY (exec_list, tc)
{
    atf_fs_path_t process_helpers;

    atf_list_t argv;

    atf_process_status_t status;

    RE (atf_list_init (&argv));

    get_process_helpers_path (tc, true, &process_helpers);
    atf_list_append (&argv, strdup (atf_fs_path_cstring (&process_helpers)), true);
    atf_list_append (&argv, strdup ("echo"), true);
    atf_list_append (&argv, strdup ("test-message"), true);
    {
        atf_fs_path_t outpath;

        atf_process_stream_t outsb;

        RE (atf_fs_path_init_fmt (&outpath, "stdout"));
        RE (atf_process_stream_init_redirect_path (&outsb, &outpath));
        RE (atf_process_exec_list (&status, &process_helpers, &argv, &outsb, NULL));
        atf_process_stream_fini (&outsb);
        atf_fs_path_fini (&outpath);
    }
    atf_list_fini (&argv);

    ATF_CHECK (atf_process_status_exited (&status));
    ATF_CHECK_EQ (atf_process_status_exitstatus (&status), EXIT_SUCCESS);

    {
        int fd = open ("stdout", O_RDONLY);

        ATF_CHECK (fd != -1);
        check_line (fd, "test-message");
        close (fd);
    }

    atf_process_status_fini (&status);
    atf_fs_path_fini (&process_helpers);
}