diff options
author | 2020-02-05 16:25:36 +0000 | |
---|---|---|
committer | 2020-02-07 00:34:58 +0000 | |
commit | cf0c6ef642517fba3bc9a211acaed742ff39b86d (patch) | |
tree | 045be891d40e7671edf55444d84bb371d1347c04 /runtime/dexopt_test.cc | |
parent | 7c2f69e42e5347820ada07c88de5a79f355c61be (diff) |
Device gtests: Use boot.art instead of core.art.
They are essentially the same. We can use boot.art to run gtests
since it is already part of the apex, including the jar files.
This will make it easier to run the tests in atest, since we
will not have to worry about copying core.art to the device.
The long-term goal is to avoid generating core.art altogether.
Couple of tests also require "alternate" image which has no
compiled code. The tests now generate it on-demand in code.
The host gtests still use core.art for now (as there is no
boot.art on host). The plan is to add it in future CLs.
Test: m test-art-host-gtest
Test: ./art/tools/run-gtests.sh
Bug: 147817606
Change-Id: I3a750bb8e60eea0b4a7df1491285feffd5a0161c
Diffstat (limited to 'runtime/dexopt_test.cc')
-rw-r--r-- | runtime/dexopt_test.cc | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/runtime/dexopt_test.cc b/runtime/dexopt_test.cc index afbd053e95..8ba6f3ec1d 100644 --- a/runtime/dexopt_test.cc +++ b/runtime/dexopt_test.cc @@ -69,6 +69,28 @@ bool DexoptTest::Dex2Oat(const std::vector<std::string>& args, std::string* erro return Exec(argv, error_msg); } +std::string DexoptTest::GenerateAlternateImage(const std::string& scratch_dir) { + std::vector<std::string> libcore_dex_files = GetLibCoreDexFileNames(); + std::vector<std::string> libcore_dex_locations = GetLibCoreDexLocations(); + + std::string image_dir = scratch_dir + GetInstructionSetString(kRuntimeISA); + int mkdir_result = mkdir(image_dir.c_str(), 0700); + CHECK_EQ(0, mkdir_result) << image_dir.c_str(); + + std::vector<std::string> extra_args { + "--compiler-filter=verify", + android::base::StringPrintf("--base=0x%08x", ART_BASE_ADDRESS), + }; + std::string filename_prefix = image_dir + "/boot-interpreter"; + ArrayRef<const std::string> dex_files(libcore_dex_files); + ArrayRef<const std::string> dex_locations(libcore_dex_locations); + std::string error_msg; + bool ok = CompileBootImage(extra_args, filename_prefix, dex_files, dex_locations, &error_msg); + EXPECT_TRUE(ok) << error_msg; + + return scratch_dir + "boot-interpreter.art"; +} + void DexoptTest::GenerateOatForTest(const std::string& dex_location, const std::string& oat_location, CompilerFilter::Filter filter, @@ -92,8 +114,11 @@ void DexoptTest::GenerateOatForTest(const std::string& dex_location, } std::string image_location = GetImageLocation(); + std::optional<ScratchDir> scratch; if (with_alternate_image) { - args.push_back("--boot-image=" + GetImageLocation2()); + scratch.emplace(); // Create the scratch directory for the generated boot image. + std::string alternate_image_location = GenerateAlternateImage(scratch->GetPath()); + args.push_back("--boot-image=" + alternate_image_location); } if (compilation_reason != nullptr) { |