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

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: Add coverage. 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
« test/win/win_child_process.cc ('K') | « 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..87916c6d8126b86bc6731394b64dc543bf4c57f6 100644
--- a/test/win/win_multiprocess_test.cc
+++ b/test/win/win_multiprocess_test.cc
@@ -21,23 +21,20 @@ namespace crashpad {
namespace test {
namespace {
+template <int exit_code>
scottmg 2015/06/25 04:13:25 exit_code -> ExitCode
erikwright (departed) 2015/06/25 14:36:02 Done.
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(exit_code); }
void WinMultiprocessChild() override {
- exit(exit_code_);
+ exit(exit_code);
}
- unsigned int exit_code_;
-
DISALLOW_COPY_AND_ASSIGN(TestWinMultiprocess);
};
@@ -46,16 +43,16 @@ enum class FailureType {
kAssert,
};
+template <FailureType failure_type>
scottmg 2015/06/25 04:13:25 similar
erikwright (departed) 2015/06/25 14:36:02 In the end I thought a non-template approach might
class TestWinMultiprocessChildFails final : public WinMultiprocess {
public:
- explicit TestWinMultiprocessChildFails(FailureType failure_type)
- : WinMultiprocess(), failure_type_(failure_type) {}
+ TestWinMultiprocessChildFails() {}
~TestWinMultiprocessChildFails() {}
private:
- void WinMultiprocessParent() override {}
+ void WinMultiprocessParent() override { SetExpectedChildExitCode(255); }
void WinMultiprocessChild() override {
- switch (failure_type_) {
+ switch (failure_type) {
case FailureType::kExpect:
EXPECT_FALSE(true);
break;
@@ -65,35 +62,24 @@ class TestWinMultiprocessChildFails final : public WinMultiprocess {
}
}
- FailureType failure_type_;
-
DISALLOW_COPY_AND_ASSIGN(TestWinMultiprocessChildFails);
};
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<TestWinMultiprocessChildFails<FailureType::kExpect>>();
}
TEST(WinMultiprocessChildFails, ChildAssertFailure) {
- TestWinMultiprocessChildFails multiprocess_failing_child(
- FailureType::kAssert);
- multiprocess_failing_child.SetExpectedChildExitCode(255);
- multiprocess_failing_child.Run();
+ WinMultiprocess::Run<TestWinMultiprocessChildFails<FailureType::kAssert>>();
}
} // namespace
« test/win/win_child_process.cc ('K') | « test/win/win_multiprocess.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698