Commit 3baed341 authored by Greg Thompson's avatar Greg Thompson Committed by Commit Bot

Diagnose FileUtilTest.ReadFileToStringWithNamedPipe flakes.

ConnectNamedPipe in the child proc is failing sometimes. It's entirely
possible that it's failing with ERROR_PIPE_CONNECTED (535), in which
case we should treat this as success. This CL will include the error
code in the failure log so that we know what's really going on.

This CL also improves multiprocess child proc diagnosability by getting
stacks from GTest when things go awry in the child.

BUG=none

Change-Id: I3befc4ebd596251e3f61a855dc83188f1efc2619
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2174580Reviewed-by: default avatarFrançois Doray <fdoray@chromium.org>
Reviewed-by: default avatarDirk Pranke <dpranke@chromium.org>
Commit-Queue: Greg Thompson <grt@chromium.org>
Cr-Commit-Position: refs/heads/master@{#765422}
parent 983836cd
...@@ -3316,7 +3316,9 @@ MULTIPROCESS_TEST_MAIN(ChildMain) { ...@@ -3316,7 +3316,9 @@ MULTIPROCESS_TEST_MAIN(ChildMain) {
PIPE_WAIT, 1, 0, 0, 0, NULL); PIPE_WAIT, 1, 0, 0, 0, NULL);
EXPECT_NE(ph, INVALID_HANDLE_VALUE); EXPECT_NE(ph, INVALID_HANDLE_VALUE);
EXPECT_TRUE(SetEvent(sync_event.Get())); EXPECT_TRUE(SetEvent(sync_event.Get()));
::SetLastError(0);
EXPECT_TRUE(ConnectNamedPipe(ph, NULL)); EXPECT_TRUE(ConnectNamedPipe(ph, NULL));
EXPECT_EQ(::GetLastError(), 0U);
DWORD written; DWORD written;
EXPECT_TRUE(::WriteFile(ph, kTestData, strlen(kTestData), &written, NULL)); EXPECT_TRUE(::WriteFile(ph, kTestData, strlen(kTestData), &written, NULL));
......
...@@ -6,6 +6,8 @@ ...@@ -6,6 +6,8 @@
#include <map> #include <map>
#include "third_party/googletest/src/googletest/src/gtest-internal-inl.h"
// Helper functions to maintain mapping of "test name"->test func. // Helper functions to maintain mapping of "test name"->test func.
// The information is accessed via a global map. // The information is accessed via a global map.
namespace multi_process_function_list { namespace multi_process_function_list {
...@@ -41,14 +43,19 @@ AppendMultiProcessTest::AppendMultiProcessTest( ...@@ -41,14 +43,19 @@ AppendMultiProcessTest::AppendMultiProcessTest(
} }
int InvokeChildProcessTest(const std::string& test_name) { int InvokeChildProcessTest(const std::string& test_name) {
auto* const impl = ::testing::internal::GetUnitTestImpl();
MultiProcessTestMap& func_lookup_table = GetMultiprocessFuncMap(); MultiProcessTestMap& func_lookup_table = GetMultiprocessFuncMap();
MultiProcessTestMap::iterator it = func_lookup_table.find(test_name); MultiProcessTestMap::iterator it = func_lookup_table.find(test_name);
if (it != func_lookup_table.end()) { if (it != func_lookup_table.end()) {
const ProcessFunctions& process_functions = it->second; const ProcessFunctions& process_functions = it->second;
if (process_functions.setup) if (process_functions.setup) {
impl->os_stack_trace_getter()->UponLeavingGTest();
(*process_functions.setup)(); (*process_functions.setup)();
if (process_functions.main) }
if (process_functions.main) {
impl->os_stack_trace_getter()->UponLeavingGTest();
return (*process_functions.main)(); return (*process_functions.main)();
}
} }
return -1; return -1;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment