diff options
| author | Lexi Winter <lexi@le-fay.org> | 2025-06-21 17:18:57 +0100 |
|---|---|---|
| committer | Lexi Winter <lexi@le-fay.org> | 2025-06-21 17:18:57 +0100 |
| commit | d27d1302d1fa1b96bf8f53f17fce947f19d21330 (patch) | |
| tree | f56ef29d7816c3b574b3359c746355a44e3b0819 /tests/spawn.cc | |
| parent | 75c6b5fee029ec95e7e45e18525e3e78b9616f48 (diff) | |
| download | nihil-d27d1302d1fa1b96bf8f53f17fce947f19d21330.tar.gz nihil-d27d1302d1fa1b96bf8f53f17fce947f19d21330.tar.bz2 | |
add nihil.config (incomplete)
Diffstat (limited to 'tests/spawn.cc')
| -rw-r--r-- | tests/spawn.cc | 65 |
1 files changed, 0 insertions, 65 deletions
diff --git a/tests/spawn.cc b/tests/spawn.cc deleted file mode 100644 index 455223e..0000000 --- a/tests/spawn.cc +++ /dev/null @@ -1,65 +0,0 @@ -/* - * This source code is released into the public domain. - */ - -#include <catch2/catch_test_macros.hpp> - -import nihil; - -TEST_CASE("spawn: system", "[spawn]") { - using namespace nihil; - auto output = std::string(); - auto result = spawn(shell("x=1; echo $x"), - capture(stdout_fileno, output)).wait(); - - REQUIRE(result.okay()); - REQUIRE(output == "1\n"); -} - -TEST_CASE("spawn: execv", "[spawn]") { - using namespace nihil; - auto output = std::string(); - auto args = argv::from_args({"sh", "-c", "x=1; echo $x"}); - auto result = spawn(execv("/bin/sh", std::move(args)), - capture(stdout_fileno, output)).wait(); - - REQUIRE(result.okay()); - REQUIRE(output == "1\n"); -} - -TEST_CASE("spawn: execvp", "[spawn]") { - using namespace nihil; - auto output = std::string(); - auto args = argv::from_args({"sh", "-c", "x=1; echo $x"}); - auto result = spawn(execvp("sh", std::move(args)), - capture(stdout_fileno, output)).wait(); - - REQUIRE(result.okay()); - REQUIRE(output == "1\n"); -} - -TEST_CASE("spawn: execl", "[spawn]") { - using namespace nihil; - auto output = std::string(); - auto result = spawn(execl("/bin/sh", "sh", "-c", "x=1; echo $x"), - capture(stdout_fileno, output)).wait(); - - REQUIRE(result.okay()); - REQUIRE(output == "1\n"); -} - -TEST_CASE("spawn: execlp", "[spawn]") { - using namespace nihil; - auto output = std::string(); - auto result = spawn(execlp("sh", "sh", "-c", "x=1; echo $x"), - capture(stdout_fileno, output)).wait(); - - REQUIRE(result.okay()); - REQUIRE(output == "1\n"); -} - -TEST_CASE("spawn: execlp failure", "[spawn]") { - using namespace nihil; - REQUIRE_THROWS_AS(execlp("lfjail_nonesuch_executable", "x"), - executable_not_found); -} |
