diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/Android.bp | 8 | ||||
-rw-r--r-- | test/art-gtests-target-chroot.xml | 14 | ||||
-rw-r--r-- | test/art-gtests-target-standalone-with-boot-image-template.xml | 55 | ||||
-rw-r--r-- | test/generate-boot-image/Android.bp | 56 | ||||
-rw-r--r-- | test/generate-boot-image/generate-boot-image.cc | 157 |
5 files changed, 0 insertions, 290 deletions
diff --git a/test/Android.bp b/test/Android.bp index ca6816cae3..07980fb79b 100644 --- a/test/Android.bp +++ b/test/Android.bp @@ -150,13 +150,6 @@ filegroup { srcs: ["art-gtests-target-standalone-root-template.xml"], } -// Test configuration template for standalone ART gtests run with a boot image on target (not -// bundled with the ART APEX). -filegroup { - name: "art-gtests-target-standalone-with-boot-image-template", - srcs: ["art-gtests-target-standalone-with-boot-image-template.xml"], -} - art_cc_defaults { name: "art_standalone_test_defaults", defaults: [ @@ -1312,7 +1305,6 @@ art_cc_test { // We need the ART testing apex, which contains all gtest binaries. // Note that due to build system and linker constraints the gtests must be in the apex. ":com.android.art.testing", - ":generate-boot-image", ], test_suites: ["general-tests"], test_config: "art-gtests-target-chroot.xml", diff --git a/test/art-gtests-target-chroot.xml b/test/art-gtests-target-chroot.xml index 5fd76f8891..aa2473d0b0 100644 --- a/test/art-gtests-target-chroot.xml +++ b/test/art-gtests-target-chroot.xml @@ -21,20 +21,6 @@ <target_preparer class="com.android.tradefed.targetprep.DisableSELinuxTargetPreparer" /> <target_preparer class="com.android.tradefed.targetprep.ArtChrootPreparer" /> - <target_preparer class="com.android.compatibility.common.tradefed.targetprep.FilePusher"> - <option name="cleanup" value="true" /> - <option name="append-bitness" value="true" /> - <option name="push-file" key="generate-boot-image" value="/data/local/tmp/art-test-chroot/data/local/tmp/generate-boot-image" /> - </target_preparer> - - <target_preparer class="com.android.tradefed.targetprep.RunCommandTargetPreparer"> - <option name="throw-if-cmd-fail" value="true" /> - <option name="run-command" value="mkdir -p /data/local/tmp/art-test-chroot/data/local/tmp/art_boot_images" /> - <!-- `compiler-filter=speed-profile` is required because OatDumpTest checks the compiled code in the boot image. --> - <option name="run-command" value="chroot /data/local/tmp/art-test-chroot /data/local/tmp/generate-boot-image --output-dir=/data/local/tmp/art_boot_images --compiler-filter=speed-profile" /> - <option name="teardown-command" value="rm -rf /data/local/tmp/art-test-chroot/data/local/tmp/art_boot_images" /> - </target_preparer> - <test class="com.android.tradefed.testtype.ArtGTest" > <!-- TODO(b/147821328): These tests do not work since they need to write to /system --> <option name="exclude-filter" value="HiddenApiTest.DexDomain_System*:OatFileAssistantTest.SystemFrameworkDir" /> diff --git a/test/art-gtests-target-standalone-with-boot-image-template.xml b/test/art-gtests-target-standalone-with-boot-image-template.xml deleted file mode 100644 index f028f2f44b..0000000000 --- a/test/art-gtests-target-standalone-with-boot-image-template.xml +++ /dev/null @@ -1,55 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- Copyright (C) 2022 The Android Open Source Project - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. ---> -<!-- Note: This test config file for {MODULE} is generated from a template. --> -<configuration description="Runs {MODULE}."> - <target_preparer class="com.android.compatibility.common.tradefed.targetprep.FilePusher"> - <option name="cleanup" value="true" /> - <option name="push" value="{MODULE}->/data/local/tmp/{MODULE}/{MODULE}" /> - <option name="append-bitness" value="true" /> - </target_preparer> - - <target_preparer class="com.android.compatibility.common.tradefed.targetprep.FilePusher"> - <option name="cleanup" value="true" /> - <option name="append-bitness" value="true" /> - <option name="push-file" key="generate-boot-image" value="/data/local/tmp/{MODULE}/generate-boot-image" /> - </target_preparer> - - <target_preparer class="com.android.tradefed.targetprep.RunCommandTargetPreparer"> - <option name="throw-if-cmd-fail" value="true" /> - <option name="run-command" value="mkdir -p /data/local/tmp/{MODULE}/art_boot_images" /> - <option name="run-command" value="/data/local/tmp/{MODULE}/generate-boot-image --output-dir=/data/local/tmp/{MODULE}/art_boot_images" /> - <option name="teardown-command" value="rm -rf /data/local/tmp/{MODULE}/art_boot_images" /> - </target_preparer> - - <test class="com.android.tradefed.testtype.GTest" > - <option name="native-test-device-path" value="/data/local/tmp/{MODULE}" /> - <option name="module-name" value="{MODULE}" /> - <option name="ld-library-path-32" value="/apex/com.android.art/lib" /> - <option name="ld-library-path-64" value="/apex/com.android.art/lib64" /> - </test> - - <!-- When this test is run in a Mainline context (e.g. with `mts-tradefed`), only enable it if - one of the Mainline modules below is present on the device used for testing. --> - <object type="module_controller" class="com.android.tradefed.testtype.suite.module.MainlineTestModuleController"> - <!-- ART Mainline Module (internal version). --> - <option name="mainline-module-package-name" value="com.google.android.art" /> - <!-- ART Mainline Module (external (AOSP) version). --> - <option name="mainline-module-package-name" value="com.android.art" /> - </object> - - <!-- Only run tests if the device under test is SDK version 31 (Android 12) or above. --> - <object type="module_controller" class="com.android.tradefed.testtype.suite.module.Sdk31ModuleController" /> -</configuration> diff --git a/test/generate-boot-image/Android.bp b/test/generate-boot-image/Android.bp deleted file mode 100644 index 4b56c5370b..0000000000 --- a/test/generate-boot-image/Android.bp +++ /dev/null @@ -1,56 +0,0 @@ -// -// Copyright (C) 2022 The Android Open Source Project -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -package { - // See: http://go/android-license-faq - // A large-scale-change added 'default_applicable_licenses' to import - // all of the 'license_kinds' from "art_license" - // to get the below license kinds: - // SPDX-license-identifier-Apache-2.0 - default_applicable_licenses: ["art_license"], -} - -art_cc_binary { - name: "generate-boot-image", - defaults: [ - "art_defaults", - ], - host_supported: false, - compile_multilib: "both", - multilib: { - lib32: { - suffix: "32", - }, - lib64: { - suffix: "64", - }, - }, - required: [ - "dex2oat", - ], - srcs: ["generate-boot-image.cc"], - shared_libs: [ - "libbase", - "liblog", - ], - static_libs: [ - "libartbase", - ], - tidy: true, - tidy_flags: [ - "-format-style=file", - ], -} diff --git a/test/generate-boot-image/generate-boot-image.cc b/test/generate-boot-image/generate-boot-image.cc deleted file mode 100644 index 91440644c6..0000000000 --- a/test/generate-boot-image/generate-boot-image.cc +++ /dev/null @@ -1,157 +0,0 @@ -/* - * Copyright (C) 2022 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** A commandline tool to generate a primary boot image for testing. */ - -#include <sys/stat.h> -#include <sysexits.h> - -#include <algorithm> -#include <cstdlib> -#include <string> -#include <vector> - -#ifdef __ANDROID__ -#include <android/api-level.h> -#endif - -#include "android-base/stringprintf.h" -#include "android-base/strings.h" -#include "arch/instruction_set.h" -#include "base/file_utils.h" -#include "base/globals.h" -#include "base/os.h" - -namespace art { - -namespace { - -using ::android::base::Join; -using ::android::base::Split; -using ::android::base::StringPrintf; - -std::string GetCompilerExecutable() { - std::string compiler_executable = GetArtBinDir() + "/dex2oat"; - if (kIsDebugBuild) { - compiler_executable += 'd'; - } - compiler_executable += Is64BitInstructionSet(kRuntimeISA) ? "64" : "32"; - return compiler_executable; -} - -std::vector<std::string> GetDexFiles() { - const char* bootclasspath_env = getenv("BOOTCLASSPATH"); - CHECK_NE(bootclasspath_env, nullptr); - std::vector<std::string> dex_files = Split(bootclasspath_env, ":"); - std::string art_root = GetArtRoot(); -// Java core libraries are located in a different location on old versions. We need to rewrite the -// locations to match where the testing scripts actually place Java core libraries. -#ifdef __ANDROID__ - if (android_get_device_api_level() <= __ANDROID_API_Q__) { - for (std::string& dex_file : dex_files) { - dex_file = android::base::StringReplace( - dex_file, "/apex/com.android.runtime", art_root, /*all=*/false); - } - } -#endif - auto end = std::remove_if(dex_files.begin(), dex_files.end(), [&](const std::string& file) { - return !android::base::StartsWith(file, art_root); - }); - dex_files.erase(end, dex_files.end()); - return dex_files; -} - -// Joins a list of commandline args into a single string, where each part is quoted with double -// quotes. Note that this is a naive implementation that does NOT escape existing double quotes, -// which is fine since we don't have existing double quotes in the args in this particular use case -// and this code is never used in production. -std::string BuildCommand(const std::vector<std::string>& args) { - std::string command = ""; - for (const std::string& arg : args) { - if (!command.empty()) { - command += " "; - } - command += '"' + arg + '"'; - } - return command; -} - -int GenerateBootImage(const std::string& dir, const std::string& compiler_filter) { - std::string isa = GetInstructionSetString(kRuntimeISA); - - std::vector<std::string> args; - args.push_back(GetCompilerExecutable()); - - std::vector<std::string> dex_files = GetDexFiles(); - args.push_back("--runtime-arg"); - args.push_back("-Xbootclasspath:" + Join(dex_files, ":")); - for (const std::string& file : dex_files) { - args.push_back("--dex-file=" + file); - } - - args.push_back("--instruction-set=" + isa); - args.push_back(StringPrintf("--base=0x%08x", ART_BASE_ADDRESS)); - args.push_back("--compiler-filter=" + compiler_filter); - args.push_back(StringPrintf("--profile-file=%s/etc/boot-image.prof", GetArtRoot().c_str())); - args.push_back("--avoid-storing-invocation"); - args.push_back("--generate-debug-info"); - args.push_back("--generate-build-id"); - args.push_back("--image-format=lz4hc"); - args.push_back("--strip"); - args.push_back("--android-root=out/empty"); - - std::string path = StringPrintf("%s/%s", dir.c_str(), isa.c_str()); - if (!OS::DirectoryExists(path.c_str())) { - CHECK_EQ(mkdir(path.c_str(), S_IRWXU), 0); - } - args.push_back(StringPrintf("--image=%s/boot.art", path.c_str())); - args.push_back(StringPrintf("--oat-file=%s/boot.oat", path.c_str())); - - int exit_code = system(BuildCommand(args).c_str()); - if (exit_code != 0) { - LOG(ERROR) << "dex2oat invocation failed. Exit code: " << exit_code; - } - return exit_code; -} - -} // namespace -} // namespace art - -int main(int argc, char** argv) { - android::base::InitLogging(argv, android::base::LogdLogger(android::base::SYSTEM)); - - std::string dir = ""; - // Set the compiler filter to `verify` by default to make test preparation faster. - std::string compiler_filter = "verify"; - for (int i = 1; i < argc; i++) { - std::string_view arg{argv[i]}; - if (android::base::ConsumePrefix(&arg, "--output-dir=")) { - dir = arg; - } else if (android::base::ConsumePrefix(&arg, "--compiler-filter=")) { - compiler_filter = arg; - } else { - LOG(ERROR) << android::base::StringPrintf("Unrecognized argument: '%s'", argv[i]); - exit(EX_USAGE); - } - } - - if (dir.empty()) { - LOG(ERROR) << "--output-dir must be specified"; - exit(EX_USAGE); - } - - return art::GenerateBootImage(dir, compiler_filter); -} |