Commit 5006dbfb authored by Greg Thompson's avatar Greg Thompson Committed by Commit Bot

Fix use of ConnectNamedPipe in FileUtilTest.ReadFileToStringWithNamedPipe.

ConnectNamedPipe returns false with a specific error code if the other
end of the pipe is already open. This is not a failure.

This is a partial revert of commit 3baed341.

BUG=none
R=dpranke@chromium.org, fdoray@chromium.org

Change-Id: Iaba28fd35e1b7435392ea5d1194bdd5f477ce3b8
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2187496
Commit-Queue: Dirk Pranke <dpranke@chromium.org>
Reviewed-by: default avatarFrançois Doray <fdoray@chromium.org>
Reviewed-by: default avatarDirk Pranke <dpranke@chromium.org>
Auto-Submit: Greg Thompson <grt@chromium.org>
Cr-Commit-Position: refs/heads/master@{#766547}
parent f528ce0d
...@@ -3308,9 +3308,11 @@ MULTIPROCESS_TEST_MAIN(ChildMain) { ...@@ -3308,9 +3308,11 @@ 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); if (!::ConnectNamedPipe(ph, /*lpOverlapped=*/nullptr)) {
EXPECT_TRUE(ConnectNamedPipe(ph, NULL)); // ERROR_PIPE_CONNECTED means that the other side has already connected.
EXPECT_EQ(::GetLastError(), 0U); auto error = ::GetLastError();
EXPECT_EQ(error, DWORD{ERROR_PIPE_CONNECTED});
}
DWORD written; DWORD written;
EXPECT_TRUE(::WriteFile(ph, kTestData, strlen(kTestData), &written, NULL)); EXPECT_TRUE(::WriteFile(ph, kTestData, strlen(kTestData), &written, NULL));
...@@ -3337,7 +3339,11 @@ MULTIPROCESS_TEST_MAIN(MoreThanBufferSizeChildMain) { ...@@ -3337,7 +3339,11 @@ MULTIPROCESS_TEST_MAIN(MoreThanBufferSizeChildMain) {
PIPE_WAIT, 1, data.size(), data.size(), 0, NULL); PIPE_WAIT, 1, data.size(), data.size(), 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()));
EXPECT_TRUE(ConnectNamedPipe(ph, NULL)); if (!::ConnectNamedPipe(ph, /*lpOverlapped=*/nullptr)) {
// ERROR_PIPE_CONNECTED means that the other side has already connected.
auto error = ::GetLastError();
EXPECT_EQ(error, DWORD{ERROR_PIPE_CONNECTED});
}
DWORD written; DWORD written;
EXPECT_TRUE(::WriteFile(ph, data.c_str(), data.size(), &written, NULL)); EXPECT_TRUE(::WriteFile(ph, data.c_str(), data.size(), &written, NULL));
......
...@@ -6,8 +6,6 @@ ...@@ -6,8 +6,6 @@
#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 {
...@@ -43,19 +41,14 @@ AppendMultiProcessTest::AppendMultiProcessTest( ...@@ -43,19 +41,14 @@ 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