diff options
author | Bent Bisballe Nyeng <deva@aasimon.org> | 2021-09-18 19:30:26 +0200 |
---|---|---|
committer | Bent Bisballe Nyeng <deva@aasimon.org> | 2021-09-18 19:30:26 +0200 |
commit | 41ce3a4dcf5a03588b7c350445e73975c6b12ff7 (patch) | |
tree | 8392bded2d40b293ed88d11a633e0325f8dcad14 | |
parent | ba04d2889a4e017c6043bac9951f722e60b63bc5 (diff) |
Add an actual unit-test for the execute function.
-rw-r--r-- | src/execute.cc | 2 | ||||
-rw-r--r-- | test/execute_test.cc | 23 |
2 files changed, 24 insertions, 1 deletions
diff --git a/src/execute.cc b/src/execute.cc index bc4cd5f..414ce70 100644 --- a/src/execute.cc +++ b/src/execute.cc @@ -26,7 +26,7 @@ int parent_waitpid(pid_t pid) return 1; } - return status; + return WEXITSTATUS(status); } } // namespace :: diff --git a/test/execute_test.cc b/test/execute_test.cc new file mode 100644 index 0000000..e055757 --- /dev/null +++ b/test/execute_test.cc @@ -0,0 +1,23 @@ +#include <uunit.h> + +#include "../src/execute.h" + +class ExecuteTest + : public uUnit +{ +public: + ExecuteTest() + { + uTEST(ExecuteTest::runit); + } + + void runit() + { + uASSERT_EQUAL(0, execute("/bin/true", {}, false)); + uASSERT_EQUAL(1, execute("/bin/false", {}, false)); + uASSERT_EQUAL(1, execute("no-such-binary", {}, false)); + } +}; + +// Registers the fixture into the 'registry' +static ExecuteTest test; |