summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Martin Stjernholm <mast@google.com> 2025-03-14 18:00:37 +0000
committer Martin Stjernholm <mast@google.com> 2025-03-20 15:50:43 -0700
commit6f3beba5e01780c30364e34be15335da51c4e0e5 (patch)
tree1f7fcdeefd53e4601a5ad585f9da0765870ce483
parent8badd481972993739e7711258f03a44638ca87a5 (diff)
Move more path logic for tests to testing.cc, so it can be used without
depending on CommonArtTest. Preparation to fix the libart-gtest dependency in art_standalone_libartpalette_tests. Due to a new #include, this necessitated fixing a bunch of `testing` namespace references that could become ambigious wrt `art::testing`. Test: m generate-boot-image Test: art/tools/buildbot-build.sh Bug: 404306250 Change-Id: Iafb3d73148125775c9c5ddbcbaef39dc61859118
-rw-r--r--compiler/optimizing/instruction_simplifier_test.cc8
-rw-r--r--compiler/optimizing/load_store_elimination_test.cc18
-rw-r--r--compiler/optimizing/reference_type_propagation_test.cc28
-rw-r--r--compiler/utils/assembler_test_base.h2
-rw-r--r--dex2oat/linker/elf_writer_test.cc9
-rw-r--r--dex2oat/linker/multi_oat_relative_patcher_test.cc2
-rw-r--r--dex2oat/linker/relative_patcher_test.h2
-rw-r--r--libartbase/Android.bp6
-rw-r--r--libartbase/base/arena_allocator_test.cc2
-rw-r--r--libartbase/base/common_art_test.cc137
-rw-r--r--libartbase/base/common_art_test.h43
-rw-r--r--libartbase/base/hash_set_test.cc2
-rw-r--r--libartbase/base/intrusive_forward_list_test.cc2
-rw-r--r--libartbase/base/logging_test.cc2
-rw-r--r--libartbase/base/mem_map_test.cc14
-rw-r--r--libartbase/base/metrics/metrics_test.cc2
-rw-r--r--libartbase/base/testing.cc144
-rw-r--r--libartbase/base/testing.h31
-rw-r--r--libartbase/base/unix_file/fd_file_test.cc8
-rw-r--r--libartbase/base/unix_file/random_access_file_test.h2
-rw-r--r--libartbase/base/utils_test.cc10
-rw-r--r--libartpalette/apex/palette_test.cc2
-rw-r--r--libartservice/service/native/service_test.cc4
-rw-r--r--libarttools/art_exec_test.cc4
-rw-r--r--libarttools/cmdline_builder_test.cc2
-rw-r--r--libarttools/system_properties_test.cc2
-rw-r--r--libdexfile/dex/code_item_accessors_test.cc2
-rw-r--r--libdexfile/dex/descriptors_names_test.cc2
-rw-r--r--libdexfile/dex/dex_file_loader_test.cc2
-rw-r--r--libdexfile/dex/dex_file_verifier_test.cc2
-rw-r--r--libdexfile/dex/type_lookup_table_test.cc8
-rw-r--r--libdexfile/dex/utf_test.cc2
-rw-r--r--libnativebridge/tests/NativeBridgeTest.h2
-rw-r--r--libnativeloader/native_loader_api_test.cpp2
-rw-r--r--libnativeloader/native_loader_test.cpp14
-rw-r--r--oatdump/oatdump_test.cc2
-rw-r--r--oatdump/oatdump_test.h2
-rw-r--r--odrefresh/odr_metrics_record_test.cc2
-rw-r--r--runtime/arch/memcmp16_test.cc3
-rw-r--r--runtime/common_runtime_test.h4
-rw-r--r--runtime/exec_utils_test.cc4
-rw-r--r--runtime/gc/space/space_create_test.cc4
-rw-r--r--runtime/jit/jit_memory_region_test.cc2
-rw-r--r--runtime/metrics/reporter_test.cc2
-rw-r--r--runtime/oat/oat_file_assistant_test.cc6
-rw-r--r--sigchainlib/sigchain_test.cc12
-rw-r--r--test/generate-boot-image/generate-boot-image.cc3
-rw-r--r--test/standalone_test_lib_check.cc2
48 files changed, 290 insertions, 282 deletions
diff --git a/compiler/optimizing/instruction_simplifier_test.cc b/compiler/optimizing/instruction_simplifier_test.cc
index a2e3882c19..448dc32006 100644
--- a/compiler/optimizing/instruction_simplifier_test.cc
+++ b/compiler/optimizing/instruction_simplifier_test.cc
@@ -234,9 +234,9 @@ TEST_P(InstanceOfInstructionSimplifierTestGroup, ExactClassCheckCastOther) {
INSTANTIATE_TEST_SUITE_P(InstructionSimplifierTest,
InstanceOfInstructionSimplifierTestGroup,
- testing::Values(InstanceOfKind::kSelf,
- InstanceOfKind::kUnrelatedLoaded,
- InstanceOfKind::kUnrelatedUnloaded,
- InstanceOfKind::kSupertype));
+ ::testing::Values(InstanceOfKind::kSelf,
+ InstanceOfKind::kUnrelatedLoaded,
+ InstanceOfKind::kUnrelatedUnloaded,
+ InstanceOfKind::kSupertype));
} // namespace art
diff --git a/compiler/optimizing/load_store_elimination_test.cc b/compiler/optimizing/load_store_elimination_test.cc
index bb73688b89..af039229af 100644
--- a/compiler/optimizing/load_store_elimination_test.cc
+++ b/compiler/optimizing/load_store_elimination_test.cc
@@ -1779,17 +1779,17 @@ TEST_P(TwoTypesConversionsTestGroup, MergingConvertedValueStorePhiDeduplication)
}
auto Int32AndSmallerTypesGenerator() {
- return testing::Values(DataType::Type::kInt32,
- DataType::Type::kInt16,
- DataType::Type::kInt8,
- DataType::Type::kUint16,
- DataType::Type::kUint8);
+ return ::testing::Values(DataType::Type::kInt32,
+ DataType::Type::kInt16,
+ DataType::Type::kInt8,
+ DataType::Type::kUint16,
+ DataType::Type::kUint8);
}
-INSTANTIATE_TEST_SUITE_P(
- LoadStoreEliminationTest,
- TwoTypesConversionsTestGroup,
- testing::Combine(Int32AndSmallerTypesGenerator(), Int32AndSmallerTypesGenerator()));
+INSTANTIATE_TEST_SUITE_P(LoadStoreEliminationTest,
+ TwoTypesConversionsTestGroup,
+ ::testing::Combine(Int32AndSmallerTypesGenerator(),
+ Int32AndSmallerTypesGenerator()));
// // ENTRY
// obj = new Obj();
diff --git a/compiler/optimizing/reference_type_propagation_test.cc b/compiler/optimizing/reference_type_propagation_test.cc
index 0e0acd11c2..f720b8d911 100644
--- a/compiler/optimizing/reference_type_propagation_test.cc
+++ b/compiler/optimizing/reference_type_propagation_test.cc
@@ -496,16 +496,16 @@ TEST_P(LoopReferenceTypePropagationTestGroup, RunVisitTest) {
INSTANTIATE_TEST_SUITE_P(ReferenceTypePropagationTest,
LoopReferenceTypePropagationTestGroup,
- testing::Combine(testing::Values(ShuffleOrder::kAlmostTopological,
- ShuffleOrder::kReverseTopological,
- ShuffleOrder::kTopological,
- ShuffleOrder::kRandom),
- testing::Values(-1, 10, 40),
- testing::Values(0, 1),
- testing::Values(InitialNullState::kAllNonNull,
- InitialNullState::kAllNull,
- InitialNullState::kHalfNull,
- InitialNullState::kRandom)));
+ ::testing::Combine(::testing::Values(ShuffleOrder::kAlmostTopological,
+ ShuffleOrder::kReverseTopological,
+ ShuffleOrder::kTopological,
+ ShuffleOrder::kRandom),
+ ::testing::Values(-1, 10, 40),
+ ::testing::Values(0, 1),
+ ::testing::Values(InitialNullState::kAllNonNull,
+ InitialNullState::kAllNull,
+ InitialNullState::kHalfNull,
+ InitialNullState::kRandom)));
TEST_P(NonLoopReferenceTypePropagationTestGroup, RunVisitTest) {
RunVisitListTest([&](std::vector<HInstruction*>& lst) { MutateList(lst, GetParam()); });
@@ -513,9 +513,9 @@ TEST_P(NonLoopReferenceTypePropagationTestGroup, RunVisitTest) {
INSTANTIATE_TEST_SUITE_P(ReferenceTypePropagationTest,
NonLoopReferenceTypePropagationTestGroup,
- testing::Values(ShuffleOrder::kAlmostTopological,
- ShuffleOrder::kReverseTopological,
- ShuffleOrder::kTopological,
- ShuffleOrder::kRandom));
+ ::testing::Values(ShuffleOrder::kAlmostTopological,
+ ShuffleOrder::kReverseTopological,
+ ShuffleOrder::kTopological,
+ ShuffleOrder::kRandom));
} // namespace art
diff --git a/compiler/utils/assembler_test_base.h b/compiler/utils/assembler_test_base.h
index 0a89ad1299..515361af00 100644
--- a/compiler/utils/assembler_test_base.h
+++ b/compiler/utils/assembler_test_base.h
@@ -42,7 +42,7 @@ namespace art HIDDEN {
static constexpr bool kKeepDisassembledFiles = false;
// We put this into a class as gtests are self-contained, so this helper needs to be in an h-file.
-class AssemblerTestBase : public testing::Test {
+class AssemblerTestBase : public ::testing::Test {
public:
AssemblerTestBase() {}
diff --git a/dex2oat/linker/elf_writer_test.cc b/dex2oat/linker/elf_writer_test.cc
index 38eec45611..4f7c3b4452 100644
--- a/dex2oat/linker/elf_writer_test.cc
+++ b/dex2oat/linker/elf_writer_test.cc
@@ -219,13 +219,12 @@ TEST_F(ElfWriterTest, CheckDynamicSection) {
size_t bss_methods_offset,
size_t bss_roots_offset,
size_t dex_section_size,
- /*out*/ size_t *number_of_dynamic_symbols) {
- SCOPED_TRACE(testing::Message() << "rodata_size: " << rodata_size
- << ", text_size: " << text_size
+ /*out*/ size_t* number_of_dynamic_symbols) {
+ SCOPED_TRACE(::testing::Message()
+ << "rodata_size: " << rodata_size << ", text_size: " << text_size
<< ", data_img_rel_ro_size: " << data_img_rel_ro_size
<< ", data_img_rel_ro_app_image_offset: " << data_img_rel_ro_app_image_offset
- << ", bss_size: " << bss_size
- << ", bss_methods_offset: " << bss_methods_offset
+ << ", bss_size: " << bss_size << ", bss_methods_offset: " << bss_methods_offset
<< ", bss_roots_offset: " << bss_roots_offset
<< ", dex_section_size: " << dex_section_size);
diff --git a/dex2oat/linker/multi_oat_relative_patcher_test.cc b/dex2oat/linker/multi_oat_relative_patcher_test.cc
index b2aa619337..a610bde6e9 100644
--- a/dex2oat/linker/multi_oat_relative_patcher_test.cc
+++ b/dex2oat/linker/multi_oat_relative_patcher_test.cc
@@ -27,7 +27,7 @@ namespace linker {
static const MethodReference kNullMethodRef = MethodReference(nullptr, 0u);
-class MultiOatRelativePatcherTest : public testing::Test {
+class MultiOatRelativePatcherTest : public ::testing::Test {
protected:
class MockPatcher : public RelativePatcher {
public:
diff --git a/dex2oat/linker/relative_patcher_test.h b/dex2oat/linker/relative_patcher_test.h
index 3e7ba796e0..16f263ec21 100644
--- a/dex2oat/linker/relative_patcher_test.h
+++ b/dex2oat/linker/relative_patcher_test.h
@@ -36,7 +36,7 @@ namespace art {
namespace linker {
// Base class providing infrastructure for architecture-specific tests.
-class RelativePatcherTest : public testing::Test {
+class RelativePatcherTest : public ::testing::Test {
protected:
RelativePatcherTest(InstructionSet instruction_set, const std::string& variant)
: storage_(/*swap_fd=*/ -1),
diff --git a/libartbase/Android.bp b/libartbase/Android.bp
index 2d8194c46e..24603c1220 100644
--- a/libartbase/Android.bp
+++ b/libartbase/Android.bp
@@ -323,10 +323,8 @@ art_cc_library_static {
srcs: [
"base/testing.cc",
],
- header_libs: [
- "libbase_headers",
- "art_libartbase_headers",
- ],
+ header_libs: ["art_libartbase_headers"],
+ export_header_lib_headers: ["art_libartbase_headers"],
}
art_cc_defaults {
diff --git a/libartbase/base/arena_allocator_test.cc b/libartbase/base/arena_allocator_test.cc
index 6323a2b97c..d956b4ab5e 100644
--- a/libartbase/base/arena_allocator_test.cc
+++ b/libartbase/base/arena_allocator_test.cc
@@ -23,7 +23,7 @@
namespace art {
-class ArenaAllocatorTest : public testing::Test {
+class ArenaAllocatorTest : public ::testing::Test {
protected:
size_t NumberOfArenas(ArenaAllocator* allocator) {
size_t result = 0u;
diff --git a/libartbase/base/common_art_test.cc b/libartbase/base/common_art_test.cc
index 2fcf41c14e..41ed98d651 100644
--- a/libartbase/base/common_art_test.cc
+++ b/libartbase/base/common_art_test.cc
@@ -34,7 +34,6 @@
#include "android-base/process.h"
#include "android-base/scopeguard.h"
#include "android-base/stringprintf.h"
-#include "android-base/strings.h"
#include "android-base/unique_fd.h"
#include "art_field-inl.h"
#include "base/file_utils.h"
@@ -163,107 +162,6 @@ android::base::ScopeGuard<std::function<void()>> ScopedInaccessible(const std::s
return android::base::make_scope_guard([=]() { std::filesystem::permissions(path, old_perms); });
}
-std::string CommonArtTestImpl::GetAndroidBuildTop() {
- CHECK(IsHost());
- std::string android_build_top;
-
- // Look at how we were invoked to find the expected directory.
- std::string argv;
- if (android::base::ReadFileToString("/proc/self/cmdline", &argv)) {
- // /proc/self/cmdline is the programs 'argv' with elements delimited by '\0'.
- std::filesystem::path path(argv.substr(0, argv.find('\0')));
- path = std::filesystem::absolute(path);
- // Walk up until we find the one of the well-known directories.
- for (; path.parent_path() != path; path = path.parent_path()) {
- // We are running tests from out/host/linux-x86 on developer machine.
- if (path.filename() == std::filesystem::path("linux-x86")) {
- android_build_top = path.parent_path().parent_path().parent_path();
- break;
- }
- // We are running tests from testcases (extracted from zip) on tradefed.
- // The first path is for remote runs and the second path for local runs.
- if (path.filename() == std::filesystem::path("testcases") ||
- path.filename().string().starts_with("host_testcases")) {
- android_build_top = path.append("art_common");
- break;
- }
- }
- }
- CHECK(!android_build_top.empty());
-
- // Check that the expected directory matches the environment variable.
- const char* android_build_top_from_env = getenv("ANDROID_BUILD_TOP");
- android_build_top = std::filesystem::path(android_build_top).string();
- CHECK(!android_build_top.empty());
- if (android_build_top_from_env != nullptr) {
- if (std::filesystem::weakly_canonical(android_build_top).string() !=
- std::filesystem::weakly_canonical(android_build_top_from_env).string()) {
- android_build_top = android_build_top_from_env;
- }
- } else {
- setenv("ANDROID_BUILD_TOP", android_build_top.c_str(), /*overwrite=*/0);
- }
- if (android_build_top.back() != '/') {
- android_build_top += '/';
- }
- return android_build_top;
-}
-
-std::string CommonArtTestImpl::GetAndroidHostOut() {
- CHECK(IsHost());
-
- // Check that the expected directory matches the environment variable.
- // ANDROID_HOST_OUT is set by envsetup or unset and is the full path to host binaries/libs
- const char* android_host_out_from_env = getenv("ANDROID_HOST_OUT");
- // OUT_DIR is a user-settable ENV_VAR that controls where soong puts build artifacts. It can
- // either be relative to ANDROID_BUILD_TOP or a concrete path.
- const char* android_out_dir = getenv("OUT_DIR");
- // Take account of OUT_DIR setting.
- if (android_out_dir == nullptr) {
- android_out_dir = "out";
- }
- std::string android_host_out;
- if (android_out_dir[0] == '/') {
- android_host_out = (std::filesystem::path(android_out_dir) / "host" / "linux-x86").string();
- } else {
- android_host_out =
- (std::filesystem::path(GetAndroidBuildTop()) / android_out_dir / "host" / "linux-x86")
- .string();
- }
- std::filesystem::path expected(android_host_out);
- if (android_host_out_from_env != nullptr) {
- std::filesystem::path from_env(std::filesystem::weakly_canonical(android_host_out_from_env));
- if (std::filesystem::weakly_canonical(expected).string() != from_env.string()) {
- LOG(WARNING) << "Execution path (" << expected << ") not below ANDROID_HOST_OUT ("
- << from_env << ")! Using env-var.";
- expected = from_env;
- }
- } else {
- setenv("ANDROID_HOST_OUT", android_host_out.c_str(), /*overwrite=*/0);
- }
- return expected.string();
-}
-
-std::string CommonArtTestImpl::GetHostBootClasspathInstallRoot() {
- CHECK(IsHost());
- std::string build_install_root = GetAndroidHostOut() + "/testcases/art_common/out/host/linux-x86";
- // Look for the `apex` subdirectory as a discriminator to check the location.
- if (OS::DirectoryExists((build_install_root + "/apex").c_str())) {
- // This is the path where "m art-host-tests" installs support files for host
- // tests, so use it when the tests are run in a build tree (which is the
- // case when testing locally).
- return build_install_root;
- }
- if (OS::DirectoryExists((GetAndroidRoot() + "/apex").c_str())) {
- // This is the location for host tests in CI when the files are unzipped
- // from art-host-tests.zip.
- return GetAndroidRoot();
- }
- LOG(ERROR) << "Neither location has a boot classpath (forgot \"m art-host-tests\"?): "
- << build_install_root << " or " << GetAndroidRoot();
- return "<no boot classpath found>";
-}
-
void CommonArtTestImpl::SetUpAndroidRootEnvVars() {
if (IsHost()) {
std::string android_host_out = GetAndroidHostOut();
@@ -463,41 +361,6 @@ std::vector<std::string> CommonArtTestImpl::GetLibCoreModuleNames() const {
return art::testing::GetLibCoreModuleNames();
}
-std::vector<std::string> CommonArtTestImpl::GetLibCoreDexFileNames(
- const std::vector<std::string>& modules) const {
- return art::testing::GetLibCoreDexFileNames(
- kIsTargetBuild ? "" : GetHostBootClasspathInstallRoot(), modules);
-}
-
-std::vector<std::string> CommonArtTestImpl::GetLibCoreDexFileNames() const {
- std::vector<std::string> modules = GetLibCoreModuleNames();
- return art::testing::GetLibCoreDexFileNames(
- kIsTargetBuild ? "" : GetHostBootClasspathInstallRoot(), modules);
-}
-
-std::vector<std::string> CommonArtTestImpl::GetLibCoreDexLocations(
- const std::vector<std::string>& modules) const {
- std::string prefix = "";
- if (IsHost()) {
- std::string android_root = GetAndroidRoot();
- std::string build_top = GetAndroidBuildTop();
- CHECK(android_root.starts_with(build_top))
- << " android_root=" << android_root << " build_top=" << build_top;
- prefix = android_root.substr(build_top.size());
- }
- return art::testing::GetLibCoreDexFileNames(prefix, modules);
-}
-
-std::vector<std::string> CommonArtTestImpl::GetLibCoreDexLocations() const {
- std::vector<std::string> modules = GetLibCoreModuleNames();
- return GetLibCoreDexLocations(modules);
-}
-
-std::string CommonArtTestImpl::GetClassPathOption(const char* option,
- const std::vector<std::string>& class_path) {
- return option + android::base::Join(class_path, ':');
-}
-
// Check that for target builds we have ART_TARGET_NATIVETEST_DIR set.
#ifdef ART_TARGET
#ifndef ART_TARGET_NATIVETEST_DIR
diff --git a/libartbase/base/common_art_test.h b/libartbase/base/common_art_test.h
index 5da6ac9920..b27199c386 100644
--- a/libartbase/base/common_art_test.h
+++ b/libartbase/base/common_art_test.h
@@ -32,6 +32,7 @@
#include "base/memory_tool.h"
#include "base/mutex.h"
#include "base/os.h"
+#include "base/testing.h"
#include "base/unix_file/fd_file.h"
#include "dex/art_dex_file_loader.h"
#include "dex/compact_dex_file.h"
@@ -152,19 +153,29 @@ class CommonArtTestImpl {
virtual std::vector<std::string> GetLibCoreModuleNames() const;
// Gets the paths of the libcore dex files for given modules.
- std::vector<std::string> GetLibCoreDexFileNames(const std::vector<std::string>& modules) const;
+ std::vector<std::string> GetLibCoreDexFileNames(const std::vector<std::string>& modules) const {
+ return art::testing::GetLibCoreDexFileNames(modules);
+ }
// Gets the paths of the libcore dex files.
- std::vector<std::string> GetLibCoreDexFileNames() const;
+ std::vector<std::string> GetLibCoreDexFileNames() const {
+ return GetLibCoreDexFileNames(GetLibCoreModuleNames());
+ }
// Gets the on-host or on-device locations of the libcore dex files for given modules.
- std::vector<std::string> GetLibCoreDexLocations(const std::vector<std::string>& modules) const;
+ std::vector<std::string> GetLibCoreDexLocations(const std::vector<std::string>& modules) const {
+ return art::testing::GetLibCoreDexLocations(modules);
+ }
// Gets the on-host or on-device locations of the libcore dex files.
- std::vector<std::string> GetLibCoreDexLocations() const;
+ std::vector<std::string> GetLibCoreDexLocations() const {
+ return GetLibCoreDexLocations(GetLibCoreModuleNames());
+ }
static std::string GetClassPathOption(const char* option,
- const std::vector<std::string>& class_path);
+ const std::vector<std::string>& class_path) {
+ return art::testing::GetClassPathOption(option, class_path);
+ }
// Retuerns the filename for a test dex (i.e. XandY or ManyMethods).
std::string GetTestDexFileName(const char* name) const;
@@ -227,21 +238,15 @@ class CommonArtTestImpl {
static std::string GetAndroidTool(const char* name, InstructionSet isa = InstructionSet::kX86_64);
protected:
- static bool IsHost() {
- return !art::kIsTargetBuild;
- }
+ static bool IsHost() { return art::testing::IsHost(); }
- // Returns ${ANDROID_BUILD_TOP}. Ensure it has tailing /.
- static std::string GetAndroidBuildTop();
+ static std::string GetAndroidBuildTop() { return art::testing::GetAndroidBuildTop(); }
- // Returns ${ANDROID_HOST_OUT}.
- static std::string GetAndroidHostOut();
+ static std::string GetAndroidHostOut() { return art::testing::GetAndroidHostOut(); }
- // Returns the path where boot classpath and boot image files are installed
- // for host tests (by the art_common mk module, typically built through "m
- // art-host-tests"). Different in CI where they are unpacked from the
- // art-host-tests.zip file.
- static std::string GetHostBootClasspathInstallRoot();
+ static std::string GetHostBootClasspathInstallRoot() {
+ return art::testing::GetHostBootClasspathInstallRoot();
+ }
// File location to boot.art, e.g. /apex/com.android.art/javalib/boot.art
static std::string GetCoreArtLocation();
@@ -300,10 +305,10 @@ class CommonArtTestBase : public TestType, public CommonArtTestImpl {
}
};
-using CommonArtTest = CommonArtTestBase<testing::Test>;
+using CommonArtTest = CommonArtTestBase<::testing::Test>;
template <typename Param>
-using CommonArtTestWithParam = CommonArtTestBase<testing::TestWithParam<Param>>;
+using CommonArtTestWithParam = CommonArtTestBase<::testing::TestWithParam<Param>>;
// Returns a list of PIDs of the processes whose process name (the first commandline argument) fully
// matches the given name.
diff --git a/libartbase/base/hash_set_test.cc b/libartbase/base/hash_set_test.cc
index b7b289cf65..959ab5ebf5 100644
--- a/libartbase/base/hash_set_test.cc
+++ b/libartbase/base/hash_set_test.cc
@@ -39,7 +39,7 @@ struct IsEmptyFnString {
}
};
-class HashSetTest : public testing::Test {
+class HashSetTest : public ::testing::Test {
public:
HashSetTest() : seed_(97421), unique_number_(0) {
}
diff --git a/libartbase/base/intrusive_forward_list_test.cc b/libartbase/base/intrusive_forward_list_test.cc
index f96fc9d516..095a94ceeb 100644
--- a/libartbase/base/intrusive_forward_list_test.cc
+++ b/libartbase/base/intrusive_forward_list_test.cc
@@ -67,7 +67,7 @@ bool operator<(const IFLTestValue2& lhs, const IFLTestValue2& rhs) {
ASSERT_TRUE(std::equal((expected).begin(), (expected).end(), (value).begin())); \
} while (false)
-class IntrusiveForwardListTest : public testing::Test {
+class IntrusiveForwardListTest : public ::testing::Test {
public:
template <typename ListType>
void IteratorToConstIterator();
diff --git a/libartbase/base/logging_test.cc b/libartbase/base/logging_test.cc
index 1fa3209f7f..985a8eafae 100644
--- a/libartbase/base/logging_test.cc
+++ b/libartbase/base/logging_test.cc
@@ -32,7 +32,7 @@ static void SimpleAborter(const char* msg) {
_exit(1);
}
-class LoggingTest : public testing::Test {
+class LoggingTest : public ::testing::Test {
protected:
LoggingTest() {
// In our abort tests we really don't want the runtime to create a real dump.
diff --git a/libartbase/base/mem_map_test.cc b/libartbase/base/mem_map_test.cc
index b3da8fbf52..76a50a59e4 100644
--- a/libartbase/base/mem_map_test.cc
+++ b/libartbase/base/mem_map_test.cc
@@ -899,17 +899,17 @@ TEST_F(MemMapTest, Reservation) {
namespace {
-class DumpMapsOnFailListener : public testing::EmptyTestEventListener {
- void OnTestPartResult(const testing::TestPartResult& result) override {
+class DumpMapsOnFailListener : public ::testing::EmptyTestEventListener {
+ void OnTestPartResult(const ::testing::TestPartResult& result) override {
switch (result.type()) {
- case testing::TestPartResult::kFatalFailure:
+ case ::testing::TestPartResult::kFatalFailure:
art::PrintFileToLog("/proc/self/maps", android::base::LogSeverity::ERROR);
break;
// TODO: Could consider logging on EXPECT failures.
- case testing::TestPartResult::kNonFatalFailure:
- case testing::TestPartResult::kSkip:
- case testing::TestPartResult::kSuccess:
+ case ::testing::TestPartResult::kNonFatalFailure:
+ case ::testing::TestPartResult::kSkip:
+ case ::testing::TestPartResult::kSuccess:
break;
}
}
@@ -921,5 +921,5 @@ class DumpMapsOnFailListener : public testing::EmptyTestEventListener {
extern "C"
__attribute__((visibility("default"))) __attribute__((used))
void ArtTestGlobalInit() {
- testing::UnitTest::GetInstance()->listeners().Append(new DumpMapsOnFailListener());
+ ::testing::UnitTest::GetInstance()->listeners().Append(new DumpMapsOnFailListener());
}
diff --git a/libartbase/base/metrics/metrics_test.cc b/libartbase/base/metrics/metrics_test.cc
index bcc4da4e06..3581615514 100644
--- a/libartbase/base/metrics/metrics_test.cc
+++ b/libartbase/base/metrics/metrics_test.cc
@@ -31,7 +31,7 @@ using test::CounterValue;
using test::GetBuckets;
using test::TestBackendBase;
-class MetricsTest : public testing::Test {};
+class MetricsTest : public ::testing::Test {};
TEST_F(MetricsTest, SimpleCounter) {
MetricsCounter<DatumId::kClassVerificationTotalTime> test_counter;
diff --git a/libartbase/base/testing.cc b/libartbase/base/testing.cc
index 3cd2836876..6ec207eded 100644
--- a/libartbase/base/testing.cc
+++ b/libartbase/base/testing.cc
@@ -14,19 +14,123 @@
* limitations under the License.
*/
+#include "testing.h"
+
#include <string>
#include <vector>
+#include "android-base/file.h"
#include "android-base/stringprintf.h"
+#include "android-base/strings.h"
#include "base/file_utils.h"
#include "base/globals.h"
+#include "base/os.h"
namespace art {
namespace testing {
-namespace {
+std::string GetAndroidBuildTop() {
+ CHECK(IsHost());
+ std::string android_build_top;
+
+ // Look at how we were invoked to find the expected directory.
+ std::string argv;
+ if (android::base::ReadFileToString("/proc/self/cmdline", &argv)) {
+ // /proc/self/cmdline is the programs 'argv' with elements delimited by '\0'.
+ std::filesystem::path path(argv.substr(0, argv.find('\0')));
+ path = std::filesystem::absolute(path);
+ // Walk up until we find the one of the well-known directories.
+ for (; path.parent_path() != path; path = path.parent_path()) {
+ // We are running tests from out/host/linux-x86 on developer machine.
+ if (path.filename() == std::filesystem::path("linux-x86")) {
+ android_build_top = path.parent_path().parent_path().parent_path();
+ break;
+ }
+ // We are running tests from testcases (extracted from zip) on tradefed.
+ // The first path is for remote runs and the second path for local runs.
+ if (path.filename() == std::filesystem::path("testcases") ||
+ path.filename().string().starts_with("host_testcases")) {
+ android_build_top = path.append("art_common");
+ break;
+ }
+ }
+ }
+ CHECK(!android_build_top.empty());
+
+ // Check that the expected directory matches the environment variable.
+ const char* android_build_top_from_env = getenv("ANDROID_BUILD_TOP");
+ android_build_top = std::filesystem::path(android_build_top).string();
+ CHECK(!android_build_top.empty());
+ if (android_build_top_from_env != nullptr) {
+ if (std::filesystem::weakly_canonical(android_build_top).string() !=
+ std::filesystem::weakly_canonical(android_build_top_from_env).string()) {
+ android_build_top = android_build_top_from_env;
+ }
+ } else {
+ setenv("ANDROID_BUILD_TOP", android_build_top.c_str(), /*overwrite=*/0);
+ }
+ if (android_build_top.back() != '/') {
+ android_build_top += '/';
+ }
+ return android_build_top;
+}
+
+std::string GetAndroidHostOut() {
+ CHECK(IsHost());
+
+ // Check that the expected directory matches the environment variable.
+ // ANDROID_HOST_OUT is set by envsetup or unset and is the full path to host binaries/libs
+ const char* android_host_out_from_env = getenv("ANDROID_HOST_OUT");
+ // OUT_DIR is a user-settable ENV_VAR that controls where soong puts build artifacts. It can
+ // either be relative to ANDROID_BUILD_TOP or a concrete path.
+ const char* android_out_dir = getenv("OUT_DIR");
+ // Take account of OUT_DIR setting.
+ if (android_out_dir == nullptr) {
+ android_out_dir = "out";
+ }
+ std::string android_host_out;
+ if (android_out_dir[0] == '/') {
+ android_host_out = (std::filesystem::path(android_out_dir) / "host" / "linux-x86").string();
+ } else {
+ android_host_out =
+ (std::filesystem::path(GetAndroidBuildTop()) / android_out_dir / "host" / "linux-x86")
+ .string();
+ }
+ std::filesystem::path expected(android_host_out);
+ if (android_host_out_from_env != nullptr) {
+ std::filesystem::path from_env(std::filesystem::weakly_canonical(android_host_out_from_env));
+ if (std::filesystem::weakly_canonical(expected).string() != from_env.string()) {
+ LOG(WARNING) << "Execution path (" << expected << ") not below ANDROID_HOST_OUT (" << from_env
+ << ")! Using env-var.";
+ expected = from_env;
+ }
+ } else {
+ setenv("ANDROID_HOST_OUT", android_host_out.c_str(), /*overwrite=*/0);
+ }
+ return expected.string();
+}
+
+std::string GetHostBootClasspathInstallRoot() {
+ CHECK(IsHost());
+ std::string build_install_root = GetAndroidHostOut() + "/testcases/art_common/out/host/linux-x86";
+ // Look for the `apex` subdirectory as a discriminator to check the location.
+ if (OS::DirectoryExists((build_install_root + "/apex").c_str())) {
+ // This is the path where "m art-host-tests" installs support files for host
+ // tests, so use it when the tests are run in a build tree (which is the
+ // case when testing locally).
+ return build_install_root;
+ }
+ if (OS::DirectoryExists((GetAndroidRoot() + "/apex").c_str())) {
+ // This is the location for host tests in CI when the files are unzipped
+ // from art-host-tests.zip.
+ return GetAndroidRoot();
+ }
+ LOG(ERROR) << "Neither location has a boot classpath (forgot \"m art-host-tests\"?): "
+ << build_install_root << " or " << GetAndroidRoot();
+ return "<no boot classpath found>";
+}
-std::string GetDexFileName(const std::string& jar_prefix, const std::string& prefix) {
+static std::string GetDexFileName(const std::string& jar_prefix, const std::string& prefix) {
const char* apexPath =
(jar_prefix == "conscrypt") ?
kAndroidConscryptApexDefaultPath :
@@ -35,7 +139,15 @@ std::string GetDexFileName(const std::string& jar_prefix, const std::string& pre
"%s%s/javalib/%s.jar", prefix.c_str(), apexPath, jar_prefix.c_str());
}
-} // namespace
+static std::vector<std::string> GetPrefixedDexFileNames(const std::string& prefix,
+ const std::vector<std::string>& modules) {
+ std::vector<std::string> result;
+ result.reserve(modules.size());
+ for (const std::string& module : modules) {
+ result.push_back(GetDexFileName(module, prefix));
+ }
+ return result;
+}
std::vector<std::string> GetLibCoreModuleNames(bool core_only) {
// Note: This must start with the CORE_IMG_JARS in Android.common_path.mk because that's what we
@@ -59,23 +171,25 @@ std::vector<std::string> GetLibCoreModuleNames(bool core_only) {
return modules;
}
-std::vector<std::string> GetLibCoreDexFileNames(const std::string& prefix,
- const std::vector<std::string>& modules) {
- std::vector<std::string> result;
- result.reserve(modules.size());
- for (const std::string& module : modules) {
- result.push_back(GetDexFileName(module, prefix));
- }
- return result;
+std::vector<std::string> GetLibCoreDexFileNames(const std::vector<std::string>& modules) {
+ return GetPrefixedDexFileNames(kIsTargetBuild ? "" : GetHostBootClasspathInstallRoot(), modules);
}
std::vector<std::string> GetLibCoreDexFileNames(const std::string& prefix, bool core_only) {
std::vector<std::string> modules = GetLibCoreModuleNames(core_only);
- return GetLibCoreDexFileNames(prefix, modules);
+ return GetPrefixedDexFileNames(prefix, modules);
}
std::vector<std::string> GetLibCoreDexLocations(const std::vector<std::string>& modules) {
- return GetLibCoreDexFileNames(/*prefix=*/"", modules);
+ std::string prefix = "";
+ if (IsHost()) {
+ std::string android_root = GetAndroidRoot();
+ std::string build_top = GetAndroidBuildTop();
+ CHECK(android_root.starts_with(build_top))
+ << " android_root=" << android_root << " build_top=" << build_top;
+ prefix = android_root.substr(build_top.size());
+ }
+ return GetPrefixedDexFileNames(prefix, modules);
}
std::vector<std::string> GetLibCoreDexLocations(bool core_only) {
@@ -83,5 +197,9 @@ std::vector<std::string> GetLibCoreDexLocations(bool core_only) {
return GetLibCoreDexLocations(modules);
}
+std::string GetClassPathOption(const char* option, const std::vector<std::string>& class_path) {
+ return option + android::base::Join(class_path, ':');
+}
+
} // namespace testing
} // namespace art
diff --git a/libartbase/base/testing.h b/libartbase/base/testing.h
index 88d0aee6e0..55d7428436 100644
--- a/libartbase/base/testing.h
+++ b/libartbase/base/testing.h
@@ -22,20 +22,41 @@
#include <string>
#include <vector>
+#include "base/globals.h"
+
namespace art {
namespace testing {
+inline bool IsHost() { return !art::kIsTargetBuild; }
+
+// Returns ${ANDROID_BUILD_TOP}. Ensure it has tailing /.
+std::string GetAndroidBuildTop();
+
+// Returns ${ANDROID_HOST_OUT}.
+std::string GetAndroidHostOut();
+
+// Returns the path where boot classpath and boot image files are installed
+// for host tests (by the art_common mk module, typically built through "m
+// art-host-tests"). Different in CI where they are unpacked from the
+// art-host-tests.zip file.
+std::string GetHostBootClasspathInstallRoot();
+
// Note: "libcore" here means art + conscrypt + icu.
// Gets the names of the libcore modules.
// If `core_only` is true, only returns the names of CORE_IMG_JARS in Android.common_path.mk.
std::vector<std::string> GetLibCoreModuleNames(bool core_only = false);
-// Gets the paths of the libcore dex files for given modules.
-std::vector<std::string> GetLibCoreDexFileNames(const std::string& prefix,
- const std::vector<std::string>& modules);
+// Gets the paths of the libcore dex files for given modules, prefixed appropriately for host or
+// target tests.
+std::vector<std::string> GetLibCoreDexFileNames(const std::vector<std::string>& modules);
+
+// Gets the paths of the libcore module dex files, prefixed appropriately for host or target tests.
+inline std::vector<std::string> GetLibCoreDexFileNames() {
+ return GetLibCoreDexFileNames(GetLibCoreModuleNames());
+}
-// Gets the paths of the libcore dex files.
+// Gets the paths of the libcore dex files, prefixed by the given string.
// If `core_only` is true, only returns the filenames of CORE_IMG_JARS in Android.common_path.mk.
std::vector<std::string> GetLibCoreDexFileNames(const std::string& prefix, bool core_only = false);
@@ -46,6 +67,8 @@ std::vector<std::string> GetLibCoreDexLocations(const std::vector<std::string>&
// If `core_only` is true, only returns the filenames of CORE_IMG_JARS in Android.common_path.mk.
std::vector<std::string> GetLibCoreDexLocations(bool core_only = false);
+std::string GetClassPathOption(const char* option, const std::vector<std::string>& class_path);
+
} // namespace testing
} // namespace art
diff --git a/libartbase/base/unix_file/fd_file_test.cc b/libartbase/base/unix_file/fd_file_test.cc
index 374edc96e7..3de3bd91a2 100644
--- a/libartbase/base/unix_file/fd_file_test.cc
+++ b/libartbase/base/unix_file/fd_file_test.cc
@@ -357,7 +357,7 @@ TEST_F(FdFileTest, CopySparseFullCopy) {
TEST_DISABLED_FOR_HOST();
auto verify_fullcopy = [&](size_t empty_prefix, size_t empty_suffix) {
- SCOPED_TRACE(testing::Message() << "prefix:" << empty_prefix << ", suffix:" << empty_suffix);
+ SCOPED_TRACE(::testing::Message() << "prefix:" << empty_prefix << ", suffix:" << empty_suffix);
std::unique_ptr<art::ScratchFile> src;
ASSERT_NO_FATAL_FAILURE(CreateSparseSourceFile(empty_prefix, empty_suffix, src));
@@ -435,9 +435,9 @@ TEST_F(FdFileTest, CopySparsePartialCopy) {
size_t copy_end_offset) {
// The copy starts <copy_start_offset> from the start of the source file.
// The copy ends <copy_end_offset> from the end of the source file.
- SCOPED_TRACE(testing::Message() << "prefix:" << empty_prefix << ", suffix:" << empty_suffix
- << ", copy_start_offset:" << copy_start_offset << ", copy_end_offset:"
- << copy_end_offset);
+ SCOPED_TRACE(::testing::Message() << "prefix:" << empty_prefix << ", suffix:" << empty_suffix
+ << ", copy_start_offset:" << copy_start_offset
+ << ", copy_end_offset:" << copy_end_offset);
std::unique_ptr<art::ScratchFile> src;
ASSERT_NO_FATAL_FAILURE(CreateSparseSourceFile(empty_prefix, empty_suffix, src));
diff --git a/libartbase/base/unix_file/random_access_file_test.h b/libartbase/base/unix_file/random_access_file_test.h
index 0592256291..abcc161aab 100644
--- a/libartbase/base/unix_file/random_access_file_test.h
+++ b/libartbase/base/unix_file/random_access_file_test.h
@@ -25,7 +25,7 @@
namespace unix_file {
-class RandomAccessFileTest : public testing::Test {
+class RandomAccessFileTest : public ::testing::Test {
protected:
virtual ~RandomAccessFileTest() {
}
diff --git a/libartbase/base/utils_test.cc b/libartbase/base/utils_test.cc
index a422fc5369..88d8f07741 100644
--- a/libartbase/base/utils_test.cc
+++ b/libartbase/base/utils_test.cc
@@ -22,7 +22,7 @@
namespace art {
-class UtilsTest : public testing::Test {};
+class UtilsTest : public ::testing::Test {};
TEST_F(UtilsTest, PrettySize) {
EXPECT_EQ("1024MB", PrettySize(1 * GB));
@@ -114,10 +114,10 @@ TEST_F(UtilsTest, Split) {
}
TEST_F(UtilsTest, GetProcessStatus) {
- EXPECT_THAT(GetProcessStatus("Name"),
- testing::AnyOf(
- "art_libartbase_", // Test binary name: `art_libartbase_test`.
- "art_standalone_")); // Test binary name: `art_standalone_libartbase_test`.
+ EXPECT_THAT(
+ GetProcessStatus("Name"),
+ ::testing::AnyOf("art_libartbase_", // Test binary name: `art_libartbase_test`.
+ "art_standalone_")); // Test binary name: `art_standalone_libartbase_test`.
EXPECT_EQ("R (running)", GetProcessStatus("State"));
EXPECT_EQ("<unknown>", GetProcessStatus("tate"));
EXPECT_EQ("<unknown>", GetProcessStatus("e"));
diff --git a/libartpalette/apex/palette_test.cc b/libartpalette/apex/palette_test.cc
index 744d6a8d30..1c4d133b65 100644
--- a/libartpalette/apex/palette_test.cc
+++ b/libartpalette/apex/palette_test.cc
@@ -58,7 +58,7 @@ bool PaletteDebugStoreIsSupported() {
} // namespace
-class PaletteClientTest : public testing::Test {};
+class PaletteClientTest : public ::testing::Test {};
TEST_F(PaletteClientTest, SchedPriority) {
int32_t tid = GetTid();
diff --git a/libartservice/service/native/service_test.cc b/libartservice/service/native/service_test.cc
index d1d429edd7..b0864b7769 100644
--- a/libartservice/service/native/service_test.cc
+++ b/libartservice/service/native/service_test.cc
@@ -30,7 +30,7 @@ using ::android::base::testing::WithMessage;
using std::literals::operator""s; // NOLINT
-class ArtServiceTest : public testing::Test {};
+class ArtServiceTest : public ::testing::Test {};
TEST_F(ArtServiceTest, ValidatePathElementOk) {
EXPECT_THAT(ValidatePathElement("com.android.foo", "packageName"), Ok());
@@ -110,7 +110,7 @@ TEST_F(ArtServiceTest, ValidateDexPathNul) {
class ArtServiceGcTest : public CommonRuntimeTest {};
TEST_F(ArtServiceGcTest, GetGarbageCollector) {
- EXPECT_THAT(GetGarbageCollector(), testing::HasSubstr("CollectorType"));
+ EXPECT_THAT(GetGarbageCollector(), ::testing::HasSubstr("CollectorType"));
}
} // namespace
diff --git a/libarttools/art_exec_test.cc b/libarttools/art_exec_test.cc
index d6e0ba4802..c729b5dc0f 100644
--- a/libarttools/art_exec_test.cc
+++ b/libarttools/art_exec_test.cc
@@ -69,10 +69,10 @@ bool GetCap(pid_t pid, cap_flag_t flag, cap_value_t value) {
return flag_value == CAP_SET;
}
-class ArtExecTest : public testing::Test {
+class ArtExecTest : public ::testing::Test {
protected:
void SetUp() override {
- testing::Test::SetUp();
+ ::testing::Test::SetUp();
if (!kIsTargetAndroid) {
GTEST_SKIP() << "art_exec is for device only";
}
diff --git a/libarttools/cmdline_builder_test.cc b/libarttools/cmdline_builder_test.cc
index 1acf2e3f0b..04b746fa8b 100644
--- a/libarttools/cmdline_builder_test.cc
+++ b/libarttools/cmdline_builder_test.cc
@@ -28,7 +28,7 @@ namespace {
using ::testing::ElementsAre;
using ::testing::IsEmpty;
-class CmdlineBuilderTest : public testing::Test {
+class CmdlineBuilderTest : public ::testing::Test {
protected:
CmdlineBuilder args_;
};
diff --git a/libarttools/system_properties_test.cc b/libarttools/system_properties_test.cc
index acffd9727c..6d5db58573 100644
--- a/libarttools/system_properties_test.cc
+++ b/libarttools/system_properties_test.cc
@@ -30,7 +30,7 @@ class MockSystemProperties : public SystemProperties {
MOCK_METHOD(std::string, GetProperty, (const std::string& key), (const, override));
};
-class SystemPropertiesTest : public testing::Test {
+class SystemPropertiesTest : public ::testing::Test {
protected:
MockSystemProperties system_properties_;
};
diff --git a/libdexfile/dex/code_item_accessors_test.cc b/libdexfile/dex/code_item_accessors_test.cc
index 9f20fc2495..bd1ddc958d 100644
--- a/libdexfile/dex/code_item_accessors_test.cc
+++ b/libdexfile/dex/code_item_accessors_test.cc
@@ -26,7 +26,7 @@
namespace art {
-class CodeItemAccessorsTest : public testing::Test {};
+class CodeItemAccessorsTest : public ::testing::Test {};
std::unique_ptr<const DexFile> CreateFakeDex(bool compact_dex, std::vector<uint8_t>* data) {
data->resize(MemMap::GetPageSize());
diff --git a/libdexfile/dex/descriptors_names_test.cc b/libdexfile/dex/descriptors_names_test.cc
index f3ec3ed0f3..1b0654a770 100644
--- a/libdexfile/dex/descriptors_names_test.cc
+++ b/libdexfile/dex/descriptors_names_test.cc
@@ -20,7 +20,7 @@
namespace art {
-class DescriptorsNamesTest : public testing::Test {};
+class DescriptorsNamesTest : public ::testing::Test {};
TEST_F(DescriptorsNamesTest, PrettyDescriptor_ArrayReferences) {
EXPECT_EQ("java.lang.Class[]", PrettyDescriptor("[Ljava/lang/Class;"));
diff --git a/libdexfile/dex/dex_file_loader_test.cc b/libdexfile/dex/dex_file_loader_test.cc
index 3de1103256..6041ea2077 100644
--- a/libdexfile/dex/dex_file_loader_test.cc
+++ b/libdexfile/dex/dex_file_loader_test.cc
@@ -27,7 +27,7 @@
namespace art {
-class DexFileLoaderTest : public testing::Test {};
+class DexFileLoaderTest : public ::testing::Test {};
static constexpr char kLocationString[] = "/a/dex/file/location";
diff --git a/libdexfile/dex/dex_file_verifier_test.cc b/libdexfile/dex/dex_file_verifier_test.cc
index d67d9a938d..8320b94c9e 100644
--- a/libdexfile/dex/dex_file_verifier_test.cc
+++ b/libdexfile/dex/dex_file_verifier_test.cc
@@ -56,7 +56,7 @@ static void FixUpChecksum(uint8_t* dex_file) {
header->checksum_ = adler_checksum;
}
-class DexFileVerifierTest : public testing::Test {
+class DexFileVerifierTest : public ::testing::Test {
protected:
DexFile* GetDexFile(const uint8_t* dex_bytes, size_t length) {
auto container = std::make_shared<MemoryDexFileContainer>(dex_bytes, length);
diff --git a/libdexfile/dex/type_lookup_table_test.cc b/libdexfile/dex/type_lookup_table_test.cc
index 4316be0bd6..27da71cf25 100644
--- a/libdexfile/dex/type_lookup_table_test.cc
+++ b/libdexfile/dex/type_lookup_table_test.cc
@@ -49,14 +49,14 @@ TEST_P(TypeLookupTableTest, Find) {
INSTANTIATE_TEST_CASE_P(FindNonExistingClassWithoutCollisions,
TypeLookupTableTest,
- testing::Values(DescriptorClassDefIdxPair("LAB;", 1U)));
+ ::testing::Values(DescriptorClassDefIdxPair("LAB;", 1U)));
INSTANTIATE_TEST_CASE_P(FindNonExistingClassWithCollisions,
TypeLookupTableTest,
- testing::Values(DescriptorClassDefIdxPair("LDA;", dex::kDexNoIndex)));
+ ::testing::Values(DescriptorClassDefIdxPair("LDA;", dex::kDexNoIndex)));
INSTANTIATE_TEST_CASE_P(FindClassNoCollisions,
TypeLookupTableTest,
- testing::Values(DescriptorClassDefIdxPair("LC;", 2U)));
+ ::testing::Values(DescriptorClassDefIdxPair("LC;", 2U)));
INSTANTIATE_TEST_CASE_P(FindClassWithCollisions,
TypeLookupTableTest,
- testing::Values(DescriptorClassDefIdxPair("LAB;", 1U)));
+ ::testing::Values(DescriptorClassDefIdxPair("LAB;", 1U)));
} // namespace art
diff --git a/libdexfile/dex/utf_test.cc b/libdexfile/dex/utf_test.cc
index 85c74d285c..e8c3313286 100644
--- a/libdexfile/dex/utf_test.cc
+++ b/libdexfile/dex/utf_test.cc
@@ -26,7 +26,7 @@
namespace art {
-class UtfTest : public testing::Test {};
+class UtfTest : public ::testing::Test {};
TEST_F(UtfTest, GetLeadingUtf16Char) {
EXPECT_EQ(0xffff, GetLeadingUtf16Char(0xeeeeffff));
diff --git a/libnativebridge/tests/NativeBridgeTest.h b/libnativebridge/tests/NativeBridgeTest.h
index 88ea0e33c8..1b9415db58 100644
--- a/libnativebridge/tests/NativeBridgeTest.h
+++ b/libnativebridge/tests/NativeBridgeTest.h
@@ -34,7 +34,7 @@ constexpr const char* kNativeBridgeLibrary8 = "libnativebridge8-test-case.so";
namespace android {
-class NativeBridgeTest : public testing::Test {
+class NativeBridgeTest : public ::testing::Test {
protected:
NativeBridgeTest() : temp_dir_() {
app_data_dir_ = std::string(temp_dir_.path);
diff --git a/libnativeloader/native_loader_api_test.cpp b/libnativeloader/native_loader_api_test.cpp
index aeda1cc2a7..6ef7d36134 100644
--- a/libnativeloader/native_loader_api_test.cpp
+++ b/libnativeloader/native_loader_api_test.cpp
@@ -38,7 +38,7 @@ using ::testing::StrEq;
class NativeLoaderLazyTest : public ::testing::Test {
protected:
void SetUp() override {
- jni_mock = std::make_unique<testing::NiceMock<MockJni>>();
+ jni_mock = std::make_unique<::testing::NiceMock<MockJni>>();
env = std::make_unique<JNIEnv>();
env->functions = CreateJNINativeInterface();
}
diff --git a/libnativeloader/native_loader_test.cpp b/libnativeloader/native_loader_test.cpp
index a07551032c..90810647c3 100644
--- a/libnativeloader/native_loader_test.cpp
+++ b/libnativeloader/native_loader_test.cpp
@@ -131,7 +131,7 @@ class MockPlatform : public Platform {
ON_CALL(*this, NativeBridgeIsSupported(_)).WillByDefault(Return(is_bridged_));
ON_CALL(*this, NativeBridgeIsPathSupported(_)).WillByDefault(Return(is_bridged_));
ON_CALL(*this, mock_get_exported_namespace(_, _))
- .WillByDefault(testing::Invoke([](bool, const char* name) -> mock_namespace_handle {
+ .WillByDefault(::testing::Invoke([](bool, const char* name) -> mock_namespace_handle {
if (namespaces.find(name) != namespaces.end()) {
return namespaces[name];
}
@@ -274,8 +274,8 @@ class NativeLoaderTest : public ::testing::TestWithParam<bool> {
bool IsBridged() { return GetParam(); }
void SetUp() override {
- mock = std::make_unique<testing::NiceMock<MockPlatform>>(IsBridged());
- jni_mock = std::make_unique<testing::NiceMock<MockJni>>();
+ mock = std::make_unique<::testing::NiceMock<MockPlatform>>(IsBridged());
+ jni_mock = std::make_unique<::testing::NiceMock<MockJni>>();
env = std::make_unique<JNIEnv>();
env->functions = CreateJNINativeInterface();
@@ -379,7 +379,7 @@ TEST_P(NativeLoaderTest, OpenNativeLibraryWithoutClassloaderAndCallerLocation) {
EXPECT_EQ(errmsg, nullptr);
}
-INSTANTIATE_TEST_SUITE_P(NativeLoaderTests, NativeLoaderTest, testing::Bool());
+INSTANTIATE_TEST_SUITE_P(NativeLoaderTests, NativeLoaderTest, ::testing::Bool());
/////////////////////////////////////////////////////////////////
@@ -439,8 +439,8 @@ class NativeLoaderTest_Create : public NativeLoaderTest {
ON_CALL(*jni_mock, JniObject_getParent(StrEq(class_loader))).WillByDefault(Return(nullptr));
- EXPECT_CALL(*mock, NativeBridgeIsPathSupported(_)).Times(testing::AnyNumber());
- EXPECT_CALL(*mock, NativeBridgeInitialized()).Times(testing::AnyNumber());
+ EXPECT_CALL(*mock, NativeBridgeIsPathSupported(_)).Times(::testing::AnyNumber());
+ EXPECT_CALL(*mock, NativeBridgeInitialized()).Times(::testing::AnyNumber());
EXPECT_CALL(*mock, mock_create_namespace(
Eq(IsBridged()), StartsWith(expected_namespace_prefix + "-"), nullptr,
@@ -684,7 +684,7 @@ TEST_P(NativeLoaderTest_Create, TwoApks) {
}
}
-INSTANTIATE_TEST_SUITE_P(NativeLoaderTests_Create, NativeLoaderTest_Create, testing::Bool());
+INSTANTIATE_TEST_SUITE_P(NativeLoaderTests_Create, NativeLoaderTest_Create, ::testing::Bool());
const std::function<Result<bool>(const struct ConfigEntry&)> always_true =
[](const struct ConfigEntry&) -> Result<bool> { return true; };
diff --git a/oatdump/oatdump_test.cc b/oatdump/oatdump_test.cc
index fa46202327..bc25896c46 100644
--- a/oatdump/oatdump_test.cc
+++ b/oatdump/oatdump_test.cc
@@ -22,7 +22,7 @@ namespace art {
INSTANTIATE_TEST_SUITE_P(DynamicOrStatic,
OatDumpTest,
- testing::Values(Flavor::kDynamic, Flavor::kStatic));
+ ::testing::Values(Flavor::kDynamic, Flavor::kStatic));
// Disable tests on arm and arm64 as they are taking too long to run. b/27824283.
#define TEST_DISABLED_FOR_ARM_AND_ARM64() \
diff --git a/oatdump/oatdump_test.h b/oatdump/oatdump_test.h
index 9af33578db..eb713357d9 100644
--- a/oatdump/oatdump_test.h
+++ b/oatdump/oatdump_test.h
@@ -41,7 +41,7 @@ enum class Flavor {
kStatic, // oatdump(d)s, dex2oat(d)s
};
-class OatDumpTest : public CommonRuntimeTest, public testing::WithParamInterface<Flavor> {
+class OatDumpTest : public CommonRuntimeTest, public ::testing::WithParamInterface<Flavor> {
protected:
virtual void SetUp() {
CommonRuntimeTest::SetUp();
diff --git a/odrefresh/odr_metrics_record_test.cc b/odrefresh/odr_metrics_record_test.cc
index 8c24156aa4..1208e188e2 100644
--- a/odrefresh/odr_metrics_record_test.cc
+++ b/odrefresh/odr_metrics_record_test.cc
@@ -132,7 +132,7 @@ TEST_F(OdrMetricsRecordTest, HappyPath) {
TEST_F(OdrMetricsRecordTest, EmptyInput) {
OdrMetricsRecord record{};
- ASSERT_THAT(record.ReadFromFile(file_path_), testing::Not(Ok()));
+ ASSERT_THAT(record.ReadFromFile(file_path_), ::testing::Not(Ok()));
}
TEST_F(OdrMetricsRecordTest, UnexpectedInput) {
diff --git a/runtime/arch/memcmp16_test.cc b/runtime/arch/memcmp16_test.cc
index 37aad21a40..21d3f13ab7 100644
--- a/runtime/arch/memcmp16_test.cc
+++ b/runtime/arch/memcmp16_test.cc
@@ -30,8 +30,7 @@ class RandGen {
uint32_t val_;
};
-class MemCmp16Test : public testing::Test {
-};
+class MemCmp16Test : public ::testing::Test {};
// A simple implementation to compare against.
// Note: this version is equivalent to the generic one used when no optimized version is available.
diff --git a/runtime/common_runtime_test.h b/runtime/common_runtime_test.h
index 7c20de30fd..1866583058 100644
--- a/runtime/common_runtime_test.h
+++ b/runtime/common_runtime_test.h
@@ -244,10 +244,10 @@ class CommonRuntimeTestBase : public TestType, public CommonRuntimeTestImpl {
}
};
-using CommonRuntimeTest = CommonRuntimeTestBase<testing::Test>;
+using CommonRuntimeTest = CommonRuntimeTestBase<::testing::Test>;
template <typename Param>
-using CommonRuntimeTestWithParam = CommonRuntimeTestBase<testing::TestWithParam<Param>>;
+using CommonRuntimeTestWithParam = CommonRuntimeTestBase<::testing::TestWithParam<Param>>;
// Sets a CheckJni abort hook to catch failures. Note that this will cause CheckJNI to carry on
// rather than aborting, so be careful!
diff --git a/runtime/exec_utils_test.cc b/runtime/exec_utils_test.cc
index eb21652c19..636383d474 100644
--- a/runtime/exec_utils_test.cc
+++ b/runtime/exec_utils_test.cc
@@ -102,7 +102,7 @@ class NeverFallbackExecUtils : public TestingExecUtils {
}
};
-class ExecUtilsTest : public CommonRuntimeTest, public testing::WithParamInterface<bool> {
+class ExecUtilsTest : public CommonRuntimeTest, public ::testing::WithParamInterface<bool> {
protected:
void SetUp() override {
CommonRuntimeTest::SetUp();
@@ -390,6 +390,6 @@ TEST_P(ExecUtilsTest, ExecNewProcessGroupFalse) {
&error_msg);
}
-INSTANTIATE_TEST_SUITE_P(AlwaysOrNeverFallback, ExecUtilsTest, testing::Values(true, false));
+INSTANTIATE_TEST_SUITE_P(AlwaysOrNeverFallback, ExecUtilsTest, ::testing::Values(true, false));
} // namespace art
diff --git a/runtime/gc/space/space_create_test.cc b/runtime/gc/space/space_create_test.cc
index 83568351b3..759c5de4ef 100644
--- a/runtime/gc/space/space_create_test.cc
+++ b/runtime/gc/space/space_create_test.cc
@@ -351,10 +351,10 @@ TEST_P(SpaceCreateTest, AllocAndFreeListTestBody) {
INSTANTIATE_TEST_CASE_P(CreateRosAllocSpace,
SpaceCreateTest,
- testing::Values(kMallocSpaceRosAlloc));
+ ::testing::Values(kMallocSpaceRosAlloc));
INSTANTIATE_TEST_CASE_P(CreateDlMallocSpace,
SpaceCreateTest,
- testing::Values(kMallocSpaceDlMalloc));
+ ::testing::Values(kMallocSpaceDlMalloc));
} // namespace space
} // namespace gc
diff --git a/runtime/jit/jit_memory_region_test.cc b/runtime/jit/jit_memory_region_test.cc
index 449255a7f7..b17e01fff9 100644
--- a/runtime/jit/jit_memory_region_test.cc
+++ b/runtime/jit/jit_memory_region_test.cc
@@ -52,7 +52,7 @@ static void registerSignalHandler() {
sigaction(SIGSEGV, &sa, nullptr);
}
-class TestZygoteMemory : public testing::Test {
+class TestZygoteMemory : public ::testing::Test {
public:
void BasicTest() {
// Zygote JIT memory only works on kernels that don't segfault on flush.
diff --git a/runtime/metrics/reporter_test.cc b/runtime/metrics/reporter_test.cc
index 039e43ca48..b3a0c025ca 100644
--- a/runtime/metrics/reporter_test.cc
+++ b/runtime/metrics/reporter_test.cc
@@ -399,7 +399,7 @@ TEST_F(MetricsReporterTest, CompilerFilter) {
}
// Test class for period spec parsing
-class ReportingPeriodSpecTest : public testing::Test {
+class ReportingPeriodSpecTest : public ::testing::Test {
public:
void VerifyFalse(const std::string& spec_str) {
Verify(spec_str, false, false, false, {});
diff --git a/runtime/oat/oat_file_assistant_test.cc b/runtime/oat/oat_file_assistant_test.cc
index b1f196a23a..5bd9d1ed32 100644
--- a/runtime/oat/oat_file_assistant_test.cc
+++ b/runtime/oat/oat_file_assistant_test.cc
@@ -52,7 +52,7 @@ namespace art HIDDEN {
class OatFileAssistantBaseTest : public DexoptTest {};
class OatFileAssistantTest : public OatFileAssistantBaseTest,
- public testing::WithParamInterface<bool> {
+ public ::testing::WithParamInterface<bool> {
public:
void SetUp() override {
DexoptTest::SetUp();
@@ -2593,6 +2593,8 @@ TEST_P(OatFileAssistantTest, ValidateBootClassPathChecksums) {
// - Oat file corrupted after status check, before reload unexecutable
// because it's unrelocated and no dex2oat
-INSTANTIATE_TEST_SUITE_P(WithOrWithoutRuntime, OatFileAssistantTest, testing::Values(true, false));
+INSTANTIATE_TEST_SUITE_P(WithOrWithoutRuntime,
+ OatFileAssistantTest,
+ ::testing::Values(true, false));
} // namespace art
diff --git a/sigchainlib/sigchain_test.cc b/sigchainlib/sigchain_test.cc
index 3a68381117..238aea3152 100644
--- a/sigchainlib/sigchain_test.cc
+++ b/sigchainlib/sigchain_test.cc
@@ -104,7 +104,8 @@ static void TestSignalBlocking(const std::function<void()>& fn) {
fn();
- if (testing::Test::HasFatalFailure()) return;
+ if (::testing::Test::HasFatalFailure())
+ return;
ASSERT_EQ(0, RealSigprocmask(SIG_SETMASK, nullptr, &mask));
ASSERT_FALSE(sigismember64(&mask, SIGSEGV));
}
@@ -266,7 +267,7 @@ DISABLE_HWASAN void fault_address_tag_impl() {
auto* tagged_null = reinterpret_cast<int*>(0x2bULL << 56);
EXPECT_EXIT(
- { [[maybe_unused]] volatile int load = *tagged_null; }, testing::ExitedWithCode(0), "");
+ { [[maybe_unused]] volatile int load = *tagged_null; }, ::testing::ExitedWithCode(0), "");
// Our sigaction implementation always implements the "clear unknown bits"
// semantics for oldact.sa_flags regardless of kernel version so we rely on it
@@ -275,9 +276,10 @@ DISABLE_HWASAN void fault_address_tag_impl() {
ASSERT_EQ(0, sigaction(SIGSEGV, &action, nullptr));
ASSERT_EQ(0, sigaction(SIGSEGV, nullptr, &action));
if (action.sa_flags & SA_EXPOSE_TAGBITS) {
- EXPECT_EXIT({ [[maybe_unused]] volatile int load = *tagged_null; },
- testing::ExitedWithCode(0x2b),
- "");
+ EXPECT_EXIT(
+ { [[maybe_unused]] volatile int load = *tagged_null; },
+ ::testing::ExitedWithCode(0x2b),
+ "");
}
}
#endif
diff --git a/test/generate-boot-image/generate-boot-image.cc b/test/generate-boot-image/generate-boot-image.cc
index 454b63185a..539670fa85 100644
--- a/test/generate-boot-image/generate-boot-image.cc
+++ b/test/generate-boot-image/generate-boot-image.cc
@@ -46,7 +46,6 @@ using ::android::base::ParseBool;
using ::android::base::ParseBoolResult;
using ::android::base::StringPrintf;
using ::art::testing::GetLibCoreDexFileNames;
-using ::art::testing::GetLibCoreDexLocations;
constexpr const char* kUsage = R"(
A commandline tool to generate a primary boot image for testing.
@@ -141,7 +140,7 @@ int GenerateBootImage(const Options& options) {
if (options.android_root_for_location) {
dex_locations = dex_files;
} else {
- dex_locations = GetLibCoreDexLocations(options.core_only);
+ dex_locations = GetLibCoreDexFileNames(/*prefix=*/"", options.core_only);
}
args.push_back("--runtime-arg");
args.push_back("-Xbootclasspath:" + Join(dex_files, ":"));
diff --git a/test/standalone_test_lib_check.cc b/test/standalone_test_lib_check.cc
index 426a302f54..72c835a658 100644
--- a/test/standalone_test_lib_check.cc
+++ b/test/standalone_test_lib_check.cc
@@ -180,6 +180,6 @@ TEST(StandaloneTestAllowedLibDeps, test) {
disallowed_libs.push_back(dyn_lib_dep);
}
- EXPECT_THAT(disallowed_libs, testing::IsEmpty())
+ EXPECT_THAT(disallowed_libs, ::testing::IsEmpty())
<< path_to_self.value() << " has disallowed shared library dependencies.";
}