Commit c34d0020 authored by Bruce Dawson's avatar Bruce Dawson Committed by Chromium LUCI CQ

Call PinUser32 before blocking is prohibited

The first call to PinUser32 needs to acquire the loader lock and is
therefore tagged as being a blocking call. This caused test failures
in headless_browsertests.exe because it happened to occur when blocking
calls were disallowed. Explicitly calling PinUser32 before blocking
calls are prohibited is already done in other test setups so this change
adds that to headless_test_launcher.cc and, through code inspection,
three other locations (to prevent future issues).

Bug: 1147063
Change-Id: I495602ab8f10eca0f756002afbee6d1b0417054c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2548350Reviewed-by: default avatarMike Pinkerton <pinkerton@chromium.org>
Reviewed-by: default avatarCliff Smolinsky <cliffsmo@microsoft.com>
Commit-Queue: Bruce Dawson <brucedawson@chromium.org>
Cr-Commit-Position: refs/heads/master@{#832412}
parent 0575afe8
...@@ -14,6 +14,10 @@ ...@@ -14,6 +14,10 @@
#include "ipc/ipc_channel.h" #include "ipc/ipc_channel.h"
#include "mojo/core/embedder/embedder.h" #include "mojo/core/embedder/embedder.h"
#if defined(OS_WIN)
#include "base/win/win_util.h"
#endif // defined(OS_WIN)
namespace chromecast { namespace chromecast {
namespace shell { namespace shell {
...@@ -48,6 +52,13 @@ int main(int argc, char** argv) { ...@@ -48,6 +52,13 @@ int main(int argc, char** argv) {
size_t parallel_jobs = base::NumParallelJobs(/*cores_per_job=*/2); size_t parallel_jobs = base::NumParallelJobs(/*cores_per_job=*/2);
if (parallel_jobs == 0U) if (parallel_jobs == 0U)
return 1; return 1;
#if defined(OS_WIN)
// Load and pin user32.dll to avoid having to load it once tests start while
// on the main thread loop where blocking calls are disallowed.
base::win::PinUser32();
#endif // OS_WIN
chromecast::shell::CastTestLauncherDelegate launcher_delegate; chromecast::shell::CastTestLauncherDelegate launcher_delegate;
mojo::core::Init(); mojo::core::Init();
content::ForceInProcessNetworkService(true); content::ForceInProcessNetworkService(true);
......
...@@ -4,14 +4,26 @@ ...@@ -4,14 +4,26 @@
#include "base/command_line.h" #include "base/command_line.h"
#include "base/test/launcher/test_launcher.h" #include "base/test/launcher/test_launcher.h"
#include "build/build_config.h"
#include "extensions/shell/test/shell_test_launcher_delegate.h" #include "extensions/shell/test/shell_test_launcher_delegate.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
#if defined(OS_WIN)
#include "base/win/win_util.h"
#endif // defined(OS_WIN)
int main(int argc, char** argv) { int main(int argc, char** argv) {
base::CommandLine::Init(argc, argv); base::CommandLine::Init(argc, argv);
size_t parallel_jobs = base::NumParallelJobs(/*cores_per_job=*/2); size_t parallel_jobs = base::NumParallelJobs(/*cores_per_job=*/2);
if (parallel_jobs == 0U) if (parallel_jobs == 0U)
return 1; return 1;
#if defined(OS_WIN)
// Load and pin user32.dll to avoid having to load it once tests start while
// on the main thread loop where blocking calls are disallowed.
base::win::PinUser32();
#endif // OS_WIN
extensions::AppShellTestLauncherDelegate launcher_delegate; extensions::AppShellTestLauncherDelegate launcher_delegate;
return content::LaunchTests(&launcher_delegate, parallel_jobs, argc, argv); return content::LaunchTests(&launcher_delegate, parallel_jobs, argc, argv);
} }
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#include "base/command_line.h" #include "base/command_line.h"
#include "base/macros.h" #include "base/macros.h"
#include "base/test/launcher/test_launcher.h" #include "base/test/launcher/test_launcher.h"
#include "build/build_config.h"
#include "content/public/common/content_switches.h" #include "content/public/common/content_switches.h"
#include "content/public/test/content_test_suite_base.h" #include "content/public/test/content_test_suite_base.h"
#include "content/public/test/network_service_test_helper.h" #include "content/public/test/network_service_test_helper.h"
...@@ -17,6 +18,10 @@ ...@@ -17,6 +18,10 @@
#include "headless/lib/utility/headless_content_utility_client.h" #include "headless/lib/utility/headless_content_utility_client.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
#if defined(OS_WIN)
#include "base/win/win_util.h"
#endif // defined(OS_WIN)
namespace headless { namespace headless {
namespace { namespace {
...@@ -69,6 +74,12 @@ int main(int argc, char** argv) { ...@@ -69,6 +74,12 @@ int main(int argc, char** argv) {
if (parallel_jobs == 0U) if (parallel_jobs == 0U)
return 1; return 1;
#if defined(OS_WIN)
// Load and pin user32.dll to avoid having to load it once tests start while
// on the main thread loop where blocking calls are disallowed.
base::win::PinUser32();
#endif // OS_WIN
// Setup a working test environment for the network service in case it's used. // Setup a working test environment for the network service in case it's used.
// Only create this object in the utility process, so that its members don't // Only create this object in the utility process, so that its members don't
// interfere with other test objects in the browser process. // interfere with other test objects in the browser process.
......
...@@ -4,18 +4,29 @@ ...@@ -4,18 +4,29 @@
#include "base/command_line.h" #include "base/command_line.h"
#include "base/test/launcher/test_launcher.h" #include "base/test/launcher/test_launcher.h"
#include "build/build_config.h"
#include "content/public/common/content_switches.h" #include "content/public/common/content_switches.h"
#include "content/public/test/network_service_test_helper.h" #include "content/public/test/network_service_test_helper.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
#include "weblayer/test/test_launcher_delegate_impl.h" #include "weblayer/test/test_launcher_delegate_impl.h"
#include "weblayer/utility/content_utility_client_impl.h" #include "weblayer/utility/content_utility_client_impl.h"
#if defined(OS_WIN)
#include "base/win/win_util.h"
#endif // defined(OS_WIN)
int main(int argc, char** argv) { int main(int argc, char** argv) {
base::CommandLine::Init(argc, argv); base::CommandLine::Init(argc, argv);
size_t parallel_jobs = base::NumParallelJobs(/*cores_per_job=*/1); size_t parallel_jobs = base::NumParallelJobs(/*cores_per_job=*/1);
if (parallel_jobs == 0U) if (parallel_jobs == 0U)
return 1; return 1;
#if defined(OS_WIN)
// Load and pin user32.dll to avoid having to load it once tests start while
// on the main thread loop where blocking calls are disallowed.
base::win::PinUser32();
#endif // OS_WIN
// Set up a working test environment for the network service in case it's // Set up a working test environment for the network service in case it's
// used. Only create this object in the utility process, so that its members // used. Only create this object in the utility process, so that its members
// don't interfere with other test objects in the browser process. // don't interfere with other test objects in the browser process.
......
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