diff options
author | 2020-06-22 15:39:00 +0100 | |
---|---|---|
committer | 2020-06-24 19:45:23 +0000 | |
commit | 1cf46a3342d8821fcdb700ada24ac272e85a2a39 (patch) | |
tree | 1357357f0bb79433672883c6949fdd86b896b256 | |
parent | 842e9c8c0affaff5253de233974c63ba7ba7f8b4 (diff) |
Copy tools needed by host gtests to testcases directory.
Atest requires that everything is in the testcases directory.
The files are not used yet (this is left to follow-up CLs).
Bug: 147819342
Test: check the generated general-tests.zip ("m general-tests")
Change-Id: Ied22a736e81a7cff03641d18bacd829b86a6ef0b
-rw-r--r-- | build/Android.gtest.mk | 46 | ||||
-rw-r--r-- | build/art.go | 29 | ||||
-rw-r--r-- | build/makevars.go | 8 | ||||
-rw-r--r-- | libdexfile/Android.bp | 6 | ||||
-rw-r--r-- | libnativebridge/Android.bp | 2 | ||||
-rw-r--r-- | libnativeloader/Android.bp | 2 |
6 files changed, 88 insertions, 5 deletions
diff --git a/build/Android.gtest.mk b/build/Android.gtest.mk index dc5015f661..21199dac33 100644 --- a/build/Android.gtest.mk +++ b/build/Android.gtest.mk @@ -17,6 +17,52 @@ # Build rules are excluded from Mac, since we can not run ART tests there in the first place. ifneq ($(HOST_OS),darwin) +################################################################################################### +# Create module in testcases to hold all common data and tools needed for ART host tests. + +# ART binary tools and libraries (automatic list of all art_cc_binary/art_cc_library modules). +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, \ + $(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), \ + $(DEXPREOPT_IMAGE$(infix)BUILT_INSTALLED_art_host_$(suffix)))) +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 + +# 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 +# is hard-coded in many places. TODO: Refactor tests to remove the need for this. +include $(CLEAR_VARS) +LOCAL_IS_HOST_MODULE := true +LOCAL_MODULE := art_common +LOCAL_MODULE_TAGS := tests +LOCAL_MODULE_CLASS := NATIVE_TESTS +LOCAL_MODULE_SUFFIX := .txt +LOCAL_COMPATIBILITY_SUITE := general-tests +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 + +$(LOCAL_BUILT_MODULE): + @mkdir -p $(dir $@) + echo "This directory contains common data and tools needed for ART host tests" > $@ + +my_files := +include $(CLEAR_VARS) +################################################################################################### + # The path for which all the dex files are relative, not actually the current directory. LOCAL_PATH := art/test diff --git a/build/art.go b/build/art.go index 5a09be0283..6b684c2504 100644 --- a/build/art.go +++ b/build/art.go @@ -17,6 +17,7 @@ package art import ( "fmt" "log" + "strings" "sync" "github.com/google/blueprint/proptools" @@ -274,6 +275,32 @@ func testInstall(ctx android.InstallHookContext) { testMap[name] = tests } +var testcasesContentKey = android.NewOnceKey("artTestcasesContent") + +func testcasesContent(config android.Config) map[string]string { + return config.Once(testcasesContentKey, func() interface{} { + return make(map[string]string) + }).(map[string]string) +} + +// Binaries and libraries also need to be copied in the testcases directory for +// running tests on host. This method adds module to the list of needed files. +// The 'key' is the file in testcases and 'value' is the path to copy it from. +// The actual copy will be done in make since soong does not do installations. +func addTestcasesFile(ctx android.InstallHookContext) { + testcasesContent := testcasesContent(ctx.Config()) + + artTestMutex.Lock() + defer artTestMutex.Unlock() + + if ctx.Os().Class == android.Host { + 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 + } +} + var artTestMutex sync.Mutex func init() { @@ -392,6 +419,7 @@ func artLibrary() android.Module { installCodegenCustomizer(module, staticAndSharedLibrary) + android.AddInstallHook(module, addTestcasesFile) return module } @@ -408,6 +436,7 @@ func artBinary() android.Module { android.AddLoadHook(module, customLinker) android.AddLoadHook(module, prefer32Bit) + android.AddInstallHook(module, addTestcasesFile) return module } diff --git a/build/makevars.go b/build/makevars.go index 1faa0f6f36..6e66966bf5 100644 --- a/build/makevars.go +++ b/build/makevars.go @@ -44,4 +44,12 @@ func makeVarsProvider(ctx android.MakeVarsContext) { for _, name := range testNames { ctx.Strict("ART_TEST_LIST_"+name, strings.Join(testMap[name], " ")) } + + // Create list of copy commands to install the content of the testcases directory. + testcasesContent := testcasesContent(ctx.Config()) + copy_cmds := []string{} + for _, key := range android.SortedStringKeys(testcasesContent) { + copy_cmds = append(copy_cmds, testcasesContent[key]+":"+key) + } + ctx.Strict("ART_TESTCASES_CONTENT", strings.Join(copy_cmds, " ")) } diff --git a/libdexfile/Android.bp b/libdexfile/Android.bp index 5a8cdb3a01..9fb6c8d93d 100644 --- a/libdexfile/Android.bp +++ b/libdexfile/Android.bp @@ -320,7 +320,7 @@ cc_defaults { ], } -cc_library { +art_cc_library { name: "libdexfile_external", defaults: [ "art_defaults", @@ -341,7 +341,7 @@ cc_library { ], } -cc_library { +art_cc_library { name: "libdexfiled_external", defaults: [ "art_debug_defaults", @@ -380,7 +380,7 @@ art_cc_test { // time dependency on dex file logic. It is therefore safe to use from binaries // compiled without dex file support, given they won't encounter any dex file // stack frames. -cc_library { +art_cc_library { name: "libdexfile_support", visibility: ["//visibility:public"], host_supported: true, diff --git a/libnativebridge/Android.bp b/libnativebridge/Android.bp index e05771ad1d..c0f4791621 100644 --- a/libnativebridge/Android.bp +++ b/libnativebridge/Android.bp @@ -27,7 +27,7 @@ cc_library_headers { ], } -cc_library { +art_cc_library { name: "libnativebridge", defaults: ["libnativebridge-defaults"], visibility: [ diff --git a/libnativeloader/Android.bp b/libnativeloader/Android.bp index 645cf6475e..5f29b4d626 100644 --- a/libnativeloader/Android.bp +++ b/libnativeloader/Android.bp @@ -10,7 +10,7 @@ cc_defaults { export_header_lib_headers: ["libnativeloader-headers"], } -cc_library { +art_cc_library { name: "libnativeloader", defaults: ["libnativeloader-defaults"], visibility: [ |