Commit 1242f4e1 authored by Kenneth Russell's avatar Kenneth Russell Committed by Commit Bot

Revert "[base] Ensure that tests don't change the process priority (reland)."

This reverts commit b3c8de73.

Reason for revert: broke ANGLE CQ, e.g.:
https://ci.chromium.org/p/chromium/builders/ci/Win7%20FYI%20dEQP%20Release%20%28AMD%29/58198?blamelist=1#blamelist-tab
https://ci.chromium.org/p/chromium/builders/try/win-angle-deqp-rel-32/328


Original change's description:
> [base] Ensure that tests don't change the process priority (reland).
> 
> The original CL
> https://chromium-review.googlesource.com/c/chromium/src/+/1679434
> was reverted because of failures on test end on Mac OS 10.11.
> This CL simply disables that check on Mac, so we can benefit from
> process priority check on other platforms ASAP.
> See diff:
> https://chromium-review.googlesource.com/c/chromium/src/+/1760873/2..3/base/test/test_suite.cc
> 
> This CL verifies that a test process is not backgrounded when it is
> launched and before/after each test. The goal is to avoid having tests
> that assume they run at normal priority be disabled because of other
> misbehaving tests (e.g. https://crbug.com/931721).
> 
> Bug: 931721
> Change-Id: Ib60d728c960f84026c84f24395d38847c1941573
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1760873
> Reviewed-by: Gabriel Charette <gab@chromium.org>
> Commit-Queue: Gabriel Charette <gab@chromium.org>
> Auto-Submit: François Doray <fdoray@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#688201}

TBR=gab@chromium.org,fdoray@chromium.org

Change-Id: I8b7bf8c348390c774eda6943609244b1f87f49b7
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: 931721
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1761517Reviewed-by: default avatarKenneth Russell <kbr@chromium.org>
Commit-Queue: Kenneth Russell <kbr@chromium.org>
Cr-Commit-Position: refs/heads/master@{#688335}
parent f59a5ac5
...@@ -27,8 +27,6 @@ ...@@ -27,8 +27,6 @@
#include "base/path_service.h" #include "base/path_service.h"
#include "base/process/launch.h" #include "base/process/launch.h"
#include "base/process/memory.h" #include "base/process/memory.h"
#include "base/process/process.h"
#include "base/process/process_handle.h"
#include "base/task/thread_pool/thread_pool.h" #include "base/task/thread_pool/thread_pool.h"
#include "base/test/gtest_xml_unittest_result_printer.h" #include "base/test/gtest_xml_unittest_result_printer.h"
#include "base/test/gtest_xml_util.h" #include "base/test/gtest_xml_util.h"
...@@ -45,7 +43,6 @@ ...@@ -45,7 +43,6 @@
#if defined(OS_MACOSX) #if defined(OS_MACOSX)
#include "base/mac/scoped_nsautorelease_pool.h" #include "base/mac/scoped_nsautorelease_pool.h"
#include "base/process/port_provider_mac.h"
#if defined(OS_IOS) #if defined(OS_IOS)
#include "base/test/test_listener_ios.h" #include "base/test/test_listener_ios.h"
#endif // OS_IOS #endif // OS_IOS
...@@ -147,47 +144,6 @@ class CheckForLeakedGlobals : public testing::EmptyTestEventListener { ...@@ -147,47 +144,6 @@ class CheckForLeakedGlobals : public testing::EmptyTestEventListener {
DISALLOW_COPY_AND_ASSIGN(CheckForLeakedGlobals); DISALLOW_COPY_AND_ASSIGN(CheckForLeakedGlobals);
}; };
// base::Process is not available on iOS
#if !defined(OS_IOS)
class CheckProcessPriority : public testing::EmptyTestEventListener {
public:
CheckProcessPriority() { CHECK(!IsProcessBackgrounded()); }
void OnTestStart(const testing::TestInfo& test) override {
EXPECT_FALSE(IsProcessBackgrounded());
}
void OnTestEnd(const testing::TestInfo& test) override {
#if !defined(OS_MACOSX)
// Flakes are found on Mac OS 10.11. See https://crbug.com/931721#c7.
EXPECT_FALSE(IsProcessBackgrounded());
#endif
}
private:
#if defined(OS_MACOSX)
// Returns the calling process's task port, ignoring its argument.
class CurrentProcessPortProvider : public PortProvider {
mach_port_t TaskForPid(ProcessHandle process) const override {
// This PortProvider implementation only works for the current process.
CHECK_EQ(process, base::GetCurrentProcessHandle());
return mach_task_self();
}
};
#endif
bool IsProcessBackgrounded() const {
#if defined(OS_MACOSX)
CurrentProcessPortProvider port_provider;
return Process::Current().IsProcessBackgrounded(&port_provider);
#else
return Process::Current().IsProcessBackgrounded();
#endif
}
DISALLOW_COPY_AND_ASSIGN(CheckProcessPriority);
};
#endif // !defined(OS_IOS)
const std::string& GetProfileName() { const std::string& GetProfileName() {
static const NoDestructor<std::string> profile_name([]() { static const NoDestructor<std::string> profile_name([]() {
const CommandLine& command_line = *CommandLine::ForCurrentProcess(); const CommandLine& command_line = *CommandLine::ForCurrentProcess();
...@@ -232,7 +188,7 @@ void InitializeLogging() { ...@@ -232,7 +188,7 @@ void InitializeLogging() {
} // namespace } // namespace
int RunUnitTestsUsingBaseTestSuite(int argc, char** argv) { int RunUnitTestsUsingBaseTestSuite(int argc, char **argv) {
TestSuite test_suite(argc, argv); TestSuite test_suite(argc, argv);
return LaunchUnitTests(argc, argv, return LaunchUnitTests(argc, argv,
BindOnce(&TestSuite::Run, Unretained(&test_suite))); BindOnce(&TestSuite::Run, Unretained(&test_suite)));
...@@ -445,8 +401,9 @@ void AbortHandler(int signal) { ...@@ -445,8 +401,9 @@ void AbortHandler(int signal) {
void TestSuite::SuppressErrorDialogs() { void TestSuite::SuppressErrorDialogs() {
#if defined(OS_WIN) #if defined(OS_WIN)
UINT new_flags = UINT new_flags = SEM_FAILCRITICALERRORS |
SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX | SEM_NOOPENFILEERRORBOX; SEM_NOGPFAULTERRORBOX |
SEM_NOOPENFILEERRORBOX;
// Preserve existing error mode, as discussed at // Preserve existing error mode, as discussed at
// http://blogs.msdn.com/oldnewthing/archive/2004/07/27/198410.aspx // http://blogs.msdn.com/oldnewthing/archive/2004/07/27/198410.aspx
...@@ -562,9 +519,6 @@ void TestSuite::Initialize() { ...@@ -562,9 +519,6 @@ void TestSuite::Initialize() {
listeners.Append(new ResetCommandLineBetweenTests); listeners.Append(new ResetCommandLineBetweenTests);
if (check_for_leaked_globals_) if (check_for_leaked_globals_)
listeners.Append(new CheckForLeakedGlobals); listeners.Append(new CheckForLeakedGlobals);
#if !defined(OS_IOS)
listeners.Append(new CheckProcessPriority);
#endif
AddTestLauncherResultPrinter(); AddTestLauncherResultPrinter();
......
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