Index: mojo/common/test/multiprocess_test_helper.h |
diff --git a/mojo/common/test/multiprocess_test_helper.h b/mojo/common/test/multiprocess_test_helper.h |
index 103dcf4b7009441efb84fcc8ef62f937a591819e..db5450c8214c151be38baaa5fe9a94f73f12d68d 100644 |
--- a/mojo/common/test/multiprocess_test_helper.h |
+++ b/mojo/common/test/multiprocess_test_helper.h |
@@ -29,7 +29,8 @@ class MultiprocessTestHelper { |
~MultiprocessTestHelper(); |
// Start a child process and run the "main" function "named" |test_child_name| |
- // declared using |MOJO_MULTIPROCESS_TEST_CHILD_MAIN()| (below). |
+ // declared using |MOJO_MULTIPROCESS_TEST_CHILD_MAIN()| or |
+ // |MOJO_MULTIPROCESS_TEST_CHILD_TEST()| (below). |
void StartChild(const std::string& test_child_name); |
// Wait for the child process to terminate. |
// Returns the exit code of the child process. Note that, though it's declared |
@@ -39,6 +40,12 @@ class MultiprocessTestHelper { |
// 0-127 being preserved, and -1 being outside the range 0-127. |
int WaitForChildShutdown(); |
+ // Like |WaitForChildShutdown()|, but returns true on success (exit code of 0) |
+ // and false otherwise. You probably want to do something like |
+ // |EXPECT_TRUE(WaitForChildTestShutdown());|. Mainly for use with |
+ // |MOJO_MULTIPROCESS_TEST_CHILD_TEST()|. |
+ bool WaitForChildTestShutdown(); |
+ |
// For use by |MOJO_MULTIPROCESS_TEST_CHILD_MAIN()| only: |
static void ChildSetup(); |
@@ -65,6 +72,19 @@ class MultiprocessTestHelper { |
test_child_name ## TestChildMain, \ |
::mojo::test::MultiprocessTestHelper::ChildSetup) |
+// Use this (and |WaitForChildTestShutdown()|) for the child process's "main()", |
+// if you want to use |EXPECT_...()| or |ASSERT_...()|; it has a |void| return |
+// type. (Note that while an |ASSERT_...()| failure will abort the test in the |
+// child, it will not abort the test in the parent.) |
+#define MOJO_MULTIPROCESS_TEST_CHILD_TEST(test_child_name) \ |
+ void test_child_name ## TestChildTest(); \ |
+ MOJO_MULTIPROCESS_TEST_CHILD_MAIN(test_child_name) { \ |
+ test_child_name ## TestChildTest(); \ |
+ return (::testing::Test::HasFatalFailure() || \ |
+ ::testing::Test::HasNonfatalFailure()) ? 1 : 0; \ |
+ } \ |
+ void test_child_name ## TestChildTest() |
+ |
} // namespace test |
} // namespace mojo |