diff options
author | Bent Bisballe Nyeng <deva@aasimon.org> | 2025-01-30 20:49:41 +0100 |
---|---|---|
committer | Bent Bisballe Nyeng <deva@aasimon.org> | 2025-01-30 20:56:43 +0100 |
commit | 1334ca42c672320cd7113cbcbc253cd93bf158b8 (patch) | |
tree | 2c3e48e73cc37090203df733c501158d8e63c239 /test | |
parent | 6628a2d8b18030dd3ebc714f65e7af90bd0b711a (diff) |
Correctly return errors caused bu sub-process signals such as segfaults and aborts.
Diffstat (limited to 'test')
-rw-r--r-- | test/execute_test.cc | 6 | ||||
-rw-r--r-- | test/testprog.cc | 8 |
2 files changed, 12 insertions, 2 deletions
diff --git a/test/execute_test.cc b/test/execute_test.cc index 4c686bf..722b6ea 100644 --- a/test/execute_test.cc +++ b/test/execute_test.cc @@ -35,6 +35,12 @@ public: uASSERT_EQUAL(1, value); value = execute(s, "no-such-binary", {}, {}, false); uASSERT_EQUAL(1, value); + value = execute(s, cmd, {"segfault"}, {}, false); + uASSERT_EQUAL(11, value); + value = execute(s, cmd, {"throw"}, {}, false); + uASSERT_EQUAL(6, value); + value = execute(s, cmd, {"abort"}, {}, false); + uASSERT_EQUAL(6, value); } void env() diff --git a/test/testprog.cc b/test/testprog.cc index dbfb665..faf1498 100644 --- a/test/testprog.cc +++ b/test/testprog.cc @@ -1,8 +1,7 @@ #include <iostream> #include <fstream> #include <string> - -extern const char **environ; // see 'man environ' +#include <signal.h> int main(int argc, const char* argv[]) { @@ -40,6 +39,11 @@ int main(int argc, const char* argv[]) abort(); } + if(cmd == "segfault") + { + raise(SIGSEGV); + } + if(cmd == "throw") { throw "ouch"; |