diff options
author | 2020-07-09 13:40:57 +0100 | |
---|---|---|
committer | 2020-07-15 14:33:43 +0000 | |
commit | 7400a5466a04f9a274d262c5cb1fd35ff496839a (patch) | |
tree | 8e4d617b0e0fdfda2c089a6a30353d470c0fb2b3 | |
parent | b461b53c926dae7f1959a309b0a2b109b6d3c4d3 (diff) |
Fixes for gtests in eng-prod
Bug: 147817558
Test: art/art-host-gtest on forrest
Change-Id: I0ecfbc81fe6998d4c8c69ce6fbeb35bdd5908b55
-rw-r--r-- | build/art.go | 5 | ||||
-rw-r--r-- | build/makevars.go | 6 | ||||
-rw-r--r-- | libartbase/base/common_art_test.cc | 10 | ||||
-rw-r--r-- | libartbase/base/file_utils_test.cc | 5 | ||||
-rw-r--r-- | runtime/arch/arm/instruction_set_features_arm.cc | 2 | ||||
-rw-r--r-- | runtime/hidden_api_test.cc | 1 | ||||
-rw-r--r-- | runtime/native_stack_dump.cc | 14 | ||||
-rw-r--r-- | runtime/prebuilt_tools_test.cc | 2 | ||||
-rw-r--r-- | test/README.md | 10 |
9 files changed, 38 insertions, 17 deletions
diff --git a/build/art.go b/build/art.go index af2a5deb54..6e9e9fda6e 100644 --- a/build/art.go +++ b/build/art.go @@ -17,6 +17,7 @@ package art import ( "fmt" "log" + "path/filepath" "strings" "sync" @@ -25,6 +26,7 @@ import ( "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 @@ func hostFlags(ctx android.LoadHookContext) []string { 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 3b9d0a6cc0..1965b5d26f 100644 --- a/build/makevars.go +++ b/build/makevars.go @@ -20,6 +20,7 @@ import ( "strings" "android/soong/android" + "android/soong/cc/config" ) var ( @@ -67,10 +68,7 @@ func makeVarsProvider(ctx android.MakeVarsContext) { 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 a087aa5316..fd6da87bc5 100644 --- a/libartbase/base/common_art_test.cc +++ b/libartbase/base/common_art_test.cc @@ -301,11 +301,17 @@ void CommonArtTestImpl::TearDownAndroidDataDir(const std::string& android_data, // 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 @@ std::unique_ptr<const DexFile> CommonArtTestImpl::LoadExpectSingleDexFile(const 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 85c110465f..313754e5a6 100644 --- a/libartbase/base/file_utils_test.cc +++ b/libartbase/base/file_utils_test.cc @@ -58,7 +58,9 @@ TEST_F(FileUtilsTest, GetSystemImageFilename) { 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 @@ TEST_F(FileUtilsTest, GetAndroidRootSafe) { // 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 fdf4dbd7be..b01f5198d1 100644 --- a/runtime/arch/arm/instruction_set_features_arm.cc +++ b/runtime/arch/arm/instruction_set_features_arm.cc @@ -257,7 +257,7 @@ ArmFeaturesUniquePtr ArmInstructionSetFeatures::FromAssembly() { // 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 16df6d751d..e933c01433 100644 --- a/runtime/hidden_api_test.cc +++ b/runtime/hidden_api_test.cc @@ -633,6 +633,7 @@ TEST_F(HiddenApiTest, DexDomain_SystemExtDir) { 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 74d9033b15..4b2409ba73 100644 --- a/runtime/native_stack_dump.cc +++ b/runtime/native_stack_dump.cc @@ -69,14 +69,12 @@ using android::base::StringPrintf; 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 @@ static void Addr2line(const std::string& map_src, } // 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 17c0d42e9d..e05a8e4113 100644 --- a/runtime/prebuilt_tools_test.cc +++ b/runtime/prebuilt_tools_test.cc @@ -28,7 +28,7 @@ namespace art { 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 d199bfea1c..8a4b589fb2 100644 --- a/test/README.md +++ b/test/README.md @@ -140,6 +140,16 @@ $ art/test.py --host -r -t 001-HelloWorld $ 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 |