Fixes for gtests in eng-prod
Bug: 147817558
Test: art/art-host-gtest on forrest
Change-Id: I0ecfbc81fe6998d4c8c69ce6fbeb35bdd5908b55
diff --git a/build/art.go b/build/art.go
index af2a5de..6e9e9fd 100644
--- a/build/art.go
+++ b/build/art.go
@@ -17,6 +17,7 @@
import (
"fmt"
"log"
+ "path/filepath"
"strings"
"sync"
@@ -25,6 +26,7 @@
"android/soong/android"
"android/soong/apex"
"android/soong/cc"
+ "android/soong/cc/config"
)
var supportedArches = []string{"arm", "arm64", "x86", "x86_64"}
@@ -167,6 +169,9 @@
cflags = append(cflags, "-DART_ENABLE_ADDRESS_SANITIZER=1")
}
+ clang_path := filepath.Join(config.ClangDefaultBase, ctx.Config().PrebuiltOS(), config.ClangDefaultVersion)
+ cflags = append(cflags, "-DART_CLANG_PATH=\""+clang_path+"\"")
+
return cflags
}
diff --git a/build/makevars.go b/build/makevars.go
index 3b9d0a6..1965b5d 100644
--- a/build/makevars.go
+++ b/build/makevars.go
@@ -20,6 +20,7 @@
"strings"
"android/soong/android"
+ "android/soong/cc/config"
)
var (
@@ -67,10 +68,7 @@
ctx.Strict("ART_TESTCASES_CONTENT", strings.Join(copy_cmds, " "))
// Add prebuilt tools.
- clang_path, err := ctx.Eval("${config.ClangPath}")
- if err != nil {
- panic(err)
- }
+ clang_path := filepath.Join(config.ClangDefaultBase, ctx.Config().PrebuiltOS(), config.ClangDefaultVersion)
copy_cmds = []string{}
for _, tool := range prebuiltToolsForTests {
src := filepath.Join(clang_path, "/", tool)
diff --git a/libartbase/base/common_art_test.cc b/libartbase/base/common_art_test.cc
index a087aa5..fd6da87 100644
--- a/libartbase/base/common_art_test.cc
+++ b/libartbase/base/common_art_test.cc
@@ -301,11 +301,17 @@
// Get prebuilt binary tool.
// The paths need to be updated when Android prebuilts update.
std::string CommonArtTestImpl::GetAndroidTool(const char* name, InstructionSet) {
- std::string path = GetAndroidBuildTop() + "prebuilts/clang/host/linux-x86/clang-r383902b/bin/";
+#ifdef ART_TARGET_ANDROID
+ UNUSED(name);
+ LOG(FATAL) << "There are no prebuilt tools available when running on target.";
+ UNREACHABLE();
+#else
+ std::string path = GetAndroidBuildTop() + ART_CLANG_PATH + "/bin/";
CHECK(OS::DirectoryExists(path.c_str())) << path;
path += name;
CHECK(OS::FileExists(path.c_str())) << path;
return path;
+#endif
}
std::string CommonArtTestImpl::GetCoreArtLocation() {
@@ -322,7 +328,7 @@
MemMap::Init();
static constexpr bool kVerifyChecksum = true;
const ArtDexFileLoader dex_file_loader;
- std::string filename(location);
+ std::string filename(IsHost() ? GetAndroidBuildTop() + location : location);
if (!dex_file_loader.Open(filename.c_str(),
std::string(location),
/* verify= */ true,
diff --git a/libartbase/base/file_utils_test.cc b/libartbase/base/file_utils_test.cc
index 85c1104..313754e 100644
--- a/libartbase/base/file_utils_test.cc
+++ b/libartbase/base/file_utils_test.cc
@@ -58,7 +58,9 @@
GetSystemImageFilename("/system/framework/boot.art", InstructionSet::kArm).c_str());
}
-TEST_F(FileUtilsTest, GetAndroidRootSafe) {
+// TODO(dsrbecky): b/160885380: This test is failing in eng-prod because libartbase
+// is loaded from different path (under testcases).
+TEST_F(FileUtilsTest, DISABLED_GetAndroidRootSafe) {
std::string error_msg;
// We don't expect null returns for most cases, so don't check and let std::string crash.
@@ -78,6 +80,7 @@
// Set a bogus value for ANDROID_ROOT. This should be an error.
ASSERT_EQ(0, setenv("ANDROID_ROOT", "/this/is/obviously/bogus", /* overwrite */ 1));
EXPECT_EQ(GetAndroidRootSafe(&error_msg), "");
+ error_msg = "";
// Inferring the Android Root from the location of libartbase only works on host.
if (!kIsTargetBuild) {
diff --git a/runtime/arch/arm/instruction_set_features_arm.cc b/runtime/arch/arm/instruction_set_features_arm.cc
index fdf4dbd..b01f519 100644
--- a/runtime/arch/arm/instruction_set_features_arm.cc
+++ b/runtime/arch/arm/instruction_set_features_arm.cc
@@ -257,7 +257,7 @@
// Use compile time features to "detect" LPAE support.
// TODO: write an assembly LPAE support test.
-#if defined(__ARM_FEATURE_LPAE)
+#if defined (__ARM_ARCH_8A__) || defined(__ARM_FEATURE_LPAE)
const bool has_atomic_ldrd_strd = true;
#else
const bool has_atomic_ldrd_strd = false;
diff --git a/runtime/hidden_api_test.cc b/runtime/hidden_api_test.cc
index 16df6d7..e933c01 100644
--- a/runtime/hidden_api_test.cc
+++ b/runtime/hidden_api_test.cc
@@ -633,6 +633,7 @@
TEST_F(HiddenApiTest, DexDomain_SystemFrameworkDir) {
// Load file from a system/framework directory and check that it is flagged as a framework dex.
+ std::filesystem::create_directory(GetAndroidRoot() + "/framework");
std::string system_framework_location_path = GetAndroidRoot() + "/framework/foo.jar";
ASSERT_TRUE(LocationIsOnSystemFramework(system_framework_location_path.c_str()));
diff --git a/runtime/native_stack_dump.cc b/runtime/native_stack_dump.cc
index 74d9033..4b2409b 100644
--- a/runtime/native_stack_dump.cc
+++ b/runtime/native_stack_dump.cc
@@ -69,14 +69,12 @@
static constexpr bool kUseAddr2line = !kIsTargetBuild;
std::string FindAddr2line() {
- if (!kIsTargetBuild) {
- constexpr const char* kAddr2linePrebuiltPath =
- "/prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.17-4.8/bin/x86_64-linux-addr2line";
- const char* env_value = getenv("ANDROID_BUILD_TOP");
- if (env_value != nullptr) {
- return std::string(env_value) + kAddr2linePrebuiltPath;
- }
+#ifndef ART_TARGET_ANDROID
+ const char* env_value = getenv("ANDROID_BUILD_TOP");
+ if (env_value != nullptr) {
+ return std::string(env_value) + "/" + ART_CLANG_PATH + "/bin/llvm-addr2line";
}
+#endif
return std::string("/usr/bin/addr2line");
}
@@ -274,7 +272,7 @@
}
// Send the offset.
- const std::string hex_offset = StringPrintf("%zx\n", offset);
+ const std::string hex_offset = StringPrintf("0x%zx\n", offset);
if (!pipe_ptr->out.WriteFully(hex_offset.data(), hex_offset.length())) {
// Error. :-(
diff --git a/runtime/prebuilt_tools_test.cc b/runtime/prebuilt_tools_test.cc
index 17c0d42..e05a8e4 100644
--- a/runtime/prebuilt_tools_test.cc
+++ b/runtime/prebuilt_tools_test.cc
@@ -28,7 +28,7 @@
class PrebuiltToolsTest : public CommonRuntimeTest {
public:
static void CheckToolsExist(InstructionSet isa) {
- const char* tools[] = { "clang", "llvm-objdump" };
+ const char* tools[] = { "clang", "llvm-addr2line", "llvm-dwarfdump", "llvm-objdump" };
for (const char* tool : tools) {
std::string path = GetAndroidTool(tool, isa);
ASSERT_TRUE(OS::FileExists(path.c_str())) << path;
diff --git a/test/README.md b/test/README.md
index d199bfe..8a4b589 100644
--- a/test/README.md
+++ b/test/README.md
@@ -140,6 +140,16 @@
$ art/test.py --target -r -t 001-HelloWorld
```
+## Running one gtest on the build host
+
+```sh
+$ find out/host/ -type f -name art_runtime_tests # Find the path of the test.
+$ out/host/linux-x86/nativetest/art_runtime_tests/art_runtime_tests
+```
+
+Add "--no_isolate" to run the tests one by one in single process (disable forking).
+Add "--gtest_filter=..." to select specific sub-test(s) to run.
+Prefix by "gdb --args " to run the test in gdb.
# ART Continuous Integration