30 lines
943 B
C++
30 lines
943 B
C++
#include "test_support.hpp"
|
|
|
|
#include <izo/process.hpp>
|
|
|
|
#include <fstream>
|
|
|
|
int main() {
|
|
std::string marker;
|
|
auto result = izo::launch_process({});
|
|
CHECK(!result);
|
|
CHECK(!result.error_message.empty());
|
|
|
|
result = izo::launch_process({"/izo/missing-executable", {}, {}, false});
|
|
CHECK(!result);
|
|
CHECK(!result.error_message.empty());
|
|
|
|
const auto directory = test_directory("process");
|
|
result = izo::launch_process({"/bin/sh", {"-c", "printf launched > marker.txt"}, directory, false});
|
|
CHECK(result);
|
|
CHECK(result.process_id > 0);
|
|
CHECK(wait_until([&] { return std::filesystem::exists(directory / "marker.txt"); }));
|
|
std::ifstream(directory / "marker.txt") >> marker;
|
|
CHECK(marker == "launched");
|
|
|
|
result = izo::launch_process({"/bin/true", {}, directory / "missing", false});
|
|
CHECK(!result);
|
|
CHECK(!result.error_message.empty());
|
|
std::filesystem::remove_all(directory);
|
|
}
|