49 lines
1.3 KiB
C++
49 lines
1.3 KiB
C++
#include <iostream>
|
|
#include <filesystem>
|
|
|
|
#include "daggy/executors/task/ForkingTaskExecutor.hpp"
|
|
|
|
#include <catch2/catch.hpp>
|
|
|
|
TEST_CASE("Basic Execution", "[forking_executor]") {
|
|
daggy::executors::task::ForkingTaskExecutor ex(10);
|
|
|
|
SECTION("Simple Run") {
|
|
daggy::Task task{.command{"/bin/echo", "abc", "123"}};
|
|
|
|
auto rec = ex.runCommand(task);
|
|
|
|
REQUIRE(rec.rc == 0);
|
|
REQUIRE(rec.outputLog.size() >= 7);
|
|
REQUIRE(rec.errorLog.empty());
|
|
}
|
|
|
|
SECTION("Error Run") {
|
|
daggy::Task task{.command{"/usr/bin/expr", "1", "+", "+"}};
|
|
|
|
auto rec = ex.runCommand(task);
|
|
|
|
REQUIRE(rec.rc == 2);
|
|
REQUIRE(rec.errorLog.size() >= 20);
|
|
REQUIRE(rec.outputLog.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;
|
|
|
|
daggy::Task task{.command{"/usr/bin/cat", bigFile}};
|
|
|
|
auto rec = ex.runCommand(task);
|
|
|
|
REQUIRE(rec.rc == 0);
|
|
REQUIRE(rec.outputLog.size() == std::filesystem::file_size(bigFile));
|
|
REQUIRE(rec.errorLog.empty());
|
|
}
|
|
}
|
|
}
|