diff options
Diffstat (limited to 'test/execute_test.cc')
-rw-r--r-- | test/execute_test.cc | 26 |
1 files changed, 23 insertions, 3 deletions
diff --git a/test/execute_test.cc b/test/execute_test.cc index 4c686bf..3cdb309 100644 --- a/test/execute_test.cc +++ b/test/execute_test.cc @@ -23,6 +23,13 @@ public: void return_value() { +#if defined(_WIN32) + constexpr int segfault_return_value = 3; + constexpr int exception_return_value = 0xC0000409; +#else + constexpr int segfault_return_value = 11; + constexpr int exception_return_value = 6; +#endif ctor::settings s; auto cur_path = std::filesystem::path(paths::argv_0).parent_path(); std::vector<std::string> paths{{cur_path.string()}}; @@ -31,10 +38,21 @@ public: auto value = execute(s, cmd, {"retval", "0"}, {}, false); uASSERT_EQUAL(0, value); + value = execute(s, cmd, {"retval", "1"}, {}, false); uASSERT_EQUAL(1, value); + value = execute(s, "no-such-binary", {}, {}, false); uASSERT_EQUAL(1, value); + + value = execute(s, cmd, {"segfault"}, {}, false); + uASSERT_EQUAL(segfault_return_value, value); + + value = execute(s, cmd, {"throw"}, {}, false); + uASSERT_EQUAL(exception_return_value, value); + + value = execute(s, cmd, {"abort"}, {}, false); + uASSERT_EQUAL(exception_return_value, value); } void env() @@ -47,7 +65,7 @@ public: auto cmd = locate("testprog", paths); uASSERT(!cmd.empty()); - tmp_file tmp; + TmpFile tmp; std::map<std::string, std::string> env; @@ -77,11 +95,13 @@ public: chk = std::find(vars.begin(), vars.end(), "bar=42"s); uASSERT(chk != vars.end()); - // Check the one that should have overwritten the existing one (probably LANG=en_US.UTF-8 or something) + // Check the one that should have overwritten the existing one (probably + // LANG=en_US.UTF-8 or something) chk = std::find(vars.begin(), vars.end(), "LANG=foo"s); uASSERT(chk != vars.end()); - // Check that other vars are also there (ie. the env wasn't cleared on entry) + // Check that other vars are also there (ie. the env wasn't cleared on + // entry) uASSERT(vars.size() > 3); } }; |