diff options
author | 2020-07-01 11:29:47 +0000 | |
---|---|---|
committer | 2020-07-01 12:41:06 +0000 | |
commit | 0a17b6a0e705e45cf47407d0573ef8a7fd67cd99 (patch) | |
tree | 9b864aae8d952fc0ee2829672220774c91494303 | |
parent | b7f4d0f15f02224ce5048ba566b2dce193ee103a (diff) |
Revert "Support running of host gtests in eng-prod"
This reverts commit 22872da653053bb4b86fbef67163a9f6b7aee25b.
Reason for revert: Checking if this CL is cause of b/160132136
Bug: 147817558
Bug: 160132136
Change-Id: Ifb6f2292292a7f69fbd0f2e9204fd37dbca84277
-rw-r--r-- | build/Android.gtest.mk | 18 | ||||
-rw-r--r-- | build/art.go | 9 | ||||
-rw-r--r-- | build/makevars.go | 27 | ||||
-rw-r--r-- | compiler/utils/assembler_test.h | 1 | ||||
-rw-r--r-- | libartbase/base/common_art_test.cc | 73 | ||||
-rw-r--r-- | libnativeloader/Android.bp | 13 | ||||
-rw-r--r-- | test/Android.bp | 5 |
7 files changed, 56 insertions, 90 deletions
diff --git a/build/Android.gtest.mk b/build/Android.gtest.mk index 73310339b2..083bb9e6d9 100644 --- a/build/Android.gtest.mk +++ b/build/Android.gtest.mk @@ -25,13 +25,12 @@ my_files := $(ART_TESTCASES_CONTENT) # Manually add system libraries that we need to run the host ART tools. my_files += \ - $(foreach lib, libbacktrace libbase libc++ libicu_jni liblog libsigchain libunwindstack \ - libziparchive libjavacore libandroidio libopenjdkd, \ - $(call intermediates-dir-for,SHARED_LIBRARIES,$(lib),HOST)/$(lib).so:lib64/$(lib).so \ - $(call intermediates-dir-for,SHARED_LIBRARIES,$(lib),HOST,,2ND)/$(lib).so:lib/$(lib).so) \ - $(foreach lib, libcrypto libz libicuuc libicui18n libandroidicu libexpat, \ - $(call intermediates-dir-for,SHARED_LIBRARIES,$(lib),HOST)/$(lib).so:lib64/$(lib)-host.so \ - $(call intermediates-dir-for,SHARED_LIBRARIES,$(lib),HOST,,2ND)/$(lib).so:lib/$(lib)-host.so) + $(foreach lib, \ + libbacktrace libbase libc++ libicu_jni liblog libsigchain libunwindstack libziparchive, \ + $(call intermediates-dir-for,SHARED_LIBRARIES,$(lib),HOST)/$(lib).so:lib64/$(lib).so) \ + $(foreach lib, \ + libcrypto libz, \ + $(call intermediates-dir-for,SHARED_LIBRARIES,$(lib),HOST)/$(lib).so:lib64/$(lib)-host.so) # Add apex directories for art, conscrypt and i18n. my_files += $(foreach infix,_ _VDEX_,$(foreach suffix,$(HOST_ARCH) $(HOST_2ND_ARCH), \ @@ -40,8 +39,7 @@ my_files += \ $(foreach jar,$(CORE_IMG_JARS),\ $(HOST_OUT_JAVA_LIBRARIES)/$(jar)-hostdex.jar:apex/com.android.art/javalib/$(jar).jar) \ $(HOST_OUT_JAVA_LIBRARIES)/conscrypt-hostdex.jar:apex/com.android.conscrypt/javalib/conscrypt.jar\ - $(HOST_OUT_JAVA_LIBRARIES)/core-icu4j-hostdex.jar:apex/com.android.i18n/javalib/core-icu4j.jar \ - $(HOST_OUT)/com.android.i18n/etc/icu/icudt66l.dat:com.android.i18n/etc/icu/icudt66l.dat + $(HOST_OUT_JAVA_LIBRARIES)/core-icu4j-hostdex.jar:apex/com.android.i18n/javalib/core-icu4j.jar # Create dummy module that will copy all the data files into testcases directory. # For now, this copies everything to "out/host/linux-x86/" subdirectory, since it @@ -53,7 +51,7 @@ LOCAL_MODULE_TAGS := tests LOCAL_MODULE_CLASS := NATIVE_TESTS LOCAL_MODULE_SUFFIX := .txt LOCAL_COMPATIBILITY_SUITE := general-tests -LOCAL_COMPATIBILITY_SUPPORT_FILES := $(ART_TESTCASES_PREBUILT_CONTENT) \ +LOCAL_COMPATIBILITY_SUPPORT_FILES := \ $(foreach f,$(my_files),$(call word-colon,1,$f):out/host/linux-x86/$(call word-colon,2,$f)) include $(BUILD_SYSTEM)/base_rules.mk diff --git a/build/art.go b/build/art.go index af2a5deb54..8deea23098 100644 --- a/build/art.go +++ b/build/art.go @@ -291,11 +291,10 @@ func addTestcasesFile(ctx android.InstallHookContext) { defer artTestMutex.Unlock() if ctx.Os().Class == android.Host { - src := ctx.SrcPath().String() - path := strings.Split(ctx.Path().ToMakePath().String(), "/") - // Keep last two parts of the install path (e.g. bin/dex2oat). - dst := strings.Join(path[len(path)-2:], "/") - testcasesContent[dst] = src + path := ctx.Path().ToMakePath().String() + parts := strings.Split(path, "/") + // Keep last two parts of the path (e.g. bin/dex2oat). + testcasesContent[strings.Join(parts[len(parts)-2:], "/")] = path } } diff --git a/build/makevars.go b/build/makevars.go index 22ef205c86..6e66966bf5 100644 --- a/build/makevars.go +++ b/build/makevars.go @@ -15,22 +15,18 @@ package art import ( - "path/filepath" "sort" "strings" "android/soong/android" - "android/soong/cc/config" ) var ( - pctx = android.NewPackageContext("android/soong/art") - prebuiltToolsForTests = []string{"as", "addr2line", "objdump"} + pctx = android.NewPackageContext("android/soong/art") ) func init() { android.RegisterMakeVarsProvider(pctx, makeVarsProvider) - pctx.Import("android/soong/cc/config") } func makeVarsProvider(ctx android.MakeVarsContext) { @@ -56,25 +52,4 @@ func makeVarsProvider(ctx android.MakeVarsContext) { copy_cmds = append(copy_cmds, testcasesContent[key]+":"+key) } ctx.Strict("ART_TESTCASES_CONTENT", strings.Join(copy_cmds, " ")) - - // Add prebuilt tools. - copy_cmds = []string{} - for _, cmd := range prebuiltToolsForTests { - target := ctx.Config().Targets[android.BuildOs][0] - toolchain := config.FindToolchain(target.Os, target.Arch) - gccRoot, gccTriple := toolchain.GccRoot(), toolchain.GccTriple() - eval := func(path ...string) string { - result, err := ctx.Eval(filepath.Join(path...)) - if err != nil { - panic(err) - } - return result - } - src := eval(gccRoot, "bin", gccTriple+"-"+cmd) - // Different tests use different paths, so we need to copy to two locations. - // TODO: Unify the test code so that this is no longer necessary. - copy_cmds = append(copy_cmds, src+":"+eval(gccRoot, "bin", gccTriple+"-"+cmd)) - copy_cmds = append(copy_cmds, src+":"+eval(gccRoot, gccTriple, "bin", cmd)) - } - ctx.Strict("ART_TESTCASES_PREBUILT_CONTENT", strings.Join(copy_cmds, " ")) } diff --git a/compiler/utils/assembler_test.h b/compiler/utils/assembler_test.h index 268befba3b..9e23d11116 100644 --- a/compiler/utils/assembler_test.h +++ b/compiler/utils/assembler_test.h @@ -738,7 +738,6 @@ class AssemblerTest : public testing::Test { AssemblerTest() {} void SetUp() override { - CommonArtTest::SetUpAndroidRootEnvVars(); allocator_.reset(new ArenaAllocator(&pool_)); assembler_.reset(CreateAssembler(allocator_.get())); test_helper_.reset( diff --git a/libartbase/base/common_art_test.cc b/libartbase/base/common_art_test.cc index e327832a7b..2497e77e75 100644 --- a/libartbase/base/common_art_test.cc +++ b/libartbase/base/common_art_test.cc @@ -141,40 +141,53 @@ void ScratchFile::Unlink() { void CommonArtTestImpl::SetUpAndroidRootEnvVars() { if (IsHost()) { - // Look at how we were invoked to extract reasonable default paths. - 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")) { - char* cwd = getcwd(nullptr, 0); - setenv("ANDROID_BUILD_TOP", cwd, /*overwrite=*/ 0); // No-op if already set. - free(cwd); - setenv("ANDROID_HOST_OUT", path.c_str(), /*overwrite=*/ 0); // No-op if already set. - break; + // Make sure that ANDROID_BUILD_TOP is set. If not, set it from CWD. + const char* android_build_top_from_env = getenv("ANDROID_BUILD_TOP"); + if (android_build_top_from_env == nullptr) { + // Not set by build server, so default to current directory. + char* cwd = getcwd(nullptr, 0); + setenv("ANDROID_BUILD_TOP", cwd, 1); + free(cwd); + android_build_top_from_env = getenv("ANDROID_BUILD_TOP"); + } + + const char* android_host_out_from_env = getenv("ANDROID_HOST_OUT"); + if (android_host_out_from_env == nullptr) { + // Not set by build server, so default to the usual value of + // ANDROID_HOST_OUT. + std::string android_host_out; +#if defined(__linux__) + // Fallback + android_host_out = std::string(android_build_top_from_env) + "/out/host/linux-x86"; + // Look at how we were invoked + std::string argv; + if (android::base::ReadFileToString("/proc/self/cmdline", &argv)) { + // /proc/self/cmdline is the programs 'argv' with elements delimited by '\0'. + std::string cmdpath(argv.substr(0, argv.find('\0'))); + std::filesystem::path path(cmdpath); + // If the path is relative then prepend the android_build_top_from_env to it + if (path.is_relative()) { + path = std::filesystem::path(android_build_top_from_env).append(cmdpath); + DCHECK(path.is_absolute()) << path; } - // We are running tests from testcases (extracted from zip) on tradefed. - if (path.filename() == std::filesystem::path("testcases")) { - path.append("art_common"); - bool ok = chdir(path.c_str()) == 0; - CHECK(ok); - setenv("ANDROID_BUILD_TOP", path.c_str(), /*overwrite=*/ 0); // No-op if already set. - path.append("out/host/linux-x86"); - setenv("ANDROID_HOST_OUT", path.c_str(), /*overwrite=*/ 0); // No-op if already set. - break; + // Walk up until we find the linux-x86 directory or we hit the root directory. + while (path.has_parent_path() && path.parent_path() != path && + path.filename() != std::filesystem::path("linux-x86")) { + path = path.parent_path(); + } + // If we found a linux-x86 directory path is now android_host_out + if (path.filename() == std::filesystem::path("linux-x86")) { + android_host_out = path.string(); } } +#elif defined(__APPLE__) + android_host_out = std::string(android_build_top_from_env) + "/out/host/darwin-x86"; +#else +#error unsupported OS +#endif + setenv("ANDROID_HOST_OUT", android_host_out.c_str(), 1); + android_host_out_from_env = getenv("ANDROID_HOST_OUT"); } - const char* android_build_top_from_env = getenv("ANDROID_BUILD_TOP"); - DCHECK(android_build_top_from_env != nullptr); - DCHECK(std::filesystem::exists(android_build_top_from_env)) << android_build_top_from_env; - const char* android_host_out_from_env = getenv("ANDROID_HOST_OUT"); - DCHECK(android_host_out_from_env != nullptr); - DCHECK(std::filesystem::exists(android_host_out_from_env)) << android_host_out_from_env; // Environment variable ANDROID_ROOT is set on the device, but not // necessarily on the host. diff --git a/libnativeloader/Android.bp b/libnativeloader/Android.bp index 33a2c8f483..5f29b4d626 100644 --- a/libnativeloader/Android.bp +++ b/libnativeloader/Android.bp @@ -35,19 +35,6 @@ art_cc_library { "libbase", ], target: { - // Library search path needed for running host tests remotely (from testcases directory). - linux_glibc_x86: { - ldflags: [ - "-Wl,-rpath,$ORIGIN/../art_common/out/host/linux-x86/lib", - "-Wl,--enable-new-dtags", - ], - }, - linux_glibc_x86_64: { - ldflags: [ - "-Wl,-rpath,$ORIGIN/../art_common/out/host/linux-x86/lib64", - "-Wl,--enable-new-dtags", - ], - }, android: { srcs: [ "library_namespaces.cpp", diff --git a/test/Android.bp b/test/Android.bp index 6be4562070..021a70fd44 100644 --- a/test/Android.bp +++ b/test/Android.bp @@ -54,11 +54,6 @@ art_cc_defaults { "art_defaults", ], - test_suites: ["general-tests"], - test_options: { - test_suite_tag: ["art-host-gtest"], - }, - shared_libs: [ "libartd", "libartd-disassembler", |