- Removing Catch2 code from codebase, will pull it via FetchContent instead.
- Changing StdOutLogger to OStreamLogger, so that test cases output can be silenced.
This commit is contained in:
@@ -3,48 +3,46 @@
|
||||
|
||||
#include "daggy/executors/task/ForkingTaskExecutor.hpp"
|
||||
|
||||
#include "catch.hpp"
|
||||
#include <catch2/catch.hpp>
|
||||
|
||||
TEST_CASE("Basic Execution", "[forking_executor]") {
|
||||
daggy::executors::task::ForkingTaskExecutor ex(10);
|
||||
daggy::executors::task::ForkingTaskExecutor ex(10);
|
||||
|
||||
SECTION("Simple Run") {
|
||||
std::vector<std::string> cmd{"/usr/bin/echo", "abc", "123"};
|
||||
SECTION("Simple Run") {
|
||||
std::vector<std::string> cmd{"/usr/bin/echo", "abc", "123"};
|
||||
|
||||
auto rec = ex.runCommand(cmd);
|
||||
auto rec = ex.runCommand(cmd);
|
||||
|
||||
REQUIRE(rec.rc == 0);
|
||||
REQUIRE(rec.output == "abc 123\n");
|
||||
REQUIRE(rec.error.empty());
|
||||
}
|
||||
|
||||
SECTION("Error Run") {
|
||||
std::vector<std::string> cmd{"/usr/bin/expr", "1", "+", "+"};
|
||||
|
||||
auto rec = ex.runCommand(cmd);
|
||||
|
||||
REQUIRE(rec.rc == 2);
|
||||
REQUIRE(rec.error == "/usr/bin/expr: syntax error: missing argument after ‘+’\n");
|
||||
REQUIRE(rec.output.empty());
|
||||
}
|
||||
|
||||
SECTION("Large Output") {
|
||||
const std::vector<std::string> BIG_FILES{
|
||||
"/usr/share/dict/linux.words"
|
||||
, "/usr/share/dict/cracklib-small"
|
||||
, "/etc/ssh/moduli"
|
||||
};
|
||||
|
||||
for (const auto & bigFile : BIG_FILES) {
|
||||
if (! std::filesystem::exists(bigFile)) continue;
|
||||
|
||||
std::vector<std::string> cmd{"/usr/bin/cat", bigFile};
|
||||
|
||||
auto rec = ex.runCommand(cmd);
|
||||
|
||||
REQUIRE(rec.rc == 0);
|
||||
REQUIRE(rec.output.size() == std::filesystem::file_size(bigFile));
|
||||
REQUIRE(rec.error.empty());
|
||||
REQUIRE(rec.rc == 0);
|
||||
REQUIRE(rec.output == "abc 123\n");
|
||||
REQUIRE(rec.error.empty());
|
||||
}
|
||||
|
||||
SECTION("Error Run") {
|
||||
std::vector<std::string> cmd{"/usr/bin/expr", "1", "+", "+"};
|
||||
|
||||
auto rec = ex.runCommand(cmd);
|
||||
|
||||
REQUIRE(rec.rc == 2);
|
||||
REQUIRE(rec.error == "/usr/bin/expr: syntax error: missing argument after ‘+’\n");
|
||||
REQUIRE(rec.output.empty());
|
||||
}
|
||||
|
||||
SECTION("Large Output") {
|
||||
const std::vector<std::string> BIG_FILES{
|
||||
"/usr/share/dict/linux.words", "/usr/share/dict/cracklib-small", "/etc/ssh/moduli"
|
||||
};
|
||||
|
||||
for (const auto &bigFile : BIG_FILES) {
|
||||
if (!std::filesystem::exists(bigFile)) continue;
|
||||
|
||||
std::vector<std::string> cmd{"/usr/bin/cat", bigFile};
|
||||
|
||||
auto rec = ex.runCommand(cmd);
|
||||
|
||||
REQUIRE(rec.rc == 0);
|
||||
REQUIRE(rec.output.size() == std::filesystem::file_size(bigFile));
|
||||
REQUIRE(rec.error.empty());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user