aboutsummaryrefslogtreecommitdiff
path: root/linux-run/linux-run-test.cpp
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2023-02-06 00:09:57 +0800
committercrupest <crupest@outlook.com>2023-02-06 00:09:57 +0800
commit7d41d457fe6e7433df030b4e5a3ae59093ad929d (patch)
tree1e510ac24115aec82521f4acb6fec20df256feb3 /linux-run/linux-run-test.cpp
parent65267139ce50b4b52f934b9750e5e4f718c538e6 (diff)
downloadlife-7d41d457fe6e7433df030b4e5a3ae59093ad929d.tar.gz
life-7d41d457fe6e7433df030b4e5a3ae59093ad929d.tar.bz2
life-7d41d457fe6e7433df030b4e5a3ae59093ad929d.zip
Add linux-run.
Diffstat (limited to 'linux-run/linux-run-test.cpp')
-rw-r--r--linux-run/linux-run-test.cpp26
1 files changed, 26 insertions, 0 deletions
diff --git a/linux-run/linux-run-test.cpp b/linux-run/linux-run-test.cpp
new file mode 100644
index 0000000..fe2486b
--- /dev/null
+++ b/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;
+}