Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(762)

Unified Diff: util/test/multiprocess_test.cc

Issue 553153002: Add Multiprocess::SetExpectedChildTermination() (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@master
Patch Set: Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« util/test/multiprocess.h ('K') | « util/test/multiprocess.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« util/test/multiprocess.h ('K') | « util/test/multiprocess.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698