diff options
| -rw-r--r-- | build/Android.common_test.mk | 9 | ||||
| -rw-r--r-- | runtime/class_linker.cc | 21 | ||||
| -rw-r--r-- | runtime/oat_file.cc | 12 | ||||
| -rw-r--r-- | runtime/oat_file.h | 4 | ||||
| -rw-r--r-- | runtime/runtime.cc | 69 | ||||
| -rw-r--r-- | test/119-noimage-patchoat/expected.txt | 6 | ||||
| -rw-r--r-- | test/119-noimage-patchoat/info.txt | 1 | ||||
| -rw-r--r-- | test/119-noimage-patchoat/run | 36 | ||||
| -rw-r--r-- | test/119-noimage-patchoat/src/Main.java | 38 | ||||
| -rw-r--r-- | test/Android.run-test.mk | 118 | ||||
| -rwxr-xr-x | test/etc/host-run-test-jar | 27 | ||||
| -rwxr-xr-x | test/etc/push-and-run-prebuilt-test-jar | 20 | ||||
| -rwxr-xr-x | test/etc/push-and-run-test-jar | 20 | ||||
| -rwxr-xr-x | test/run-all-tests | 7 | ||||
| -rwxr-xr-x | test/run-test | 26 |
15 files changed, 378 insertions, 36 deletions
diff --git a/build/Android.common_test.mk b/build/Android.common_test.mk index dc586a052e..20c5a21bc1 100644 --- a/build/Android.common_test.mk +++ b/build/Android.common_test.mk @@ -78,6 +78,15 @@ ART_TEST_RUN_TEST_NO_RELOCATE ?= $(ART_TEST_FULL) # Do you want run-tests with no prebuilding enabled run? ART_TEST_RUN_TEST_NO_PREBUILD ?= $(ART_TEST_FULL) +# Do you want run-tests without a pregenerated core.art? +ART_TEST_RUN_TEST_NO_IMAGE ?= $(ART_TEST_FULL) + +# Do you want run-tests with relocation enabled but patchoat failing? +ART_TEST_RUN_TEST_RELOCATE_NO_PATCHOAT ?= $(ART_TEST_FULL) + +# Do you want run-tests without a dex2oat? +ART_TEST_RUN_TEST_NO_DEX2OAT ?= $(ART_TEST_FULL) + # Do you want failed tests to have their artifacts cleaned up? ART_TEST_RUN_TEST_ALWAYS_CLEAN ?= true diff --git a/runtime/class_linker.cc b/runtime/class_linker.cc index c696089ad9..4123fc6398 100644 --- a/runtime/class_linker.cc +++ b/runtime/class_linker.cc @@ -1168,6 +1168,7 @@ const OatFile* ClassLinker::FindOatFileContainingDexFileFromDexLocation( error_msg.c_str())); return nullptr; } else if (!oat_file->IsExecutable() && + Runtime::Current()->GetHeap()->HasImageSpace() && !VerifyOatImageChecksum(oat_file.get(), isa)) { error_msgs->push_back(StringPrintf("Failed to verify non-executable oat file '%s' found for " "dex location '%s'. Image checksum incorrect.", @@ -1250,6 +1251,7 @@ const OatFile* ClassLinker::OpenOatFileFromDexLocation(const std::string& dex_lo std::string odex_error_msg; bool should_patch_system = false; bool odex_checksum_verified = false; + bool have_system_odex = false; { // There is a high probability that these both these oat files map similar/the same address // spaces so we must scope them like this so they each gets its turn. @@ -1260,14 +1262,18 @@ const OatFile* ClassLinker::OpenOatFileFromDexLocation(const std::string& dex_lo &odex_error_msg)) { error_msgs->push_back(odex_error_msg); return odex_oat_file.release(); - } else if (odex_checksum_verified) { - // We can just relocate - should_patch_system = true; - odex_error_msg = "Image Patches are incorrect"; + } else { + if (odex_checksum_verified) { + // We can just relocate + should_patch_system = true; + odex_error_msg = "Image Patches are incorrect"; + } + if (odex_oat_file.get() != nullptr) { + have_system_odex = true; + } } } - std::string cache_error_msg; bool should_patch_cache = false; bool cache_checksum_verified = false; @@ -1303,6 +1309,8 @@ const OatFile* ClassLinker::OpenOatFileFromDexLocation(const std::string& dex_lo CHECK(have_dalvik_cache); ret = PatchAndRetrieveOat(cache_filename, cache_filename, image_location, isa, &error_msg); } + } else if (have_system_odex) { + ret = GetInterpretedOnlyOat(odex_filename, isa, &error_msg); } } if (ret == nullptr && have_dalvik_cache && OS::FileExists(cache_filename.c_str())) { @@ -1352,7 +1360,8 @@ const OatFile* ClassLinker::GetInterpretedOnlyOat(const std::string& oat_path, if (output.get() == nullptr) { return nullptr; } - if (VerifyOatImageChecksum(output.get(), isa)) { + if (!Runtime::Current()->GetHeap()->HasImageSpace() || + VerifyOatImageChecksum(output.get(), isa)) { return output.release(); } else { *error_msg = StringPrintf("Could not use oat file '%s', image checksum failed to verify.", diff --git a/runtime/oat_file.cc b/runtime/oat_file.cc index 50dfe2109f..d179a960b5 100644 --- a/runtime/oat_file.cc +++ b/runtime/oat_file.cc @@ -24,6 +24,7 @@ #include "base/stl_util.h" #include "base/unix_file/fd_file.h" #include "elf_file.h" +#include "elf_utils.h" #include "oat.h" #include "mirror/art_method.h" #include "mirror/art_method-inl.h" @@ -40,6 +41,17 @@ void OatFile::CheckLocation(const std::string& location) { CHECK(!location.empty()); } +OatFile* OatFile::OpenWithElfFile(ElfFile* elf_file, + const std::string& location, + std::string* error_msg) { + std::unique_ptr<OatFile> oat_file(new OatFile(location, false)); + oat_file->elf_file_.reset(elf_file); + Elf32_Shdr* hdr = elf_file->FindSectionByName(".rodata"); + oat_file->begin_ = elf_file->Begin() + hdr->sh_offset; + oat_file->end_ = elf_file->Begin() + hdr->sh_size + hdr->sh_offset; + return oat_file->Setup(error_msg) ? oat_file.release() : nullptr; +} + OatFile* OatFile::OpenMemory(std::vector<uint8_t>& oat_contents, const std::string& location, std::string* error_msg) { diff --git a/runtime/oat_file.h b/runtime/oat_file.h index 8535bf4133..5b24e8fd6f 100644 --- a/runtime/oat_file.h +++ b/runtime/oat_file.h @@ -40,6 +40,10 @@ class OatHeader; class OatFile { public: + // Opens an oat file contained within the given elf file. This is always opened as + // non-executable at the moment. + static OatFile* OpenWithElfFile(ElfFile* elf_file, const std::string& location, + std::string* error_msg); // Open an oat file. Returns NULL on failure. Requested base can // optionally be used to request where the file should be loaded. static OatFile* Open(const std::string& filename, diff --git a/runtime/runtime.cc b/runtime/runtime.cc index 3fc6ad53d2..d05d031335 100644 --- a/runtime/runtime.cc +++ b/runtime/runtime.cc @@ -46,6 +46,7 @@ #include "atomic.h" #include "class_linker.h" #include "debugger.h" +#include "elf_file.h" #include "fault_handler.h" #include "gc/accounting/card_table-inl.h" #include "gc/heap.h" @@ -66,6 +67,7 @@ #include "native_bridge_art_interface.h" #include "parsed_options.h" #include "oat_file.h" +#include "os.h" #include "quick/quick_method_frame_info.h" #include "reflection.h" #include "ScopedLocalRef.h" @@ -547,9 +549,74 @@ void Runtime::StartDaemonThreads() { VLOG(startup) << "Runtime::StartDaemonThreads exiting"; } +static bool OpenDexFilesFromImage(const std::vector<std::string>& dex_filenames, + const std::string& image_location, + std::vector<const DexFile*>& dex_files, + size_t* failures) { + std::string system_filename; + bool has_system = false; + std::string cache_filename_unused; + bool dalvik_cache_exists_unused; + bool has_cache_unused; + bool found_image = gc::space::ImageSpace::FindImageFilename(image_location.c_str(), + kRuntimeISA, + &system_filename, + &has_system, + &cache_filename_unused, + &dalvik_cache_exists_unused, + &has_cache_unused); + *failures = 0; + if (!found_image || !has_system) { + return false; + } + std::string error_msg; + // We are falling back to non-executable use of the oat file because patching failed, presumably + // due to lack of space. + std::string oat_filename = ImageHeader::GetOatLocationFromImageLocation(system_filename.c_str()); + std::string oat_location = ImageHeader::GetOatLocationFromImageLocation(image_location.c_str()); + std::unique_ptr<File> file(OS::OpenFileForReading(oat_filename.c_str())); + if (file.get() == nullptr) { + return false; + } + std::unique_ptr<ElfFile> elf_file(ElfFile::Open(file.release(), false, false, &error_msg)); + if (elf_file.get() == nullptr) { + return false; + } + std::unique_ptr<OatFile> oat_file(OatFile::OpenWithElfFile(elf_file.release(), oat_location, + &error_msg)); + if (oat_file.get() == nullptr) { + LOG(INFO) << "Unable to use '" << oat_filename << "' because " << error_msg; + return false; + } + + std::vector<const OatFile::OatDexFile*> oat_dex_files = oat_file->GetOatDexFiles(); + for (size_t i = 0; i < oat_dex_files.size(); i++) { + const OatFile::OatDexFile* oat_dex_file = oat_dex_files[i]; + if (oat_dex_file == nullptr) { + *failures += 1; + continue; + } + const DexFile* dex_file = oat_dex_file->OpenDexFile(&error_msg); + if (dex_file == nullptr) { + *failures += 1; + } else { + dex_files.push_back(dex_file); + } + } + Runtime::Current()->GetClassLinker()->RegisterOatFile(oat_file.release()); + return true; +} + + static size_t OpenDexFiles(const std::vector<std::string>& dex_filenames, + const std::string& image_location, std::vector<const DexFile*>& dex_files) { size_t failure_count = 0; + if (!image_location.empty() && OpenDexFilesFromImage(dex_filenames, image_location, dex_files, + &failure_count)) { + return failure_count; + } + failure_count = 0; for (size_t i = 0; i < dex_filenames.size(); i++) { const char* dex_filename = dex_filenames[i].c_str(); std::string error_msg; @@ -713,7 +780,7 @@ bool Runtime::Init(const RuntimeOptions& raw_options, bool ignore_unrecognized) std::vector<std::string> dex_filenames; Split(boot_class_path_string_, ':', dex_filenames); std::vector<const DexFile*> boot_class_path; - OpenDexFiles(dex_filenames, boot_class_path); + OpenDexFiles(dex_filenames, options->image_, boot_class_path); class_linker_->InitWithoutImage(boot_class_path); // TODO: Should we move the following to InitWithoutImage? SetInstructionSet(kRuntimeISA); diff --git a/test/119-noimage-patchoat/expected.txt b/test/119-noimage-patchoat/expected.txt new file mode 100644 index 0000000000..e864268a38 --- /dev/null +++ b/test/119-noimage-patchoat/expected.txt @@ -0,0 +1,6 @@ +Run -Xnoimage-dex2oat -Xpatchoat:/system/bin/false +Has image is false, is image dex2oat enabled is false. +Run -Ximage-dex2oat +Has image is true, is image dex2oat enabled is true. +Run default +Has image is true, is image dex2oat enabled is true. diff --git a/test/119-noimage-patchoat/info.txt b/test/119-noimage-patchoat/info.txt new file mode 100644 index 0000000000..6b853688dd --- /dev/null +++ b/test/119-noimage-patchoat/info.txt @@ -0,0 +1 @@ +Test that disables patchoat'ing the image. diff --git a/test/119-noimage-patchoat/run b/test/119-noimage-patchoat/run new file mode 100644 index 0000000000..745b0c9475 --- /dev/null +++ b/test/119-noimage-patchoat/run @@ -0,0 +1,36 @@ +#!/bin/bash +# +# Copyright (C) 2014 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. + +# Force relocation otherwise we will just use the already created core.oat/art pair. +flags="${@/--no-relocate/--relocate}" + +if [ $(basename $RUN) == 'host-run-test-jar' ]; then + false_bin="/bin/false" +else + false_bin="/system/bin/false" +fi + +# Make sure we can run without an image file, +echo "Run -Xnoimage-dex2oat -Xpatchoat:/system/bin/false" +${RUN} ${flags} ${BPATH} --runtime-option -Xnoimage-dex2oat --runtime-option -Xpatchoat:${false_bin} + +# Make sure we can run with the image file. +echo "Run -Ximage-dex2oat" +${RUN} ${flags} ${BPATH} --runtime-option -Ximage-dex2oat + +# Make sure we can run with the default settings. +echo "Run default" +${RUN} ${flags} ${BPATH} diff --git a/test/119-noimage-patchoat/src/Main.java b/test/119-noimage-patchoat/src/Main.java new file mode 100644 index 0000000000..11c736a7d6 --- /dev/null +++ b/test/119-noimage-patchoat/src/Main.java @@ -0,0 +1,38 @@ +/* + * Copyright (C) 2014 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. + */ + +public class Main { + public static void main(String[] args) { + boolean hasImage = hasImage(); + System.out.println( + "Has image is " + hasImage + ", is image dex2oat enabled is " + + isImageDex2OatEnabled() + "."); + + if (hasImage && !isImageDex2OatEnabled()) { + throw new Error("Image with dex2oat disabled runs with an oat file"); + } else if (!hasImage && isImageDex2OatEnabled()) { + throw new Error("Image with dex2oat enabled runs without an oat file"); + } + } + + static { + System.loadLibrary("arttest"); + } + + private native static boolean hasImage(); + + private native static boolean isImageDex2OatEnabled(); +} diff --git a/test/Android.run-test.mk b/test/Android.run-test.mk index 2f2d283019..214584d647 100644 --- a/test/Android.run-test.mk +++ b/test/Android.run-test.mk @@ -65,16 +65,18 @@ TEST_ART_RUN_TEST_BUILD_RULES := # General rules to build and run a run-test. # Test rule names or of the form: -# test-art-{1: host or target}-run-test-{2: prebuild or no-prebuild}- -# {3: interpreter default optimizing}-{4: relocate or no-relocate}-{5: trace or no-trace}- -# {6: gcstress gcverify cms}-{7: forcecopy checkjni jni}-{8: test name}{9: 32 or 64} +# test-art-{1: host or target}-run-test-{2: prebuild no-prebuild no-dex2oat}- +# {3: interpreter default optimizing}-{4: relocate no-relocate relocate-no-patchoat}- +# {5: trace or no-trace}-{6: gcstress gcverify cms}-{7: forcecopy checkjni jni}- +# {8: no-image or image}-{9: test name}{10: 32 or 64} TARGET_TYPES := host target -PREBUILD_TYPES := prebuild no-prebuild +PREBUILD_TYPES := prebuild no-prebuild no-dex2oat COMPILER_TYPES := default interpreter optimizing -RELOCATE_TYPES := relocate no-relocate +RELOCATE_TYPES := relocate no-relocate relocate-no-patchoat TRACE_TYPES := trace no-trace GC_TYPES := gcstress gcverify cms JNI_TYPES := jni checkjni forcecopy +IMAGE_TYPES := image no-image ALL_ADDRESS_SIZES := 64 32 # List all run test names with number arguments agreeing with the comment above. define all-run-test-names @@ -85,10 +87,11 @@ define all-run-test-names $(foreach trace, $(5), \ $(foreach gc, $(6), \ $(foreach jni, $(7), \ - $(foreach test, $(8), \ - $(foreach address_size, $(9), \ - test-art-$(target)-run-test-$(prebuild)-$(compiler)-$(relocate)-$(trace)-$(gc)-$(jni)-$(test)$(address_size) \ - ))))))))) + $(foreach image, $(8), \ + $(foreach test, $(9), \ + $(foreach address_size, $(10), \ + test-art-$(target)-run-test-$(prebuild)-$(compiler)-$(relocate)-$(trace)-$(gc)-$(jni)-$(image)-$(test)$(address_size) \ + )))))))))) endef # all-run-test-names # To generate a full list or tests: @@ -111,6 +114,7 @@ ifdef dist_goal ART_TEST_KNOWN_BROKEN += $(call all-run-test-names,$(TARGET_TYPES),$(PREBUILD_TYPES), \ $(COMPILER_TYPES), $(RELOCATE_TYPES),$(TRACE_TYPES),$(GC_TYPES),$(JNI_TYPES), \ $(TEST_ART_TIMING_SENSITIVE_RUN_TESTS), $(ALL_ADDRESS_SIZES)) + $(IMAGE_TYPES), $(TEST_ART_TIMING_SENSITIVE_RUN_TESTS), $(ALL_ADDRESS_SIZES)) endif # NB 116-nodex2oat is not broken per-se it just doesn't (and isn't meant to) work with --prebuild. @@ -145,15 +149,36 @@ TEST_ART_BROKEN_TRACE_RUN_TESTS := \ ART_TEST_KNOWN_BROKEN += $(call all-run-test-names,$(TARGET_TYPES),$(PREBUILD_TYPES), \ $(COMPILER_TYPES), $(RELOCATE_TYPES),trace,$(GC_TYPES),$(JNI_TYPES), \ - $(TEST_ART_BROKEN_TRACE_RUN_TESTS), $(ALL_ADDRESS_SIZES)) + $(IMAGE_TYPES), $(TEST_ART_BROKEN_TRACE_RUN_TESTS), $(ALL_ADDRESS_SIZES)) TEST_ART_BROKEN_TRACE_RUN_TESTS := # 115-native-bridge setup is complicated. Need to implement it correctly for the target. ART_TEST_KNOWN_BROKEN += $(call all-run-test-names,target,$(PREBUILD_TYPES),$(COMPILER_TYPES), \ - $(RELOCATE_TYPES),$(TRACE_TYPES),$(GC_TYPES),$(JNI_TYPES),115-native-bridge, \ + $(RELOCATE_TYPES),$(TRACE_TYPES),$(GC_TYPES),$(JNI_TYPES),$(IMAGE_TYPES),115-native-bridge, \ $(ALL_ADDRESS_SIZES)) +# All these tests check that we have sane behavior if we don't have a patchoat or dex2oat. +# Therefore we shouldn't run them in situations where we actually don't have these since they +# explicitly test for them. These all also assume we have an image. +TEST_ART_BROKEN_FALLBACK_RUN_TESTS := \ + 116-nodex2oat \ + 117-nopatchoat \ + 118-noimage-dex2oat \ + 119-noimage-patchoat + +ART_TEST_KNOWN_BROKEN += $(call all-run-test-names,$(TARGET_TYPES),no-dex2oat,$(COMPILER_TYPES), \ + $(RELOCATE_TYPES),$(TRACE_TYPES),$(GC_TYPES),$(JNI_TYPES),$(IMAGE_TYPES), \ + $(TEST_ART_BROKEN_FALLBACK_RUN_TESTS),$(ALL_ADDRESS_SIZES)) + +ART_TEST_KNOWN_BROKEN += $(call all-run-test-names,$(TARGET_TYPES),$(PREBUILD_TYPES),$(COMPILER_TYPES), \ + $(RELOCATE_TYPES),$(TRACE_TYPES),$(GC_TYPES),$(JNI_TYPES),no-image, \ + $(TEST_ART_BROKEN_FALLBACK_RUN_TESTS),$(ALL_ADDRESS_SIZES)) + +ART_TEST_KNOWN_BROKEN += $(call all-run-test-names,$(TARGET_TYPES),$(PREBUILD_TYPES),$(COMPILER_TYPES), \ + relocate-no-patchoat,$(TRACE_TYPES),$(GC_TYPES),$(JNI_TYPES),$(IMAGE_TYPES), \ + $(TEST_ART_BROKEN_FALLBACK_RUN_TESTS),$(ALL_ADDRESS_SIZES)) + # Clear variables ahead of appending to them when defining tests. $(foreach target, $(TARGET_TYPES), $(eval ART_RUN_TEST_$(call name-to-var,$(target))_RULES :=)) $(foreach target, $(TARGET_TYPES), \ @@ -175,6 +200,9 @@ $(foreach target, $(TARGET_TYPES), \ $(foreach jni, $(JNI_TYPES), \ $(eval ART_RUN_TEST_$(call name-to-var,$(target))_$(call name-to-var,$(jni))_RULES :=))) $(foreach target, $(TARGET_TYPES), \ + $(foreach image, $(IMAGE_TYPES), \ + $(eval ART_RUN_TEST_$(call name-to-var,$(target))_$(call name-to-var,$(image))_RULES :=))) +$(foreach target, $(TARGET_TYPES), \ $(foreach test, $(TEST_ART_RUN_TESTS), \ $(eval ART_RUN_TEST_$(call name-to-var,$(target))_$(call name-to-var,$(test))_RULES :=))) $(foreach target, $(TARGET_TYPES), \ @@ -213,9 +241,10 @@ ART_TEST_HOST_RUN_TEST_DEPENDENCIES += \ endif # Create a rule to build and run a tests following the form: -# test-art-{1: host or target}-run-test-{2: prebuild or no-prebuild}- -# {3: interpreter default optimizing}-{4: relocate or no-relocate}-{5: trace or no-trace}- -# {6: gcstress gcverify cms}-{7: forcecopy checkjni jni}-{8: test name}{9: 32 or 64} +# test-art-{1: host or target}-run-test-{2: prebuild no-prebuild no-dex2oat}- +# {3: interpreter default optimizing}-{4: relocate no-relocate relocate-no-patchoat}- +# {5: trace or no-trace}-{6: gcstress gcverify cms}-{7: forcecopy checkjni jni}- +# {8: no-image image}-{9: test name}{10: 32 or 64} define define-test-art-run-test run_test_options := $(addprefix --runtime-option ,$(DALVIKVM_FLAGS)) prereq_rule := @@ -246,7 +275,12 @@ define define-test-art-run-test test_groups += ART_RUN_TEST_$$(uc_host_or_target)_NO_PREBUILD_RULES run_test_options += --no-prebuild else - $$(error found $(2) expected $(PREBUILD_TYPES)) + ifeq ($(2),no-dex2oat) + test_groups += ART_RUN_TEST_$$(uc_host_or_target)_NO_DEX2OAT_RULES + run_test_options += --no-prebuild --no-dex2oat + else + $$(error found $(2) expected $(PREBUILD_TYPES)) + endif endif endif ifeq ($(3),optimizing) @@ -272,7 +306,12 @@ define define-test-art-run-test test_groups += ART_RUN_TEST_$$(uc_host_or_target)_NO_RELOCATE_RULES run_test_options += --no-relocate else - $$(error found $(4) expected $(RELOCATE_TYPES)) + ifeq ($(4),relocate-no-patchoat) + test_groups += ART_RUN_TEST_$$(uc_host_or_target)_RELOCATE_NO_PATCHOAT_RULES + run_test_options += --relocate --no-patchoat + else + $$(error found $(4) expected $(RELOCATE_TYPES)) + endif endif endif ifeq ($(5),trace) @@ -318,19 +357,29 @@ define define-test-art-run-test endif endif endif - # $(8) is the test name - test_groups += ART_RUN_TEST_$$(uc_host_or_target)_$(call name-to-var,$(8))_RULES - ifeq ($(9),64) + ifeq ($(8),no-image) + test_groups += ART_RUN_TEST_$$(uc_host_or_target)_NO_IMAGE_RULES + run_test_options += --no-image + else + ifeq ($(8),image) + test_groups += ART_RUN_TEST_$$(uc_host_or_target)_IMAGE_RULES + else + $$(error found $(8) expected $(IMAGE_TYPES)) + endif + endif + # $(9) is the test name + test_groups += ART_RUN_TEST_$$(uc_host_or_target)_$(call name-to-var,$(9))_RULES + ifeq ($(10),64) test_groups += ART_RUN_TEST_$$(uc_host_or_target)_64_RULES run_test_options += --64 else - ifeq ($(9),32) + ifeq ($(10),32) test_groups += ART_RUN_TEST_$$(uc_host_or_target)_32_RULES else - $$(error found $(9) expected $(ALL_ADDRESS_SIZES)) + $$(error found $(10) expected $(ALL_ADDRESS_SIZES)) endif endif - run_test_rule_name := test-art-$(1)-run-test-$(2)-$(3)-$(4)-$(5)-$(6)-$(7)-$(8)$(9) + run_test_rule_name := test-art-$(1)-run-test-$(2)-$(3)-$(4)-$(5)-$(6)-$(7)-$(8)-$(9)$(10) run_test_options := --output-path $(ART_HOST_TEST_DIR)/run-test-output/$$(run_test_rule_name) \ $$(run_test_options) $$(run_test_rule_name): PRIVATE_RUN_TEST_OPTIONS := $$(run_test_options) @@ -338,7 +387,7 @@ $$(run_test_rule_name): PRIVATE_RUN_TEST_OPTIONS := $$(run_test_options) $$(run_test_rule_name): $(DX) $(HOST_OUT_EXECUTABLES)/jasmin $$(prereq_rule) $(hide) $$(call ART_TEST_SKIP,$$@) && \ DX=$(abspath $(DX)) JASMIN=$(abspath $(HOST_OUT_EXECUTABLES)/jasmin) \ - art/test/run-test $$(PRIVATE_RUN_TEST_OPTIONS) $(8) \ + art/test/run-test $$(PRIVATE_RUN_TEST_OPTIONS) $(9) \ && $$(call ART_TEST_PASSED,$$@) || $$(call ART_TEST_FAILED,$$@) $$(hide) (echo $(MAKECMDGOALS) | grep -q $$@ && \ echo "run-test run as top-level target, removing test directory $(ART_HOST_TEST_DIR)" && \ @@ -358,6 +407,9 @@ test_prebuild_types := prebuild ifeq ($(ART_TEST_RUN_TEST_NO_PREBUILD),true) test_prebuild_types += no-prebuild endif +ifeq ($(ART_TEST_RUN_TEST_NO_DEX2OAT),true) + test_prebuild_types += no-dex2oat +endif test_compiler_types := ifeq ($(ART_TEST_DEFAULT_COMPILER),true) test_compiler_types += default @@ -372,6 +424,9 @@ test_relocate_types := relocate ifeq ($(ART_TEST_RUN_TEST_NO_RELOCATE),true) test_relocate_types += no-relocate endif +ifeq ($(ART_TEST_RUN_TEST_RELOCATE_NO_PATCHOAT),true) + test_relocate_types := relocate-no-patchoat +endif test_trace_types := no-trace ifeq ($(ART_TEST_TRACE),true) test_trace_types += trace @@ -387,6 +442,10 @@ test_jni_types := checkjni ifeq ($(ART_TEST_JNI_FORCECOPY),true) test_jni_types += forcecopy endif +test_image_types := image +ifeq ($(ART_TEST_RUN_TEST_NO_IMAGE),true) + test_image_types += no-image +endif ADDRESS_SIZES_TARGET := $(ART_PHONY_TEST_TARGET_SUFFIX) $(2ND_ART_PHONY_TEST_TARGET_SUFFIX) ADDRESS_SIZES_HOST := $(ART_PHONY_TEST_HOST_SUFFIX) $(2ND_ART_PHONY_TEST_HOST_SUFFIX) @@ -400,8 +459,9 @@ $(foreach target, $(TARGET_TYPES), \ $(foreach trace, $(test_trace_types), \ $(foreach gc, $(test_gc_types), \ $(foreach jni, $(test_jni_types), \ - $(eval $(call define-test-art-run-test,$(target),$(prebuild),$(compiler),$(relocate),$(trace),$(gc),$(jni),$(test),$(address_size))) \ - ))))))))) + $(foreach image, $(test_image_types), \ + $(eval $(call define-test-art-run-test,$(target),$(prebuild),$(compiler),$(relocate),$(trace),$(gc),$(jni),$(image),$(test),$(address_size))) \ + )))))))))) define-test-art-run-test := test_prebuild_types := test_compiler_types := @@ -409,6 +469,7 @@ test_relocate_types := test_trace_types := test_gc_types := test_jni_types := +test_image_types := ART_TEST_HOST_RUN_TEST_DEPENDENCIES := ADDRESS_SIZES_TARGET := ADDRESS_SIZES_HOST := @@ -445,6 +506,9 @@ $(foreach target, $(TARGET_TYPES), \ $(foreach jni, $(JNI_TYPES), $(eval \ $(call define-test-art-run-test-group,test-art-$(target)-run-test-$(jni),$(ART_RUN_TEST_$(call name-to-var,$(target))_$(call name-to-var,$(jni))_RULES))))) $(foreach target, $(TARGET_TYPES), \ + $(foreach image, $(IMAGE_TYPES), $(eval \ + $(call define-test-art-run-test-group,test-art-$(target)-run-test-$(image),$(ART_RUN_TEST_$(call name-to-var,$(target))_$(call name-to-var,$(image))_RULES))))) +$(foreach target, $(TARGET_TYPES), \ $(foreach test, $(TEST_ART_RUN_TESTS), $(eval \ $(call define-test-art-run-test-group,test-art-$(target)-run-test-$(test),$(ART_RUN_TEST_$(call name-to-var,$(target))_$(call name-to-var,$(test))_RULES))))) $(foreach target, $(TARGET_TYPES), \ @@ -472,6 +536,9 @@ $(foreach target, $(TARGET_TYPES), \ $(foreach jni, $(JNI_TYPES), \ $(eval ART_RUN_TEST_$(call name-to-var,$(target))_$(call name-to-var,$(jni))_RULES :=))) $(foreach target, $(TARGET_TYPES), \ + $(foreach image, $(IMAGE_TYPES), \ + $(eval ART_RUN_TEST_$(call name-to-var,$(target))_$(call name-to-var,$(image))_RULES :=))) +$(foreach target, $(TARGET_TYPES), \ $(foreach test, $(TEST_ART_RUN_TESTS), \ $(eval ART_RUN_TEST_$(call name-to-var,$(target))_$(call name-to-var,$(test))_RULES :=))) $(foreach target, $(TARGET_TYPES), \ @@ -485,4 +552,5 @@ RELOCATE_TYPES := TRACE_TYPES := GC_TYPES := JNI_TYPES := +IMAGE_TYPES := ALL_ADDRESS_SIZES := diff --git a/test/etc/host-run-test-jar b/test/etc/host-run-test-jar index ce85eb087d..bce34f6d70 100755 --- a/test/etc/host-run-test-jar +++ b/test/etc/host-run-test-jar @@ -23,6 +23,10 @@ QUIET="n" FLAGS="" COMPILER_FLAGS="" BUILD_BOOT_OPT="" +PATCHOAT="" +DEX2OAT="" +FALSE_BIN="/bin/false" +HAVE_IMAGE="y" exe="${ANDROID_HOST_OUT}/bin/dalvikvm32" main="Main" @@ -33,6 +37,12 @@ while true; do elif [ "x$1" = "x--prebuild" ]; then PREBUILD="y" shift + elif [ "x$1" = "x--no-dex2oat" ]; then + DEX2OAT="-Xcompiler:${FALSE_BIN}" + shift + elif [ "x$1" = "x--no-patchoat" ]; then + PATCHOAT="-Xpatchoat:${FALSE_BIN}" + shift elif [ "x$1" = "x--lib" ]; then shift if [ "x$1" = "x" ]; then @@ -44,6 +54,9 @@ while true; do LIB=${LIB/%so/dylib} fi shift + elif [ "x$1" = "x--no-image" ]; then + HAVE_IMAGE="n" + shift elif [ "x$1" = "x--boot" ]; then shift option="$1" @@ -157,6 +170,13 @@ if [ "$INTERPRETER" = "y" ]; then COMPILER_FLAGS="${COMPILER_FLAGS} --compiler-filter=interpret-only" fi +if [ "$HAVE_IMAGE" = "n" ]; then + # Set image to a place were there isn't one and then set the bootclasspath + # so we can create it. + BOOT_OPT="-Ximage:/system/framework/boot.art" + BOOT_OPT="${BOOT_OPT} -Xbootclasspath:$ANDROID_HOST_OUT/../common/obj/JAVA_LIBRARIES/core-libart-hostdex_intermediates/javalib.jar" +fi + if [ "$RELOCATE" = "y" ]; then FLAGS="${FLAGS} -Xrelocate" COMPILER_FLAGS="${COMPILER_FLAGS} --runtime-arg -Xnorelocate --include-patch-information" @@ -178,7 +198,7 @@ else fi JNI_OPTS="-Xjnigreflimit:512 -Xcheck:jni" -cmdline="$INVOKE_WITH $gdb $exe $gdbargs -XXlib:$LIB $JNI_OPTS $FLAGS $INT_OPTS $DEBUGGER_OPTS $BOOT_OPT -cp $DEX_LOCATION/$TEST_NAME.jar $main" +cmdline="$INVOKE_WITH $gdb $exe $gdbargs -XXlib:$LIB $PATCHOAT $DEX2OAT $JNI_OPTS $FLAGS $INT_OPTS $DEBUGGER_OPTS $BOOT_OPT -cp $DEX_LOCATION/$TEST_NAME.jar $main" if [ "$DEV_MODE" = "y" ]; then if [ "$PREBUILD" = "y" ]; then echo "$mkdir_cmd && $prebuild_cmd && $cmdline" @@ -190,4 +210,7 @@ if [ "$DEV_MODE" = "y" ]; then fi cd $ANDROID_BUILD_TOP -$mkdir_cmd && $prebuild_cmd && LD_PRELOAD=libsigchain.so $cmdline "$@" +# If we are execing /bin/false we might not be on the same ISA as libsigchain.so +# ld.so will helpfully warn us of this. Unfortunately this messes up our error +# checking so we will just filter out the error with a grep. +$mkdir_cmd && $prebuild_cmd && LD_PRELOAD=libsigchain.so $cmdline "$@" 2>&1 | grep -v -E "^ERROR: ld\.so: object '.+\.so' from LD_PRELOAD cannot be preloaded: ignored\.$" diff --git a/test/etc/push-and-run-prebuilt-test-jar b/test/etc/push-and-run-prebuilt-test-jar index ad23edff29..c1d407d7f3 100755 --- a/test/etc/push-and-run-prebuilt-test-jar +++ b/test/etc/push-and-run-prebuilt-test-jar @@ -26,6 +26,10 @@ FLAGS="" TARGET_SUFFIX="32" GDB_TARGET_SUFFIX="" COMPILE_FLAGS="" +FALSE_BIN="/system/bin/false" +PATCHOAT="" +DEX2OAT="" +HAVE_IMAGE="y" while true; do if [ "x$1" = "x--quiet" ]; then @@ -55,12 +59,21 @@ while true; do BOOT_OPT="$1" BUILD_BOOT_OPT="--boot-image=${1#-Ximage:}" shift + elif [ "x$1" = "x--no-dex2oat" ]; then + DEX2OAT="-Xcompiler:${FALSE_BIN}" + shift + elif [ "x$1" = "x--no-patchoat" ]; then + PATCHOAT="-Xpatchoat:${FALSE_BIN}" + shift elif [ "x$1" = "x--relocate" ]; then RELOCATE="y" shift elif [ "x$1" = "x--no-relocate" ]; then RELOCATE="n" shift + elif [ "x$1" = "x--no-image" ]; then + HAVE_IMAGE="n" + shift elif [ "x$1" = "x--debug" ]; then DEBUGGER="y" shift @@ -136,6 +149,11 @@ fi msg "------------------------------" +if [ "$HAVE_IMAGE" = "n" ]; then + BOOT_OPT="-Ximage:/system/non-existant/boot.art" + BOOT_OPT="${BOOT_OPT} -Xbootclasspath:/system/framework/core-libart.jar" +fi + ARCH=$(adb shell ls -F /data/dalvik-cache | grep -Ewo "${ARCHITECTURES_PATTERN}") if [ x"$ARCH" = "x" ]; then echo "Unable to determine architecture" @@ -194,7 +212,7 @@ fi cmdline="cd $DEX_LOCATION && export ANDROID_DATA=$DEX_LOCATION && export DEX_LOCATION=$DEX_LOCATION && \ mkdir -p $DEX_LOCATION/dalvik-cache/$ARCH/ && \ $INVOKE_WITH /system/bin/dex2oatd $COMPILE_FLAGS $BUILD_BOOT_OPT $BUILD_RELOCATE_OPT --runtime-arg -classpath --runtime-arg $DEX_LOCATION/$TEST_NAME.jar --dex-file=$DEX_LOCATION/$TEST_NAME.jar --oat-file=$DEX_LOCATION/dalvik-cache/$ARCH/$(echo $DEX_LOCATION/$TEST_NAME.jar/classes.dex | cut -d/ -f 2- | sed "s:/:@:g") --instruction-set=$ARCH && \ - $INVOKE_WITH $gdb /system/bin/dalvikvm$TARGET_SUFFIX $FLAGS $gdbargs -XXlib:$LIB $ZYGOTE $JNI_OPTS $RELOCATE_OPT $INT_OPTS $DEBUGGER_OPTS $BOOT_OPT -cp $DEX_LOCATION/$TEST_NAME.jar Main $@" + $INVOKE_WITH $gdb /system/bin/dalvikvm$TARGET_SUFFIX $FLAGS $gdbargs -XXlib:$LIB $PATCHOAT $DEX2OAT $ZYGOTE $JNI_OPTS $RELOCATE_OPT $INT_OPTS $DEBUGGER_OPTS $BOOT_OPT -cp $DEX_LOCATION/$TEST_NAME.jar Main $@" cmdfile=$(tempfile -p "cmd-" -s "-$TEST_NAME") echo "$cmdline" > $cmdfile diff --git a/test/etc/push-and-run-test-jar b/test/etc/push-and-run-test-jar index 06075c2619..9e63beddef 100755 --- a/test/etc/push-and-run-test-jar +++ b/test/etc/push-and-run-test-jar @@ -22,6 +22,10 @@ INVOKE_WITH="" FLAGS="" TARGET_SUFFIX="32" GDB_TARGET_SUFFIX="" +FALSE_BIN="/system/bin/false" +PATCHOAT="" +DEX2OAT="" +HAVE_IMAGE="y" while true; do if [ "x$1" = "x--quiet" ]; then @@ -40,6 +44,15 @@ while true; do option="$1" FLAGS="${FLAGS} -Xcompiler-option $option" shift + elif [ "x$1" = "x--no-image" ]; then + HAVE_IMAGE="n" + shift + elif [ "x$1" = "x--no-dex2oat" ]; then + DEX2OAT="-Xcompiler:${FALSE_BIN}" + shift + elif [ "x$1" = "x--no-patchoat" ]; then + PATCHOAT="-Xpatchoat:${FALSE_BIN}" + shift elif [ "x$1" = "x--runtime-option" ]; then shift option="$1" @@ -129,6 +142,11 @@ fi msg "------------------------------" +if [ "$HAVE_IMAGE" = "n" ]; then + BOOT_OPT="-Ximage:/system/non-existant/boot.art" + BOOT_OPT="${BOOT_OPT} -Xbootclasspath:/system/framework/core-libart.jar" +fi + if [ "$QUIET" = "n" ]; then adb shell rm -r $DEX_LOCATION adb shell mkdir -p $DEX_LOCATION @@ -172,7 +190,7 @@ else fi cmdline="cd $DEX_LOCATION && export ANDROID_DATA=$DEX_LOCATION && export DEX_LOCATION=$DEX_LOCATION && \ - $INVOKE_WITH $gdb /system/bin/dalvikvm$TARGET_SUFFIX $FLAGS $gdbargs -XXlib:$LIB $ZYGOTE $JNI_OPTS $RELOCATE_OPT $INT_OPTS $DEBUGGER_OPTS $BOOT_OPT -cp $DEX_LOCATION/$TEST_NAME.jar Main" + $INVOKE_WITH $gdb /system/bin/dalvikvm$TARGET_SUFFIX $FLAGS $gdbargs -XXlib:$LIB $PATCHOAT $DEX2OAT $ZYGOTE $JNI_OPTS $RELOCATE_OPT $INT_OPTS $DEBUGGER_OPTS $BOOT_OPT -cp $DEX_LOCATION/$TEST_NAME.jar Main" if [ "$DEV_MODE" = "y" ]; then echo $cmdline "$@" fi diff --git a/test/run-all-tests b/test/run-all-tests index 98f1208e2e..318a0de17e 100755 --- a/test/run-all-tests +++ b/test/run-all-tests @@ -101,6 +101,12 @@ while true; do elif [ "x$1" = "x--prebuild" ]; then run_args="${run_args} --prebuild" shift; + elif [ "x$1" = "x--no-dex2oat" ]; then + run_args="${run_args} --no-dex2oat" + shift; + elif [ "x$1" = "x--no-patchoat" ]; then + run_args="${run_args} --no-patchoat" + shift; elif [ "x$1" = "x--always-clean" ]; then run_args="${run_args} --always-clean" elif expr "x$1" : "x--" >/dev/null 2>&1; then @@ -123,6 +129,7 @@ if [ "$usage" = "yes" ]; then echo " --debug --dev --host --interpreter --jvm --no-optimize" echo " --no-verify -O --update --valgrind --zygote --64 --relocate" echo " --prebuild --always-clean --gcstress --gcverify --trace" + echo " --no-patchoat --no-dex2oat" echo " Specific Runtime Options:" echo " --seq Run tests one-by-one, avoiding failures caused by busy CPU" ) 1>&2 diff --git a/test/run-test b/test/run-test index 6fac03b467..2b4a41dcbf 100755 --- a/test/run-test +++ b/test/run-test @@ -81,6 +81,9 @@ basic_verify="false" gc_verify="false" gc_stress="false" always_clean="no" +have_dex2oat="yes" +have_patchoat="yes" +have_image="yes" while true; do if [ "x$1" = "x--host" ]; then @@ -99,6 +102,15 @@ while true; do lib="libdvm.so" runtime="dalvik" shift + elif [ "x$1" = "x--no-dex2oat" ]; then + have_dex2oat="no" + shift + elif [ "x$1" = "x--no-patchoat" ]; then + have_patchoat="no" + shift + elif [ "x$1" = "x--no-image" ]; then + have_image="no" + shift elif [ "x$1" = "x--relocate" ]; then relocate="yes" shift @@ -261,6 +273,14 @@ else fi fi +if [ "$have_patchoat" = "no" ]; then + run_args="${run_args} --no-patchoat" +fi + +if [ "$have_dex2oat" = "no" ]; then + run_args="${run_args} --no-dex2oat" +fi + if [ ! "$runtime" = "jvm" ]; then run_args="${run_args} --lib $lib" fi @@ -296,6 +316,10 @@ elif [ "$runtime" = "art" ]; then fi fi +if [ "$have_image" = "no" ]; then + run_args="${run_args} --no-image" +fi + if [ "$dev_mode" = "yes" -a "$update_mode" = "yes" ]; then echo "--dev and --update are mutually exclusive" 1>&2 usage="yes" @@ -347,6 +371,8 @@ if [ "$usage" = "yes" ]; then echo " --zygote Spawn the process from the Zygote." \ "If used, then the" echo " other runtime options are ignored." + echo " --no-dex2oat Run as though dex2oat was failing." + echo " --no-patchoat Run as though patchoat was failing." echo " --prebuild Run dex2oat on the files before starting test. (default)" echo " --no-prebuild Do not run dex2oat on the files before starting" echo " the test." |