mirror of
https://github.com/chromium/crashpad.git
synced 2025-03-09 22:26:06 +00:00
test: Fix paths for crashpad_tests monolith in Chromium
Instead of individual per-directory test executables like crashpad_util_test, all Crashpad tests in Chromium will be run from a single crashpad_tests executable. Test: crashpad_util_test Paths.Executable, ProcessInfo.Self; crashpad_snapshot_test PEImageReader.DebugDirectory Bug: chromium:779790 Change-Id: If95272fd641734fbdb8e231fbcdc4e7ccb2cb822 Reviewed-on: https://chromium-review.googlesource.com/749303 Reviewed-by: Scott Graham <scottmg@chromium.org>
This commit is contained in:
parent
c542a5ae03
commit
43b798b492
@ -22,6 +22,7 @@
|
|||||||
#include "gtest/gtest.h"
|
#include "gtest/gtest.h"
|
||||||
#include "snapshot/win/process_reader_win.h"
|
#include "snapshot/win/process_reader_win.h"
|
||||||
#include "test/errors.h"
|
#include "test/errors.h"
|
||||||
|
#include "test/test_paths.h"
|
||||||
#include "util/misc/from_pointer_cast.h"
|
#include "util/misc/from_pointer_cast.h"
|
||||||
#include "util/win/get_module_information.h"
|
#include "util/win/get_module_information.h"
|
||||||
#include "util/win/module_version.h"
|
#include "util/win/module_version.h"
|
||||||
@ -52,7 +53,11 @@ TEST(PEImageReader, DebugDirectory) {
|
|||||||
DWORD age;
|
DWORD age;
|
||||||
std::string pdbname;
|
std::string pdbname;
|
||||||
EXPECT_TRUE(pe_image_reader.DebugDirectoryInformation(&uuid, &age, &pdbname));
|
EXPECT_TRUE(pe_image_reader.DebugDirectoryInformation(&uuid, &age, &pdbname));
|
||||||
EXPECT_NE(pdbname.find("crashpad_snapshot_test"), std::string::npos);
|
std::string self_name = base::UTF16ToUTF8(
|
||||||
|
TestPaths::ExpectedExecutableBasename(L"crashpad_snapshot_test")
|
||||||
|
.RemoveFinalExtension()
|
||||||
|
.value());
|
||||||
|
EXPECT_NE(pdbname.find(self_name), std::string::npos);
|
||||||
const std::string suffix(".pdb");
|
const std::string suffix(".pdb");
|
||||||
EXPECT_EQ(
|
EXPECT_EQ(
|
||||||
pdbname.compare(pdbname.size() - suffix.size(), suffix.size(), suffix),
|
pdbname.compare(pdbname.size() - suffix.size(), suffix.size(), suffix),
|
||||||
|
@ -116,6 +116,23 @@ base::FilePath TestPaths::Executable() {
|
|||||||
return executable_path;
|
return executable_path;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// static
|
||||||
|
base::FilePath TestPaths::ExpectedExecutableBasename(
|
||||||
|
const base::FilePath::StringType& name) {
|
||||||
|
#if defined(CRASHPAD_IN_CHROMIUM)
|
||||||
|
base::FilePath::StringType executable_name(
|
||||||
|
FILE_PATH_LITERAL("crashpad_tests"));
|
||||||
|
#else // CRASHPAD_IN_CHROMIUM
|
||||||
|
base::FilePath::StringType executable_name(name);
|
||||||
|
#endif // CRASHPAD_IN_CHROMIUM
|
||||||
|
|
||||||
|
#if defined(OS_WIN)
|
||||||
|
executable_name += FILE_PATH_LITERAL(".exe");
|
||||||
|
#endif // OS_WIN
|
||||||
|
|
||||||
|
return base::FilePath(executable_name);
|
||||||
|
}
|
||||||
|
|
||||||
// static
|
// static
|
||||||
base::FilePath TestPaths::TestDataRoot() {
|
base::FilePath TestPaths::TestDataRoot() {
|
||||||
static base::FilePath* test_data_root =
|
static base::FilePath* test_data_root =
|
||||||
|
@ -62,6 +62,24 @@ class TestPaths {
|
|||||||
//! On failure, aborts execution.
|
//! On failure, aborts execution.
|
||||||
static base::FilePath Executable();
|
static base::FilePath Executable();
|
||||||
|
|
||||||
|
//! \brief Returns the expected basename of the currently-running test
|
||||||
|
//! executable.
|
||||||
|
//!
|
||||||
|
//! In Crashpad’s standalone build, this returns \a name, with the system’s
|
||||||
|
//! extension for executables (`.exe`) appended if appropriate.
|
||||||
|
//!
|
||||||
|
//! When building in Chromium, \a name is ignored, and the name of the
|
||||||
|
//! monolithic test executable (`crashpad_tests`) is returned, with the
|
||||||
|
//! system’s extension for executables appended if appropriate.
|
||||||
|
//!
|
||||||
|
//! Only use this function to determine test expectations.
|
||||||
|
//!
|
||||||
|
//! Do not use this function to obtain the name of the currently running test
|
||||||
|
//! executable, use Executable() instead. Do not use this function to locate
|
||||||
|
//! other build artifacts, use BuildArtifact() instead.
|
||||||
|
static base::FilePath ExpectedExecutableBasename(
|
||||||
|
const base::FilePath::StringType& name);
|
||||||
|
|
||||||
//! \brief Returns the pathname of the test data root.
|
//! \brief Returns the pathname of the test data root.
|
||||||
//!
|
//!
|
||||||
//! If the `CRASHPAD_TEST_DATA_ROOT` environment variable is set, its value
|
//! If the `CRASHPAD_TEST_DATA_ROOT` environment variable is set, its value
|
||||||
|
@ -15,8 +15,8 @@
|
|||||||
#include "util/misc/paths.h"
|
#include "util/misc/paths.h"
|
||||||
|
|
||||||
#include "base/files/file_path.h"
|
#include "base/files/file_path.h"
|
||||||
#include "build/build_config.h"
|
|
||||||
#include "gtest/gtest.h"
|
#include "gtest/gtest.h"
|
||||||
|
#include "test/test_paths.h"
|
||||||
|
|
||||||
namespace crashpad {
|
namespace crashpad {
|
||||||
namespace test {
|
namespace test {
|
||||||
@ -26,12 +26,10 @@ TEST(Paths, Executable) {
|
|||||||
base::FilePath executable_path;
|
base::FilePath executable_path;
|
||||||
ASSERT_TRUE(Paths::Executable(&executable_path));
|
ASSERT_TRUE(Paths::Executable(&executable_path));
|
||||||
const base::FilePath executable_name(executable_path.BaseName());
|
const base::FilePath executable_name(executable_path.BaseName());
|
||||||
#if defined(OS_WIN)
|
const base::FilePath expected_name(TestPaths::ExpectedExecutableBasename(
|
||||||
EXPECT_EQ(executable_name.value(),
|
FILE_PATH_LITERAL("crashpad_util_test")));
|
||||||
FILE_PATH_LITERAL("crashpad_util_test.exe"));
|
|
||||||
#else
|
EXPECT_EQ(executable_name.value(), expected_name.value());
|
||||||
EXPECT_EQ(executable_name.value(), "crashpad_util_test");
|
|
||||||
#endif // OS_WIN
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
@ -104,10 +104,12 @@ TEST(ProcessInfo, Self) {
|
|||||||
std::vector<ProcessInfo::Module> modules;
|
std::vector<ProcessInfo::Module> modules;
|
||||||
EXPECT_TRUE(process_info.Modules(&modules));
|
EXPECT_TRUE(process_info.Modules(&modules));
|
||||||
ASSERT_GE(modules.size(), 2u);
|
ASSERT_GE(modules.size(), 2u);
|
||||||
static constexpr wchar_t kSelfName[] = L"\\crashpad_util_test.exe";
|
std::wstring self_name =
|
||||||
ASSERT_GE(modules[0].name.size(), wcslen(kSelfName));
|
std::wstring(1, '\\') +
|
||||||
EXPECT_EQ(modules[0].name.substr(modules[0].name.size() - wcslen(kSelfName)),
|
TestPaths::ExpectedExecutableBasename(L"crashpad_util_test").value();
|
||||||
kSelfName);
|
ASSERT_GE(modules[0].name.size(), self_name.size());
|
||||||
|
EXPECT_EQ(modules[0].name.substr(modules[0].name.size() - self_name.size()),
|
||||||
|
self_name);
|
||||||
ASSERT_GE(modules[1].name.size(), wcslen(kNtdllName));
|
ASSERT_GE(modules[1].name.size(), wcslen(kNtdllName));
|
||||||
EXPECT_EQ(modules[1].name.substr(modules[1].name.size() - wcslen(kNtdllName)),
|
EXPECT_EQ(modules[1].name.substr(modules[1].name.size() - wcslen(kNtdllName)),
|
||||||
kNtdllName);
|
kNtdllName);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user