diff options
author | crupest <crupest@outlook.com> | 2023-02-06 00:09:57 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2023-02-06 00:09:57 +0800 |
commit | a207604826d5b4eb1a230adc2c201fdc478b2678 (patch) | |
tree | 65af79b53ef392e8ddaff2c09ad22f47dccfffb6 /works/life/linux-run/linux-run-test.cpp | |
parent | 82ca9e11965bce800ed5d500ab9c7dbc9ac3aa77 (diff) | |
download | crupest-a207604826d5b4eb1a230adc2c201fdc478b2678.tar.gz crupest-a207604826d5b4eb1a230adc2c201fdc478b2678.tar.bz2 crupest-a207604826d5b4eb1a230adc2c201fdc478b2678.zip |
import(life): Add linux-run.
Diffstat (limited to 'works/life/linux-run/linux-run-test.cpp')
-rw-r--r-- | works/life/linux-run/linux-run-test.cpp | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/works/life/linux-run/linux-run-test.cpp b/works/life/linux-run/linux-run-test.cpp new file mode 100644 index 0000000..fe2486b --- /dev/null +++ b/works/life/linux-run/linux-run-test.cpp @@ -0,0 +1,26 @@ +#include "linux-run.h" + +#include <iostream> +#include <stdexcept> + +int main() { + using namespace linux_run; + RunOptions options; + options.timeout_in_second = 1; + + bool caught_timeout_error = false; + + try { + run("./linux-run-test-bin", {}, options); + } catch (const TimeoutError &e) { + caught_timeout_error = true; + } + + if (!caught_timeout_error) { + throw std::runtime_error("Test failed. TimeoutError was not thrown."); + } else { + std::cout << "Test succeeded. TimeoutError caught.\n"; + } + + return 0; +} |