Lines Matching +full:stdout +full:- +full:path
48 #include <atf-c++.hpp>
54 #include "utils/fs/path.hpp"
89 std::cout << "To stdout: " << Message << "\n"; in child_simple_function()
100 /// The message to print on stdout and stderr.
107 /// \param message The message to print on stdout and stderr.
118 std::cout << "To stdout: " << _message << "\n"; in operator ()()
125 /// Body for a process that prints many messages to stdout and exits.
133 std::cout << "This is a message to stdout, sequence " << i << "\n"; in child_printer_function()
200 /// Calculates the path to the test helpers binary.
205 /// \return The path to the helpers binary.
206 static fs::path
209 return fs::path(tc->get_config_var("srcdir")) / "helpers"; in get_helpers()
217 /// \return Always -1.
223 return -1; in fork_fail()
227 /// Mock open(2) that fails if the 'raise-error' file is opened.
230 /// \param path The path to the file to be opened.
234 /// \return The opened file handle or -1 on error.
237 open_fail(const char* path, const int flags, ...) throw() in open_fail() argument
239 if (std::strcmp(path, "raise-error") == 0) { in open_fail()
241 return -1; in open_fail()
247 return ::open(path, flags, mode); in open_fail()
256 /// \return Always -1.
262 return -1; in pipe_fail()
266 /// Helper for child tests to validate inheritance of stdout/stderr.
268 /// This function ensures that passing one of /dev/stdout or /dev/stderr to
275 /// \param fork_stdout The path to pass to the fork call as the stdout file.
276 /// \param fork_stderr The path to pass to the fork call as the stderr file.
284 ATF_REQUIRE(pid != -1); in do_inherit_test()
290 if (::dup2(fd, child_fd) == -1) in do_inherit_test()
297 fs::path(fork_stdout), fs::path(fork_stderr)); in do_inherit_test()
298 const process::status status = child->wait(); in do_inherit_test()
304 ATF_REQUIRE(::waitpid(pid, &status, 0) != -1); in do_inherit_test()
307 ATF_REQUIRE(atf::utils::grep_file("stdout: Z", "stdout.txt")); in do_inherit_test()
330 std::istream& output = child->output(); in child__fork_capture__ok()
334 ATF_REQUIRE_EQ((F("This is a message to stdout, " in child__fork_capture__ok()
342 process::status status = child->wait(); in child__fork_capture__ok()
372 std::istream& output = child->output(); in ATF_TEST_CASE_BODY()
375 const process::status status = child->wait(); in ATF_TEST_CASE_BODY()
388 const process::status status = child->wait(); in ATF_TEST_CASE_BODY()
412 atf::utils::create_file("to-not-be-deleted", ""); in ATF_TEST_CASE_BODY()
418 ::unlink("to-not-be-deleted"); in ATF_TEST_CASE_BODY()
422 const process::status status = child->wait(); in ATF_TEST_CASE_BODY()
424 ATF_REQUIRE(fs::exists(fs::path("to-not-be-deleted"))); in ATF_TEST_CASE_BODY()
432 atf::utils::create_file("to-not-be-deleted", ""); in ATF_TEST_CASE_BODY()
436 const process::status status = child->wait(); in ATF_TEST_CASE_BODY()
438 ATF_REQUIRE(fs::exists(fs::path("to-not-be-deleted"))); in ATF_TEST_CASE_BODY()
444 ::unlink("to-not-be-deleted"); in ATF_TEST_CASE_BODY()
467 const fs::path file1("file1.txt"); in ATF_TEST_CASE_BODY()
468 const fs::path file2("file2.txt"); in ATF_TEST_CASE_BODY()
472 const process::status status = child->wait(); in ATF_TEST_CASE_BODY()
476 ATF_REQUIRE( atf::utils::grep_file("^To stdout: Z$", file1.str())); in ATF_TEST_CASE_BODY()
477 ATF_REQUIRE(!atf::utils::grep_file("^To stdout: Z$", file2.str())); in ATF_TEST_CASE_BODY()
487 const fs::path filea("fileA.txt"); in ATF_TEST_CASE_BODY()
488 const fs::path fileb("fileB.txt"); in ATF_TEST_CASE_BODY()
490 atf::utils::create_file(filea.str(), "Initial stdout\n"); in ATF_TEST_CASE_BODY()
495 const process::status status = child->wait(); in ATF_TEST_CASE_BODY()
499 ATF_REQUIRE( atf::utils::grep_file("^Initial stdout$", filea.str())); in ATF_TEST_CASE_BODY()
500 ATF_REQUIRE(!atf::utils::grep_file("^Initial stdout$", fileb.str())); in ATF_TEST_CASE_BODY()
502 ATF_REQUIRE( atf::utils::grep_file("^To stdout: a functor$", filea.str())); in ATF_TEST_CASE_BODY()
503 ATF_REQUIRE(!atf::utils::grep_file("^To stdout: a functor$", fileb.str())); in ATF_TEST_CASE_BODY()
518 fs::path("unused.out"), fs::path("stderr")); in ATF_TEST_CASE_BODY()
520 const process::status status = child->wait(); in ATF_TEST_CASE_BODY()
533 fs::path("unused.out"), fs::path("unused.err")); in ATF_TEST_CASE_BODY()
534 const process::status status = child->wait(); in ATF_TEST_CASE_BODY()
543 do_inherit_test("/dev/stdout", "stderr.txt", "stdout.txt", STDOUT_FILENO); in ATF_TEST_CASE_BODY()
550 do_inherit_test("stdout.txt", "/dev/stderr", "stderr.txt", STDERR_FILENO); in ATF_TEST_CASE_BODY()
558 atf::utils::create_file("to-not-be-deleted", ""); in ATF_TEST_CASE_BODY()
561 child_return, fs::path("out"), fs::path("err")); in ATF_TEST_CASE_BODY()
564 ::unlink("to-not-be-deleted"); in ATF_TEST_CASE_BODY()
568 const process::status status = child->wait(); in ATF_TEST_CASE_BODY()
570 ATF_REQUIRE(fs::exists(fs::path("to-not-be-deleted"))); in ATF_TEST_CASE_BODY()
578 atf::utils::create_file("to-not-be-deleted", ""); in ATF_TEST_CASE_BODY()
581 child_raise_exception< int, 123 >, fs::path("out"), in ATF_TEST_CASE_BODY()
582 fs::path("err")); in ATF_TEST_CASE_BODY()
583 const process::status status = child->wait(); in ATF_TEST_CASE_BODY()
585 ATF_REQUIRE(fs::exists(fs::path("to-not-be-deleted"))); in ATF_TEST_CASE_BODY()
591 ::unlink("to-not-be-deleted"); in ATF_TEST_CASE_BODY()
603 fs::path("a.txt"), fs::path("b.txt")); in ATF_TEST_CASE_BODY()
609 ATF_REQUIRE(!fs::exists(fs::path("a.txt"))); in ATF_TEST_CASE_BODY()
610 ATF_REQUIRE(!fs::exists(fs::path("b.txt"))); in ATF_TEST_CASE_BODY()
619 child_simple_function< 1, 'A' >, fs::path("raise-error"), in ATF_TEST_CASE_BODY()
620 fs::path("created")); in ATF_TEST_CASE_BODY()
621 const process::status status = child->wait(); in ATF_TEST_CASE_BODY()
624 ATF_REQUIRE(!fs::exists(fs::path("raise-error"))); in ATF_TEST_CASE_BODY()
625 ATF_REQUIRE(!fs::exists(fs::path("created"))); in ATF_TEST_CASE_BODY()
634 child_simple_function< 1, 'A' >, fs::path("created"), in ATF_TEST_CASE_BODY()
635 fs::path("raise-error")); in ATF_TEST_CASE_BODY()
636 const process::status status = child->wait(); in ATF_TEST_CASE_BODY()
639 ATF_REQUIRE(fs::exists(fs::path("created"))); in ATF_TEST_CASE_BODY()
640 ATF_REQUIRE(!fs::exists(fs::path("raise-error"))); in ATF_TEST_CASE_BODY()
648 args.push_back("return-code"); in ATF_TEST_CASE_BODY()
651 const fs::path program = get_helpers(this); in ATF_TEST_CASE_BODY()
654 program, args, fs::path("out"), fs::path("err")); in ATF_TEST_CASE_BODY()
656 const process::status status = child->wait(); in ATF_TEST_CASE_BODY()
666 args.push_back("return-code"); in ATF_TEST_CASE_BODY()
669 ATF_REQUIRE(::mkdir("root", 0755) != -1); in ATF_TEST_CASE_BODY()
670 ATF_REQUIRE(::symlink(get_helpers(this).c_str(), "root/helpers") != -1); in ATF_TEST_CASE_BODY()
673 fs::path("root/helpers"), args, fs::path("out"), fs::path("err")); in ATF_TEST_CASE_BODY()
675 const process::status status = child->wait(); in ATF_TEST_CASE_BODY()
685 args.push_back("return-code"); in ATF_TEST_CASE_BODY()
688 ATF_REQUIRE(::symlink(get_helpers(this).c_str(), "helpers") != -1); in ATF_TEST_CASE_BODY()
691 fs::path("helpers"), args, fs::path("out"), fs::path("err")); in ATF_TEST_CASE_BODY()
693 const process::status status = child->wait(); in ATF_TEST_CASE_BODY()
705 args.push_back("return-code"); in ATF_TEST_CASE_BODY()
708 const fs::path helpers = get_helpers(this); in ATF_TEST_CASE_BODY()
709 utils::setenv("PATH", helpers.branch_path().c_str()); in ATF_TEST_CASE_BODY()
711 fs::path(helpers.leaf_name()), args); in ATF_TEST_CASE_BODY()
714 ATF_REQUIRE(std::getline(child->output(), line).good()); in ATF_TEST_CASE_BODY()
716 ATF_REQUIRE(!std::getline(child->output(), line)); in ATF_TEST_CASE_BODY()
718 const process::status status = child->wait(); in ATF_TEST_CASE_BODY()
732 ATF_REQUIRE(std::getline(child->output(), line).good()); in ATF_TEST_CASE_BODY()
734 ATF_REQUIRE(!std::getline(child->output(), line)); in ATF_TEST_CASE_BODY()
736 const process::status status = child->wait(); in ATF_TEST_CASE_BODY()
746 args.push_back("print-args"); in ATF_TEST_CASE_BODY()
753 ATF_REQUIRE(std::getline(child->output(), line).good()); in ATF_TEST_CASE_BODY()
755 ATF_REQUIRE(std::getline(child->output(), line).good()); in ATF_TEST_CASE_BODY()
756 ATF_REQUIRE_EQ("argv[1] = print-args", line); in ATF_TEST_CASE_BODY()
757 ATF_REQUIRE(std::getline(child->output(), line)); in ATF_TEST_CASE_BODY()
759 ATF_REQUIRE(std::getline(child->output(), line)); in ATF_TEST_CASE_BODY()
761 ATF_REQUIRE(std::getline(child->output(), line)); in ATF_TEST_CASE_BODY()
763 ATF_REQUIRE(!std::getline(child->output(), line)); in ATF_TEST_CASE_BODY()
765 const process::status status = child->wait(); in ATF_TEST_CASE_BODY()
776 fs::path("a/b/c"), args); in ATF_TEST_CASE_BODY()
779 ATF_REQUIRE(std::getline(child->output(), line).good()); in ATF_TEST_CASE_BODY()
782 ATF_REQUIRE(!std::getline(child->output(), line)); in ATF_TEST_CASE_BODY()
784 const process::status status = child->wait(); in ATF_TEST_CASE_BODY()
796 const int pid = child->pid(); in ATF_TEST_CASE_BODY()
798 const process::status status = child->wait(); in ATF_TEST_CASE_BODY()