Beispiel #1
0
/// Tests an exec function with no arguments.
///
/// \param tc The calling test case.
/// \param do_exec The exec function to test.
static void
check_exec_no_args(const atf::tests::tc* tc, const exec_function do_exec)
{
    std::auto_ptr< process::child > child = process::child::fork_files(
        child_exec(do_exec, get_helpers(tc), process::args_vector()),
        fs::path("stdout"), fs::path("stderr"));
    const process::status status = child->wait();
    ATF_REQUIRE(status.exited());
    ATF_REQUIRE_EQ(EXIT_FAILURE, status.exitstatus());
    ATF_REQUIRE(atf::utils::grep_file("Must provide a helper name", "stderr"));
}
Beispiel #2
0
/// Tests an exec function with some arguments.
///
/// \param tc The calling test case.
/// \param do_exec The exec function to test.
static void
check_exec_some_args(const atf::tests::tc* tc, const exec_function do_exec)
{
    process::args_vector args;
    args.push_back("print-args");
    args.push_back("foo");
    args.push_back("bar");

    std::auto_ptr< process::child > child = process::child::fork_files(
        child_exec(do_exec, get_helpers(tc), args),
        fs::path("stdout"), fs::path("stderr"));
    const process::status status = child->wait();
    ATF_REQUIRE(status.exited());
    ATF_REQUIRE_EQ(EXIT_SUCCESS, status.exitstatus());
    ATF_REQUIRE(atf::utils::grep_file("argv\\[1\\] = print-args", "stdout"));
    ATF_REQUIRE(atf::utils::grep_file("argv\\[2\\] = foo", "stdout"));
    ATF_REQUIRE(atf::utils::grep_file("argv\\[3\\] = bar", "stdout"));
}