win: Dynamically disable WoW64 tests absent explicit 32-bit build output

Rather than having the 64-bit build assume that it lives in
out\{Debug,Release}_x64 and that it can find 32-bit build output in
out\{Debug,Release}, require the location of 32-bit build output to be
provided explicitly via the CRASHPAD_TEST_32_BIT_OUTPUT environment
variable. If this variable is not set, 64-bit tests that require 32-bit
test build output will dynamically disable themselves at runtime.

In order for this to work, a new DISABLED_TEST() macro is added to
support dynamically disabled tests. gtest does not have its own
first-class support for this
(https://groups.google.com/d/topic/googletestframework/Nwh3u7YFuN4,
https://github.com/google/googletest/issues/490) so this local solution
is used instead.

For tests via Crashpad’s own build\run_tests.py, which is how Crashpad’s
own buildbots and trybots invoke tests, CRASHPAD_TEST_32_BIT_OUTPUT is
set to a locaton compatible with the paths expected for the GYP-based
build. No test coverage is lost on Crashpad’s own buildbots and trybots.

For Crashpad tests in Chromium’s buildbots and trybots, this environment
variable will not be set, causing these tests to be dynamically
disabled.

Bug: crashpad:203, chromium:743139, chromium:777924
Change-Id: I3c0de2bf4f835e13ed5a4adda5760d6fed508126
Reviewed-on: https://chromium-review.googlesource.com/739795
Commit-Queue: Mark Mentovai <mark@chromium.org>
Reviewed-by: Scott Graham <scottmg@chromium.org>
This commit is contained in:
Mark Mentovai 2017-10-26 13:48:01 -04:00 committed by Commit Bot
parent 34699d378b
commit 5e9ed4cb9f
14 changed files with 336 additions and 99 deletions

View File

@ -1,4 +1,5 @@
#!/usr/bin/env python
# coding: utf-8
# Copyright 2014 The Crashpad Authors. All rights reserved.
#
@ -31,6 +32,18 @@ def main(args):
os.path.join(os.path.dirname(os.path.abspath(__file__)), os.pardir)
binary_dir = args[0]
# Tell 64-bit Windows tests where to find 32-bit test executables, for
# cross-bitted testing. This relies on the fact that the GYP build by default
# uses {Debug,Release} for the 32-bit build and {Debug,Release}_x64 for the
# 64-bit build. This is not a universally valid assumption, and if its not
# met, 64-bit tests that require 32-bit build output will disable themselves
# dynamically.
if (sys.platform == 'win32' and binary_dir.endswith('_x64') and
'CRASHPAD_TEST_32_BIT_OUTPUT' not in os.environ):
binary_dir_32 = binary_dir[:-4]
if os.path.isdir(binary_dir_32):
os.environ['CRASHPAD_TEST_32_BIT_OUTPUT'] = binary_dir_32
tests = [
'crashpad_client_test',
'crashpad_minidump_test',

View File

@ -462,7 +462,7 @@ def main(args):
return 1
z7_dump_path = None
if not args[0].endswith('x64'):
if not args[0].endswith('_x64'):
z7_dump_path = GetDumpFromZ7Program(args[0], pipe_name)
if not z7_dump_path:
return 1

View File

@ -23,6 +23,7 @@
#include "gtest/gtest.h"
#include "snapshot/win/process_snapshot_win.h"
#include "test/errors.h"
#include "test/gtest_disabled.h"
#include "test/test_paths.h"
#include "test/win/child_launcher.h"
#include "util/file/file_io.h"
@ -120,7 +121,7 @@ class CrashingDelegate : public ExceptionHandlerServer::Delegate {
DISALLOW_COPY_AND_ASSIGN(CrashingDelegate);
};
void TestCrashingChild(const base::string16& directory_modification) {
void TestCrashingChild(const base::FilePath& directory) {
// Set up the registration server on a background thread.
ScopedKernelHANDLE server_ready(CreateEvent(nullptr, false, false, nullptr));
ASSERT_TRUE(server_ready.is_valid()) << ErrorMessage("CreateEvent");
@ -140,13 +141,13 @@ void TestCrashingChild(const base::string16& directory_modification) {
<< ErrorMessage("WaitForSingleObject");
// Spawn a child process, passing it the pipe name to connect to.
base::FilePath test_executable = TestPaths::Executable();
std::wstring child_test_executable =
test_executable.DirName()
.Append(directory_modification)
.Append(test_executable.BaseName().RemoveFinalExtension().value() +
L"_crashing_child.exe")
.value();
std::wstring child_test_executable = directory
.Append(TestPaths::Executable()
.BaseName()
.RemoveFinalExtension()
.value() +
L"_crashing_child.exe")
.value();
ChildLauncher child(child_test_executable, pipe_name);
ASSERT_NO_FATAL_FAILURE(child.Start());
@ -165,16 +166,17 @@ void TestCrashingChild(const base::string16& directory_modification) {
}
TEST(ExceptionSnapshotWinTest, ChildCrash) {
TestCrashingChild(FILE_PATH_LITERAL("."));
TestCrashingChild(TestPaths::Executable().DirName());
}
#if defined(ARCH_CPU_64_BITS)
TEST(ExceptionSnapshotWinTest, ChildCrashWOW64) {
#ifndef NDEBUG
TestCrashingChild(FILE_PATH_LITERAL("..\\..\\out\\Debug"));
#else
TestCrashingChild(FILE_PATH_LITERAL("..\\..\\out\\Release"));
#endif
base::FilePath output_32_bit_directory = TestPaths::Output32BitDirectory();
if (output_32_bit_directory.empty()) {
DISABLED_TEST();
}
TestCrashingChild(output_32_bit_directory);
}
#endif // ARCH_CPU_64_BITS
@ -227,8 +229,7 @@ class SimulateDelegate : public ExceptionHandlerServer::Delegate {
DISALLOW_COPY_AND_ASSIGN(SimulateDelegate);
};
void TestDumpWithoutCrashingChild(
const base::string16& directory_modification) {
void TestDumpWithoutCrashingChild(const base::FilePath& directory) {
// Set up the registration server on a background thread.
ScopedKernelHANDLE server_ready(CreateEvent(nullptr, false, false, nullptr));
ASSERT_TRUE(server_ready.is_valid()) << ErrorMessage("CreateEvent");
@ -248,11 +249,12 @@ void TestDumpWithoutCrashingChild(
<< ErrorMessage("WaitForSingleObject");
// Spawn a child process, passing it the pipe name to connect to.
base::FilePath test_executable = TestPaths::Executable();
std::wstring child_test_executable =
test_executable.DirName()
.Append(directory_modification)
.Append(test_executable.BaseName().RemoveFinalExtension().value() +
directory
.Append(TestPaths::Executable()
.BaseName()
.RemoveFinalExtension()
.value() +
L"_dump_without_crashing.exe")
.value();
ChildLauncher child(child_test_executable, pipe_name);
@ -273,16 +275,17 @@ void TestDumpWithoutCrashingChild(
}
TEST(SimulateCrash, ChildDumpWithoutCrashing) {
TestDumpWithoutCrashingChild(FILE_PATH_LITERAL("."));
TestDumpWithoutCrashingChild(TestPaths::Executable().DirName());
}
#if defined(ARCH_CPU_64_BITS)
TEST(SimulateCrash, ChildDumpWithoutCrashingWOW64) {
#ifndef NDEBUG
TestDumpWithoutCrashingChild(FILE_PATH_LITERAL("..\\..\\out\\Debug"));
#else
TestDumpWithoutCrashingChild(FILE_PATH_LITERAL("..\\..\\out\\Release"));
#endif
base::FilePath output_32_bit_directory = TestPaths::Output32BitDirectory();
if (output_32_bit_directory.empty()) {
DISABLED_TEST();
}
TestDumpWithoutCrashingChild(output_32_bit_directory);
}
#endif // ARCH_CPU_64_BITS

View File

@ -25,6 +25,7 @@
#include "client/simple_address_range_bag.h"
#include "gtest/gtest.h"
#include "snapshot/win/process_snapshot_win.h"
#include "test/gtest_disabled.h"
#include "test/test_paths.h"
#include "test/win/child_launcher.h"
#include "util/file/file_io.h"
@ -42,16 +43,15 @@ enum TestType {
kCrashDebugBreak,
};
void TestExtraMemoryRanges(TestType type,
const base::string16& directory_modification) {
void TestExtraMemoryRanges(TestType type, const base::FilePath& directory) {
// Spawn a child process, passing it the pipe name to connect to.
base::FilePath test_executable = TestPaths::Executable();
std::wstring child_test_executable =
test_executable.DirName()
.Append(directory_modification)
.Append(test_executable.BaseName().RemoveFinalExtension().value() +
L"_extra_memory_ranges.exe")
.value();
std::wstring child_test_executable = directory
.Append(TestPaths::Executable()
.BaseName()
.RemoveFinalExtension()
.value() +
L"_extra_memory_ranges.exe")
.value();
ChildLauncher child(child_test_executable, L"");
ASSERT_NO_FATAL_FAILURE(child.Start());
@ -101,30 +101,30 @@ void TestExtraMemoryRanges(TestType type,
}
TEST(ExtraMemoryRanges, DontCrash) {
TestExtraMemoryRanges(kDontCrash, FILE_PATH_LITERAL("."));
TestExtraMemoryRanges(kDontCrash, TestPaths::Executable().DirName());
}
TEST(ExtraMemoryRanges, CrashDebugBreak) {
TestExtraMemoryRanges(kCrashDebugBreak, FILE_PATH_LITERAL("."));
TestExtraMemoryRanges(kCrashDebugBreak, TestPaths::Executable().DirName());
}
#if defined(ARCH_CPU_64_BITS)
TEST(ExtraMemoryRanges, DontCrashWOW64) {
#ifndef NDEBUG
TestExtraMemoryRanges(kDontCrash, FILE_PATH_LITERAL("..\\..\\out\\Debug"));
#else
TestExtraMemoryRanges(kDontCrash, FILE_PATH_LITERAL("..\\..\\out\\Release"));
#endif
base::FilePath output_32_bit_directory = TestPaths::Output32BitDirectory();
if (output_32_bit_directory.empty()) {
DISABLED_TEST();
}
TestExtraMemoryRanges(kDontCrash, output_32_bit_directory);
}
TEST(ExtraMemoryRanges, CrashDebugBreakWOW64) {
#ifndef NDEBUG
TestExtraMemoryRanges(kCrashDebugBreak,
FILE_PATH_LITERAL("..\\..\\out\\Debug"));
#else
TestExtraMemoryRanges(kCrashDebugBreak,
FILE_PATH_LITERAL("..\\..\\out\\Release"));
#endif
base::FilePath output_32_bit_directory = TestPaths::Output32BitDirectory();
if (output_32_bit_directory.empty()) {
DISABLED_TEST();
}
TestExtraMemoryRanges(kCrashDebugBreak, output_32_bit_directory);
}
#endif // ARCH_CPU_64_BITS

View File

@ -29,6 +29,7 @@
#include "gtest/gtest.h"
#include "snapshot/win/pe_image_reader.h"
#include "snapshot/win/process_reader_win.h"
#include "test/gtest_disabled.h"
#include "test/test_paths.h"
#include "test/win/child_launcher.h"
#include "util/file/file_io.h"
@ -46,16 +47,15 @@ enum TestType {
kCrashDebugBreak,
};
void TestAnnotationsOnCrash(TestType type,
const base::string16& directory_modification) {
void TestAnnotationsOnCrash(TestType type, const base::FilePath& directory) {
// Spawn a child process, passing it the pipe name to connect to.
base::FilePath test_executable = TestPaths::Executable();
std::wstring child_test_executable =
test_executable.DirName()
.Append(directory_modification)
.Append(test_executable.BaseName().RemoveFinalExtension().value() +
L"_simple_annotations.exe")
.value();
std::wstring child_test_executable = directory
.Append(TestPaths::Executable()
.BaseName()
.RemoveFinalExtension()
.value() +
L"_simple_annotations.exe")
.value();
ChildLauncher child(child_test_executable, L"");
ASSERT_NO_FATAL_FAILURE(child.Start());
@ -112,30 +112,30 @@ void TestAnnotationsOnCrash(TestType type,
}
TEST(PEImageAnnotationsReader, DontCrash) {
TestAnnotationsOnCrash(kDontCrash, FILE_PATH_LITERAL("."));
TestAnnotationsOnCrash(kDontCrash, TestPaths::Executable().DirName());
}
TEST(PEImageAnnotationsReader, CrashDebugBreak) {
TestAnnotationsOnCrash(kCrashDebugBreak, FILE_PATH_LITERAL("."));
TestAnnotationsOnCrash(kCrashDebugBreak, TestPaths::Executable().DirName());
}
#if defined(ARCH_CPU_64_BITS)
TEST(PEImageAnnotationsReader, DontCrashWOW64) {
#ifndef NDEBUG
TestAnnotationsOnCrash(kDontCrash, FILE_PATH_LITERAL("..\\..\\out\\Debug"));
#else
TestAnnotationsOnCrash(kDontCrash, FILE_PATH_LITERAL("..\\..\\out\\Release"));
#endif
base::FilePath output_32_bit_directory = TestPaths::Output32BitDirectory();
if (output_32_bit_directory.empty()) {
DISABLED_TEST();
}
TestAnnotationsOnCrash(kDontCrash, output_32_bit_directory);
}
TEST(PEImageAnnotationsReader, CrashDebugBreakWOW64) {
#ifndef NDEBUG
TestAnnotationsOnCrash(kCrashDebugBreak,
FILE_PATH_LITERAL("..\\..\\out\\Debug"));
#else
TestAnnotationsOnCrash(kCrashDebugBreak,
FILE_PATH_LITERAL("..\\..\\out\\Release"));
#endif
base::FilePath output_32_bit_directory = TestPaths::Output32BitDirectory();
if (output_32_bit_directory.empty()) {
DISABLED_TEST();
}
TestAnnotationsOnCrash(kCrashDebugBreak, output_32_bit_directory);
}
#endif // ARCH_CPU_64_BITS

View File

@ -20,6 +20,7 @@
#include "snapshot/win/pe_image_reader.h"
#include "snapshot/win/process_reader_win.h"
#include "test/errors.h"
#include "test/gtest_disabled.h"
#include "test/test_paths.h"
#include "test/win/child_launcher.h"
#include "util/file/file_io.h"
@ -30,20 +31,20 @@ namespace crashpad {
namespace test {
namespace {
void TestImageReaderChild(const base::string16& directory_modification) {
void TestImageReaderChild(const base::FilePath& directory) {
UUID done_uuid;
done_uuid.InitializeWithNew();
ScopedKernelHANDLE done(
CreateEvent(nullptr, true, false, done_uuid.ToString16().c_str()));
ASSERT_TRUE(done.is_valid()) << ErrorMessage("CreateEvent");
base::FilePath test_executable = TestPaths::Executable();
std::wstring child_test_executable =
test_executable.DirName()
.Append(directory_modification)
.Append(test_executable.BaseName().RemoveFinalExtension().value() +
L"_image_reader.exe")
.value();
std::wstring child_test_executable = directory
.Append(TestPaths::Executable()
.BaseName()
.RemoveFinalExtension()
.value() +
L"_image_reader.exe")
.value();
ChildLauncher child(child_test_executable, done_uuid.ToString16());
ASSERT_NO_FATAL_FAILURE(child.Start());
@ -112,16 +113,17 @@ void TestImageReaderChild(const base::string16& directory_modification) {
}
TEST(ProcessSnapshotTest, CrashpadInfoChild) {
TestImageReaderChild(FILE_PATH_LITERAL("."));
TestImageReaderChild(TestPaths::Executable().DirName());
}
#if defined(ARCH_CPU_64_BITS)
TEST(ProcessSnapshotTest, CrashpadInfoChildWOW64) {
#ifndef NDEBUG
TestImageReaderChild(FILE_PATH_LITERAL("..\\..\\out\\Debug"));
#else
TestImageReaderChild(FILE_PATH_LITERAL("..\\..\\out\\Release"));
#endif
base::FilePath output_32_bit_directory = TestPaths::Output32BitDirectory();
if (output_32_bit_directory.empty()) {
DISABLED_TEST();
}
TestImageReaderChild(output_32_bit_directory);
}
#endif

View File

@ -14,10 +14,13 @@
#include "gmock/gmock.h"
#include "gtest/gtest.h"
#include "test/gtest_disabled.h"
#include "test/main_arguments.h"
int main(int argc, char* argv[]) {
crashpad::test::InitializeMainArguments(argc, argv);
testing::InitGoogleMock(&argc, argv);
testing::AddGlobalTestEnvironment(
crashpad::test::DisabledTestGtestEnvironment::Get());
return RUN_ALL_TESTS();
}

83
test/gtest_disabled.cc Normal file
View File

@ -0,0 +1,83 @@
// Copyright 2017 The Crashpad Authors. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include "test/gtest_disabled.h"
#include <stdio.h>
#include "base/format_macros.h"
#include "base/logging.h"
#include "base/strings/stringprintf.h"
namespace crashpad {
namespace test {
namespace {
DisabledTestGtestEnvironment* g_instance;
} // namespace
// static
DisabledTestGtestEnvironment* DisabledTestGtestEnvironment::Get() {
if (!g_instance) {
g_instance = new DisabledTestGtestEnvironment();
}
return g_instance;
}
void DisabledTestGtestEnvironment::DisabledTest() {
const testing::TestInfo* test_info =
testing::UnitTest::GetInstance()->current_test_info();
std::string disabled_test = base::StringPrintf(
"%s.%s", test_info->test_case_name(), test_info->name());
// Show a DISABLED message using a format similar to gtest, along with a hint
// explaining that OK or FAILED will also appear.
printf(
"This test has been disabled dynamically.\n"
"It will appear as both DISABLED and OK or FAILED.\n"
"[ DISABLED ] %s\n",
disabled_test.c_str());
disabled_tests_.insert(disabled_test);
}
DisabledTestGtestEnvironment::DisabledTestGtestEnvironment()
: testing::Environment(),
disabled_tests_() {
DCHECK(!g_instance);
}
DisabledTestGtestEnvironment::~DisabledTestGtestEnvironment() {
DCHECK_EQ(this, g_instance);
g_instance = nullptr;
}
void DisabledTestGtestEnvironment::TearDown() {
if (!disabled_tests_.empty()) {
printf(
"[ DISABLED ] %" PRIuS " dynamically disabled test%s, listed below:\n"
"[ DISABLED ] %s also counted in PASSED or FAILED below.\n",
disabled_tests_.size(),
disabled_tests_.size() == 1 ? "" : "s",
disabled_tests_.size() == 1 ? "This test is" : "These tests are");
for (const std::string& disabled_test : disabled_tests_) {
printf("[ DISABLED ] %s\n", disabled_test.c_str());
}
}
}
} // namespace test
} // namespace crashpad

87
test/gtest_disabled.h Normal file
View File

@ -0,0 +1,87 @@
// Copyright 2017 The Crashpad Authors. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef CRASHPAD_TEST_GTEST_DISABLED_H_
#define CRASHPAD_TEST_GTEST_DISABLED_H_
#include <set>
#include <string>
#include "base/macros.h"
#include "gtest/gtest.h"
//! \file
namespace crashpad {
namespace test {
//! \brief Provides support for dynamically disabled gtest tests.
//!
//! A test runner must register this with gtest as follows prior to calling
//! `RUN_ALL_TESTS()`:
//! \code
//! testing::AddGlobalTestEnvironment(
//! crashpad::test::DisabledTestGtestEnvironment::Get());
//! \endcode
class DisabledTestGtestEnvironment final : public testing::Environment {
public:
//! \brief Returns the DisabledTestGtestEnvironment singleton instance,
//! creating it if necessary.
static DisabledTestGtestEnvironment* Get();
//! \brief Displays a message about a test being disabled, and arranges for
//! this information to be duplicated in TearDown().
//!
//! This method is for the internal use of the DISABLED_TEST() macro. Do not
//! call it directly, use the macro instead.
void DisabledTest();
private:
DisabledTestGtestEnvironment();
~DisabledTestGtestEnvironment() override;
// testing::Environment:
void TearDown() override;
std::set<std::string> disabled_tests_;
DISALLOW_COPY_AND_ASSIGN(DisabledTestGtestEnvironment);
};
} // namespace test
} // namespace crashpad
//! \brief Displays a message about a test being disabled, and returns early.
//!
//! gtest only provides a mechanism for tests to be disabled statically, by
//! prefixing test case names or test names with `DISABLED_`. When it is
//! necessary to disable tests dynamically, gtest provides no assistance. This
//! macro displays a message about the disabled test and returns early. The
//! dynamically disabled test will also be displayed during gtest global test
//! environment tear-down before the test executable exits.
//!
//! This macro may only be invoked from the context of a gtest test.
//!
//! Theres a long-standing <a
//! href="https://groups.google.com/d/topic/googletestframework/Nwh3u7YFuN4">gtest
//! feature request</a> to provide this functionality directly in gtest, but
//! since it hasnt been implemented, this macro provides a local mechanism to
//! achieve it.
#define DISABLED_TEST() \
do { \
::crashpad::test::DisabledTestGtestEnvironment::Get()->DisabledTest(); \
return; \
} while (false)
#endif // CRASHPAD_TEST_GTEST_DISABLED_H_

View File

@ -13,10 +13,13 @@
// limitations under the License.
#include "gtest/gtest.h"
#include "test/gtest_disabled.h"
#include "test/main_arguments.h"
int main(int argc, char* argv[]) {
crashpad::test::InitializeMainArguments(argc, argv);
testing::InitGoogleTest(&argc, argv);
testing::AddGlobalTestEnvironment(
crashpad::test::DisabledTestGtestEnvironment::Get());
return RUN_ALL_TESTS();
}

View File

@ -36,6 +36,8 @@
'file.cc',
'file.h',
'gtest_death_check.h',
'gtest_disabled.cc',
'gtest_disabled.h',
'hex_string.cc',
'hex_string.h',
'linux/fake_ptrace_connection.cc',
@ -105,6 +107,10 @@
'dependencies': [
'crashpad_test',
'../third_party/gtest/gtest.gyp:gtest',
'../third_party/mini_chromium/mini_chromium.gyp:base',
],
'include_dirs': [
'..',
],
'sources': [
'gtest_main.cc',
@ -117,6 +123,10 @@
'crashpad_test',
'../third_party/gtest/gmock.gyp:gmock',
'../third_party/gtest/gtest.gyp:gtest',
'../third_party/mini_chromium/mini_chromium.gyp:base',
],
'include_dirs': [
'..',
],
'sources': [
'gmock_main.cc',

View File

@ -106,5 +106,19 @@ base::FilePath TestPaths::TestDataRoot() {
return *test_data_root;
}
#if defined(OS_WIN) && defined(ARCH_CPU_64_BITS)
// static
base::FilePath TestPaths::Output32BitDirectory() {
const wchar_t* environment_value = _wgetenv(L"CRASHPAD_TEST_32_BIT_OUTPUT");
if (!environment_value) {
return base::FilePath();
}
return base::FilePath(environment_value);
}
#endif // defined(OS_WIN) && defined(ARCH_CPU_64_BITS)
} // namespace test
} // namespace crashpad

View File

@ -17,6 +17,7 @@
#include "base/files/file_path.h"
#include "base/macros.h"
#include "build/build_config.h"
namespace crashpad {
namespace test {
@ -42,6 +43,22 @@ class TestPaths {
//! files.
static base::FilePath TestDataRoot();
#if (defined(OS_WIN) && defined(ARCH_CPU_64_BITS)) || DOXYGEN
//! \brief Returns the pathname of a directory containing 32-bit test build
//! output.
//!
//! Tests that require the use of 32-bit build output should call this
//! function to locate that output. This function is only provided to allow
//! 64-bit test code to locate 32-bit output. 32-bit test code can find 32-bit
//! output in its own directory, the parent of Executable().
//!
//! If the `CRASHPAD_TEST_32_BIT_OUTPUT` environment variable is set, its
//! value will be returned. Otherwise, this function will return an empty
//! path, and tests that require the use of 32-bit build output should disable
//! themselves. The DISABLED_TEST() macro may be useful for this purpose.
static base::FilePath Output32BitDirectory();
#endif
DISALLOW_IMPLICIT_CONSTRUCTORS(TestPaths);
};

View File

@ -26,6 +26,7 @@
#include "build/build_config.h"
#include "gtest/gtest.h"
#include "test/errors.h"
#include "test/gtest_disabled.h"
#include "test/scoped_temp_dir.h"
#include "test/test_paths.h"
#include "test/win/child_launcher.h"
@ -131,7 +132,7 @@ TEST(ProcessInfo, Self) {
FromPointerCast<WinVMAddress>(_ReturnAddress()));
}
void TestOtherProcess(const base::string16& directory_modification) {
void TestOtherProcess(const base::FilePath& directory) {
ProcessInfo process_info;
UUID done_uuid;
@ -141,12 +142,12 @@ void TestOtherProcess(const base::string16& directory_modification) {
CreateEvent(nullptr, true, false, done_uuid.ToString16().c_str()));
ASSERT_TRUE(done.get()) << ErrorMessage("CreateEvent");
base::FilePath test_executable = TestPaths::Executable();
std::wstring child_test_executable =
test_executable.DirName()
.Append(directory_modification)
.Append(test_executable.BaseName().RemoveFinalExtension().value() +
directory
.Append(TestPaths::Executable()
.BaseName()
.RemoveFinalExtension()
.value() +
L"_process_info_test_child.exe")
.value();
@ -190,16 +191,17 @@ void TestOtherProcess(const base::string16& directory_modification) {
}
TEST(ProcessInfo, OtherProcess) {
TestOtherProcess(FILE_PATH_LITERAL("."));
TestOtherProcess(TestPaths::Executable().DirName());
}
#if defined(ARCH_CPU_64_BITS)
TEST(ProcessInfo, OtherProcessWOW64) {
#ifndef NDEBUG
TestOtherProcess(FILE_PATH_LITERAL("..\\..\\out\\Debug"));
#else
TestOtherProcess(FILE_PATH_LITERAL("..\\..\\out\\Release"));
#endif
base::FilePath output_32_bit_directory = TestPaths::Output32BitDirectory();
if (output_32_bit_directory.empty()) {
DISABLED_TEST();
}
TestOtherProcess(output_32_bit_directory);
}
#endif // ARCH_CPU_64_BITS