#include #include #include #include #include using Error = std::optional; using namespace std::chrono_literals; namespace p = boost::process; static constexpr auto WaitTimeout = 10s; static constexpr auto Sleep = 30s; template static Error runBenchmark(const std::string &Binary, const std::chrono::duration &Timeout) { try { p::child c(Binary, p::std_out > p::null, p::std_err > p::null, p::std_in < p::null); if (!c.wait_for(Timeout)) { c.terminate(); return "Timeout"; } if (c.exit_code() != 0) return "Exited with code " + std::to_string(c.exit_code()); } catch (boost::process::process_error E) { return E.what(); } return {}; } int main(int argc, char **argv) { if (argc == 1) { auto start = std::chrono::steady_clock::now(); while (std::chrono::steady_clock::now() - start < Sleep); return 0; } if (auto E = runBenchmark(argv[0], WaitTimeout)) std::cerr << *E << "\n"; std::cerr << "Finished\n"; }