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

Unified Diff: test/win/win_multiprocess_test.cc

Issue 1164453003: Refactor multiprocess test code to allow multiple child processes to be launched. (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@multiprocess_test
Patch Set: Review comment. Created 5 years, 6 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
« no previous file with comments | « test/win/win_multiprocess.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/win/win_multiprocess_test.cc
diff --git a/test/win/win_multiprocess_test.cc b/test/win/win_multiprocess_test.cc
index eaf3d66953872c4f8d5f77a708bb5bad7527efac..19af08e9a0b2340da886be0d4c1f1c1fcb9e5caf 100644
--- a/test/win/win_multiprocess_test.cc
+++ b/test/win/win_multiprocess_test.cc
@@ -21,79 +21,62 @@ namespace crashpad {
namespace test {
namespace {
+template <int ExitCode>
class TestWinMultiprocess final : public WinMultiprocess {
public:
- explicit TestWinMultiprocess(unsigned int exit_code)
- : WinMultiprocess(), exit_code_(exit_code) {}
-
- ~TestWinMultiprocess() {}
+ TestWinMultiprocess() {}
private:
// WinMultiprocess will have already exercised the pipes.
- void WinMultiprocessParent() override {}
+ void WinMultiprocessParent() override { SetExpectedChildExitCode(ExitCode); }
void WinMultiprocessChild() override {
- exit(exit_code_);
+ exit(ExitCode);
}
- unsigned int exit_code_;
-
DISALLOW_COPY_AND_ASSIGN(TestWinMultiprocess);
};
-enum class FailureType {
- kExpect,
- kAssert,
+class TestWinMultiprocessChildAsserts final : public WinMultiprocess {
+ public:
+ TestWinMultiprocessChildAsserts() {}
+
+ private:
+ void WinMultiprocessParent() override { SetExpectedChildExitCode(255); }
+ void WinMultiprocessChild() override {
+ ASSERT_FALSE(true);
+ }
+
+ DISALLOW_COPY_AND_ASSIGN(TestWinMultiprocessChildAsserts);
};
-class TestWinMultiprocessChildFails final : public WinMultiprocess {
+class TestWinMultiprocessChildExpects final : public WinMultiprocess {
public:
- explicit TestWinMultiprocessChildFails(FailureType failure_type)
- : WinMultiprocess(), failure_type_(failure_type) {}
- ~TestWinMultiprocessChildFails() {}
+ TestWinMultiprocessChildExpects() {}
private:
- void WinMultiprocessParent() override {}
+ void WinMultiprocessParent() override { SetExpectedChildExitCode(255); }
void WinMultiprocessChild() override {
- switch (failure_type_) {
- case FailureType::kExpect:
- EXPECT_FALSE(true);
- break;
- case FailureType::kAssert:
- ASSERT_FALSE(true);
- break;
- }
+ EXPECT_FALSE(true);
}
- FailureType failure_type_;
-
- DISALLOW_COPY_AND_ASSIGN(TestWinMultiprocessChildFails);
+ DISALLOW_COPY_AND_ASSIGN(TestWinMultiprocessChildExpects);
};
-
TEST(WinMultiprocess, WinMultiprocess) {
- TestWinMultiprocess win_multiprocess(0);
- win_multiprocess.Run();
+ WinMultiprocess::Run<TestWinMultiprocess<0>>();
}
TEST(WinMultiprocess, WinMultiprocessNonSuccessExitCode) {
- TestWinMultiprocess win_multiprocess(100);
- win_multiprocess.SetExpectedChildExitCode(100);
- win_multiprocess.Run();
+ WinMultiprocess::Run<TestWinMultiprocess<100>>();
}
TEST(WinMultiprocessChildFails, ChildExpectFailure) {
- TestWinMultiprocessChildFails multiprocess_failing_child(
- FailureType::kExpect);
- multiprocess_failing_child.SetExpectedChildExitCode(255);
- multiprocess_failing_child.Run();
+ WinMultiprocess::Run<TestWinMultiprocessChildExpects>();
}
TEST(WinMultiprocessChildFails, ChildAssertFailure) {
- TestWinMultiprocessChildFails multiprocess_failing_child(
- FailureType::kAssert);
- multiprocess_failing_child.SetExpectedChildExitCode(255);
- multiprocess_failing_child.Run();
+ WinMultiprocess::Run<TestWinMultiprocessChildAsserts>();
}
} // namespace
« no previous file with comments | « test/win/win_multiprocess.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698