Index: util/test/multiprocess_test.cc |
diff --git a/util/test/multiprocess_test.cc b/util/test/multiprocess_test.cc |
index 53b60ef0f60878061c8379e3004f40b70fd35cf9..167f6475d4661bbcaba7bd6ca35e09d56a381f80 100644 |
--- a/util/test/multiprocess_test.cc |
+++ b/util/test/multiprocess_test.cc |
@@ -14,6 +14,8 @@ |
#include "util/test/multiprocess.h" |
+#include <stdlib.h> |
+#include <sys/signal.h> |
#include <unistd.h> |
#include "base/basictypes.h" |
@@ -81,4 +83,66 @@ TEST(Multiprocess, Multiprocess) { |
multiprocess.Run(); |
} |
+class TestMultiprocessUnclean final : public Multiprocess { |
+ public: |
+ enum TerminationType { |
+ kExitSuccess = 0, |
+ kExitFailure, |
+ kExit2, |
+ kAbort, |
+ }; |
+ |
+ explicit TestMultiprocessUnclean(TerminationType type) |
+ : Multiprocess(), |
+ type_(type) { |
+ if (type_ == kAbort) { |
+ SetExpectedChildTermination(kTerminationSignal, SIGABRT); |
+ } else { |
+ SetExpectedChildTermination(kTerminationNormal, ExitCode()); |
+ } |
+ } |
+ |
+ ~TestMultiprocessUnclean() {} |
+ |
+ private: |
+ int ExitCode() const { |
+ return type_; |
+ } |
+ |
+ virtual void MultiprocessParent() override { |
+ } |
+ |
+ virtual void MultiprocessChild() override { |
+ if (type_ == kAbort) { |
+ abort(); |
+ } else { |
+ _exit(ExitCode()); |
+ } |
+ } |
+ |
+ TerminationType type_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(TestMultiprocessUnclean); |
+}; |
+ |
+TEST(Multiprocess, MultiprocessSuccessfulExit) { |
+ TestMultiprocessUnclean multiprocess(TestMultiprocessUnclean::kExitSuccess); |
+ multiprocess.Run(); |
+} |
+ |
+TEST(Multiprocess, MultiprocessUnsuccessfulExit) { |
+ TestMultiprocessUnclean multiprocess(TestMultiprocessUnclean::kExitFailure); |
+ multiprocess.Run(); |
+} |
+ |
+TEST(Multiprocess, MultiprocessExit2) { |
+ TestMultiprocessUnclean multiprocess(TestMultiprocessUnclean::kExit2); |
+ multiprocess.Run(); |
+} |
+ |
+TEST(Multiprocess, MultiprocessAbortSignal) { |
+ TestMultiprocessUnclean multiprocess(TestMultiprocessUnclean::kAbort); |
+ multiprocess.Run(); |
+} |
+ |
} // namespace |