summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/execute.cc2
-rw-r--r--test/execute_test.cc23
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;