blob: a1d3ed9241750cff97ee794eae14a3324e7f508e [file] [log] [blame]
Richard Uhler66d874d2015-01-15 09:37:19 -08001/*
2 * Copyright (C) 2014 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
Richard Uhler66d874d2015-01-15 09:37:19 -080017#include <algorithm>
18#include <fstream>
19#include <string>
20#include <vector>
21#include <sys/param.h>
22
23#include <backtrace/BacktraceMap.h>
24#include <gtest/gtest.h>
25
Mathieu Chartierc7853442015-03-27 14:35:38 -070026#include "art_field-inl.h"
Vladimir Marko3481ba22015-04-13 12:22:36 +010027#include "class_linker-inl.h"
Richard Uhler66d874d2015-01-15 09:37:19 -080028#include "common_runtime_test.h"
Andreas Gampebb9c6b12015-03-29 13:56:36 -070029#include "compiler_callbacks.h"
Andreas Gampee1459ae2016-06-29 09:36:30 -070030#include "dex2oat_environment_test.h"
Richard Uhlerf16d5722015-05-11 09:32:47 -070031#include "gc/space/image_space.h"
Richard Uhler66d874d2015-01-15 09:37:19 -080032#include "mem_map.h"
Andreas Gampee1459ae2016-06-29 09:36:30 -070033#include "oat_file_assistant.h"
Mathieu Chartierf9c6fc62015-10-07 11:44:05 -070034#include "oat_file_manager.h"
Richard Uhler66d874d2015-01-15 09:37:19 -080035#include "os.h"
Richard Uhler23cedd22015-04-08 13:17:29 -070036#include "scoped_thread_state_change.h"
Richard Uhler66d874d2015-01-15 09:37:19 -080037#include "thread-inl.h"
38#include "utils.h"
39
40namespace art {
41
Andreas Gampee1459ae2016-06-29 09:36:30 -070042class OatFileAssistantTest : public Dex2oatEnvironmentTest {
Richard Uhler66d874d2015-01-15 09:37:19 -080043 public:
Andreas Gampee1459ae2016-06-29 09:36:30 -070044 virtual void SetUp() OVERRIDE {
Richard Uhler66d874d2015-01-15 09:37:19 -080045 ReserveImageSpace();
Andreas Gampee1459ae2016-06-29 09:36:30 -070046 Dex2oatEnvironmentTest::SetUp();
Richard Uhler66d874d2015-01-15 09:37:19 -080047 }
48
Richard Uhlera48403e2016-04-26 10:24:38 -070049 // Pre-Relocate the image to a known non-zero offset so we don't have to
50 // deal with the runtime randomly relocating the image by 0 and messing up
51 // the expected results of the tests.
52 bool PreRelocateImage(std::string* error_msg) {
53 std::string image;
54 if (!GetCachedImageFile(&image, error_msg)) {
55 return false;
56 }
57
58 std::string patchoat = GetAndroidRoot();
59 patchoat += kIsDebugBuild ? "/bin/patchoatd" : "/bin/patchoat";
60
61 std::vector<std::string> argv;
62 argv.push_back(patchoat);
63 argv.push_back("--input-image-location=" + GetImageLocation());
64 argv.push_back("--output-image-file=" + image);
65 argv.push_back("--instruction-set=" + std::string(GetInstructionSetString(kRuntimeISA)));
66 argv.push_back("--base-offset-delta=0x00008000");
67 return Exec(argv, error_msg);
68 }
69
Richard Uhler66d874d2015-01-15 09:37:19 -080070 virtual void PreRuntimeCreate() {
Richard Uhlera48403e2016-04-26 10:24:38 -070071 std::string error_msg;
72 ASSERT_TRUE(PreRelocateImage(&error_msg)) << error_msg;
73
Richard Uhler66d874d2015-01-15 09:37:19 -080074 UnreserveImageSpace();
75 }
76
Andreas Gampee1459ae2016-06-29 09:36:30 -070077 virtual void PostRuntimeCreate() OVERRIDE {
Richard Uhler66d874d2015-01-15 09:37:19 -080078 ReserveImageSpace();
79 }
80
Richard Uhler93aa2102015-08-10 14:47:41 -070081 // Generate a non-PIC odex file for the purposes of test.
Richard Uhler94f5bda2015-07-22 08:25:11 -070082 // The generated odex file will be un-relocated.
Richard Uhler66d874d2015-01-15 09:37:19 -080083 void GenerateOdexForTest(const std::string& dex_location,
Andreas Gampe29d38e72016-03-23 15:31:51 +000084 const std::string& odex_location,
Richard Uhlera48403e2016-04-26 10:24:38 -070085 CompilerFilter::Filter filter,
86 bool pic = false,
87 bool with_patch_info = true) {
88 // Temporarily redirect the dalvik cache so dex2oat doesn't find the
89 // relocated image file.
90 std::string android_data_tmp = GetScratchDir() + "AndroidDataTmp";
91 setenv("ANDROID_DATA", android_data_tmp.c_str(), 1);
Richard Uhler93aa2102015-08-10 14:47:41 -070092 std::vector<std::string> args;
93 args.push_back("--dex-file=" + dex_location);
Richard Uhlera48403e2016-04-26 10:24:38 -070094 args.push_back("--oat-file=" + odex_location);
Andreas Gampe29d38e72016-03-23 15:31:51 +000095 args.push_back("--compiler-filter=" + CompilerFilter::NameOfFilter(filter));
Richard Uhlera48403e2016-04-26 10:24:38 -070096 args.push_back("--runtime-arg");
97 args.push_back("-Xnorelocate");
Richard Uhler93aa2102015-08-10 14:47:41 -070098
Richard Uhlera48403e2016-04-26 10:24:38 -070099 if (pic) {
100 args.push_back("--compile-pic");
101 }
102
103 if (with_patch_info) {
104 args.push_back("--include-patch-information");
105 }
Richard Uhler93aa2102015-08-10 14:47:41 -0700106
107 std::string error_msg;
108 ASSERT_TRUE(OatFileAssistant::Dex2Oat(args, &error_msg)) << error_msg;
Richard Uhlera48403e2016-04-26 10:24:38 -0700109 setenv("ANDROID_DATA", android_data_.c_str(), 1);
Richard Uhler93aa2102015-08-10 14:47:41 -0700110
111 // Verify the odex file was generated as expected and really is
112 // unrelocated.
Mathieu Chartier0b4cbd02016-03-08 16:49:58 -0800113 std::unique_ptr<OatFile> odex_file(OatFile::Open(odex_location.c_str(),
114 odex_location.c_str(),
115 nullptr,
116 nullptr,
117 false,
118 /*low_4gb*/false,
119 dex_location.c_str(),
120 &error_msg));
Richard Uhler93aa2102015-08-10 14:47:41 -0700121 ASSERT_TRUE(odex_file.get() != nullptr) << error_msg;
Richard Uhlera48403e2016-04-26 10:24:38 -0700122 EXPECT_EQ(pic, odex_file->IsPic());
123 EXPECT_EQ(with_patch_info, odex_file->HasPatchInfo());
Andreas Gampe29d38e72016-03-23 15:31:51 +0000124 EXPECT_EQ(filter, odex_file->GetCompilerFilter());
125
Vladimir Markof6d1e0f2016-05-23 15:32:42 +0100126 if (CompilerFilter::IsBytecodeCompilationEnabled(filter)) {
Andreas Gampe29d38e72016-03-23 15:31:51 +0000127 const std::vector<gc::space::ImageSpace*> image_spaces =
Richard Uhlera48403e2016-04-26 10:24:38 -0700128 Runtime::Current()->GetHeap()->GetBootImageSpaces();
Andreas Gampe29d38e72016-03-23 15:31:51 +0000129 ASSERT_TRUE(!image_spaces.empty() && image_spaces[0] != nullptr);
130 const ImageHeader& image_header = image_spaces[0]->GetImageHeader();
131 const OatHeader& oat_header = odex_file->GetOatHeader();
Jeff Haob11ffb72016-04-07 15:40:54 -0700132 uint32_t combined_checksum = OatFileAssistant::CalculateCombinedImageChecksum();
133 EXPECT_EQ(combined_checksum, oat_header.GetImageFileLocationOatChecksum());
Andreas Gampe29d38e72016-03-23 15:31:51 +0000134 EXPECT_NE(reinterpret_cast<uintptr_t>(image_header.GetOatDataBegin()),
135 oat_header.GetImageFileLocationOatDataBegin());
136 EXPECT_NE(image_header.GetPatchDelta(), oat_header.GetImagePatchDelta());
137 }
Richard Uhler93aa2102015-08-10 14:47:41 -0700138 }
139
140 void GeneratePicOdexForTest(const std::string& dex_location,
Andreas Gampe29d38e72016-03-23 15:31:51 +0000141 const std::string& odex_location,
142 CompilerFilter::Filter filter) {
Richard Uhlera48403e2016-04-26 10:24:38 -0700143 GenerateOdexForTest(dex_location, odex_location, filter, true, false);
Calin Juravleb077e152016-02-18 18:47:37 +0000144 }
David Brazdilce4b0ba2016-01-28 15:05:49 +0000145
Richard Uhlerd1537b52016-03-29 13:27:41 -0700146 // Generate a non-PIC odex file without patch information for the purposes
147 // of test. The generated odex file will be un-relocated.
Richard Uhlerd1537b52016-03-29 13:27:41 -0700148 void GenerateNoPatchOdexForTest(const std::string& dex_location,
149 const std::string& odex_location,
150 CompilerFilter::Filter filter) {
Richard Uhlera48403e2016-04-26 10:24:38 -0700151 GenerateOdexForTest(dex_location, odex_location, filter, false, false);
Richard Uhlerd1537b52016-03-29 13:27:41 -0700152 }
153
Richard Uhler66d874d2015-01-15 09:37:19 -0800154 private:
155 // Reserve memory around where the image will be loaded so other memory
156 // won't conflict when it comes time to load the image.
157 // This can be called with an already loaded image to reserve the space
158 // around it.
159 void ReserveImageSpace() {
160 MemMap::Init();
161
162 // Ensure a chunk of memory is reserved for the image space.
Richard Uhlera48403e2016-04-26 10:24:38 -0700163 // The reservation_end includes room for the main space that has to come
164 // right after the image in case of the GSS collector.
165 uintptr_t reservation_start = ART_BASE_ADDRESS;
166 uintptr_t reservation_end = ART_BASE_ADDRESS + 384 * MB;
Richard Uhler66d874d2015-01-15 09:37:19 -0800167
Richard Uhler66d874d2015-01-15 09:37:19 -0800168 std::unique_ptr<BacktraceMap> map(BacktraceMap::Create(getpid(), true));
169 ASSERT_TRUE(map.get() != nullptr) << "Failed to build process map";
170 for (BacktraceMap::const_iterator it = map->begin();
171 reservation_start < reservation_end && it != map->end(); ++it) {
Richard Uhler3efe9792015-03-30 16:18:03 -0700172 ReserveImageSpaceChunk(reservation_start, std::min(it->start, reservation_end));
173 reservation_start = std::max(reservation_start, it->end);
174 }
175 ReserveImageSpaceChunk(reservation_start, reservation_end);
176 }
Richard Uhler66d874d2015-01-15 09:37:19 -0800177
Richard Uhler3efe9792015-03-30 16:18:03 -0700178 // Reserve a chunk of memory for the image space in the given range.
179 // Only has effect for chunks with a positive number of bytes.
180 void ReserveImageSpaceChunk(uintptr_t start, uintptr_t end) {
181 if (start < end) {
182 std::string error_msg;
Richard Uhler66d874d2015-01-15 09:37:19 -0800183 image_reservation_.push_back(std::unique_ptr<MemMap>(
184 MemMap::MapAnonymous("image reservation",
Richard Uhler3efe9792015-03-30 16:18:03 -0700185 reinterpret_cast<uint8_t*>(start), end - start,
Igor Murashkinb1d8c312015-08-04 11:18:43 -0700186 PROT_NONE, false, false, &error_msg)));
Richard Uhler66d874d2015-01-15 09:37:19 -0800187 ASSERT_TRUE(image_reservation_.back().get() != nullptr) << error_msg;
188 LOG(INFO) << "Reserved space for image " <<
189 reinterpret_cast<void*>(image_reservation_.back()->Begin()) << "-" <<
190 reinterpret_cast<void*>(image_reservation_.back()->End());
Richard Uhler66d874d2015-01-15 09:37:19 -0800191 }
192 }
193
194
195 // Unreserve any memory reserved by ReserveImageSpace. This should be called
196 // before the image is loaded.
197 void UnreserveImageSpace() {
198 image_reservation_.clear();
199 }
200
Richard Uhler66d874d2015-01-15 09:37:19 -0800201 std::vector<std::unique_ptr<MemMap>> image_reservation_;
202};
203
204class OatFileAssistantNoDex2OatTest : public OatFileAssistantTest {
205 public:
206 virtual void SetUpRuntimeOptions(RuntimeOptions* options) {
207 OatFileAssistantTest::SetUpRuntimeOptions(options);
208 options->push_back(std::make_pair("-Xnodex2oat", nullptr));
209 }
210};
211
212// Generate an oat file for the purposes of test, as opposed to testing
213// generation of oat files.
Andreas Gampe29d38e72016-03-23 15:31:51 +0000214static void GenerateOatForTest(const char* dex_location, CompilerFilter::Filter filter) {
215 // Use an oat file assistant to find the proper oat location.
216 OatFileAssistant ofa(dex_location, kRuntimeISA, false, false);
217 const std::string* oat_location = ofa.OatFileName();
218 ASSERT_TRUE(oat_location != nullptr);
Richard Uhler66d874d2015-01-15 09:37:19 -0800219
Andreas Gampe29d38e72016-03-23 15:31:51 +0000220 std::vector<std::string> args;
221 args.push_back("--dex-file=" + std::string(dex_location));
222 args.push_back("--oat-file=" + *oat_location);
223 args.push_back("--compiler-filter=" + CompilerFilter::NameOfFilter(filter));
224 args.push_back("--runtime-arg");
225 args.push_back("-Xnorelocate");
Richard Uhler66d874d2015-01-15 09:37:19 -0800226 std::string error_msg;
Andreas Gampe29d38e72016-03-23 15:31:51 +0000227 ASSERT_TRUE(OatFileAssistant::Dex2Oat(args, &error_msg)) << error_msg;
228
229 // Verify the oat file was generated as expected.
230 std::unique_ptr<OatFile> oat_file(OatFile::Open(oat_location->c_str(),
231 oat_location->c_str(),
232 nullptr,
233 nullptr,
234 false,
235 /*low_4gb*/false,
236 dex_location,
237 &error_msg));
238 ASSERT_TRUE(oat_file.get() != nullptr) << error_msg;
239 EXPECT_EQ(filter, oat_file->GetCompilerFilter());
Richard Uhler66d874d2015-01-15 09:37:19 -0800240}
241
242// Case: We have a DEX file, but no OAT file for it.
Richard Uhler95abd042015-03-24 09:51:28 -0700243// Expect: The status is kDex2OatNeeded.
Richard Uhler66d874d2015-01-15 09:37:19 -0800244TEST_F(OatFileAssistantTest, DexNoOat) {
245 std::string dex_location = GetScratchDir() + "/DexNoOat.jar";
246 Copy(GetDexSrc1(), dex_location);
247
Andreas Gampe29d38e72016-03-23 15:31:51 +0000248 OatFileAssistant oat_file_assistant(dex_location.c_str(), kRuntimeISA, false, false);
Richard Uhler66d874d2015-01-15 09:37:19 -0800249
Andreas Gampe29d38e72016-03-23 15:31:51 +0000250 EXPECT_EQ(OatFileAssistant::kDex2OatNeeded,
251 oat_file_assistant.GetDexOptNeeded(CompilerFilter::kVerifyAtRuntime));
252 EXPECT_EQ(OatFileAssistant::kDex2OatNeeded,
253 oat_file_assistant.GetDexOptNeeded(CompilerFilter::kInterpretOnly));
254 EXPECT_EQ(OatFileAssistant::kDex2OatNeeded,
255 oat_file_assistant.GetDexOptNeeded(CompilerFilter::kSpeedProfile));
256 EXPECT_EQ(OatFileAssistant::kDex2OatNeeded,
257 oat_file_assistant.GetDexOptNeeded(CompilerFilter::kSpeed));
Richard Uhler66d874d2015-01-15 09:37:19 -0800258
259 EXPECT_FALSE(oat_file_assistant.IsInBootClassPath());
260 EXPECT_FALSE(oat_file_assistant.OdexFileExists());
261 EXPECT_TRUE(oat_file_assistant.OdexFileIsOutOfDate());
262 EXPECT_FALSE(oat_file_assistant.OdexFileNeedsRelocation());
263 EXPECT_FALSE(oat_file_assistant.OdexFileIsUpToDate());
Richard Uhler95abd042015-03-24 09:51:28 -0700264 EXPECT_EQ(OatFileAssistant::kOatOutOfDate, oat_file_assistant.OdexFileStatus());
Richard Uhler66d874d2015-01-15 09:37:19 -0800265 EXPECT_FALSE(oat_file_assistant.OatFileExists());
266 EXPECT_TRUE(oat_file_assistant.OatFileIsOutOfDate());
267 EXPECT_FALSE(oat_file_assistant.OatFileNeedsRelocation());
268 EXPECT_FALSE(oat_file_assistant.OatFileIsUpToDate());
Richard Uhler95abd042015-03-24 09:51:28 -0700269 EXPECT_EQ(OatFileAssistant::kOatOutOfDate, oat_file_assistant.OatFileStatus());
Richard Uhler9b994ea2015-06-24 08:44:19 -0700270 EXPECT_TRUE(oat_file_assistant.HasOriginalDexFiles());
Richard Uhler66d874d2015-01-15 09:37:19 -0800271}
272
273// Case: We have no DEX file and no OAT file.
Richard Uhler9b994ea2015-06-24 08:44:19 -0700274// Expect: Status is kNoDexOptNeeded. Loading should fail, but not crash.
Richard Uhler66d874d2015-01-15 09:37:19 -0800275TEST_F(OatFileAssistantTest, NoDexNoOat) {
276 std::string dex_location = GetScratchDir() + "/NoDexNoOat.jar";
277
Andreas Gampe29d38e72016-03-23 15:31:51 +0000278 OatFileAssistant oat_file_assistant(dex_location.c_str(), kRuntimeISA, false, true);
Richard Uhler66d874d2015-01-15 09:37:19 -0800279
Andreas Gampe29d38e72016-03-23 15:31:51 +0000280 EXPECT_EQ(OatFileAssistant::kNoDexOptNeeded,
281 oat_file_assistant.GetDexOptNeeded(CompilerFilter::kSpeed));
Richard Uhler9b994ea2015-06-24 08:44:19 -0700282 EXPECT_FALSE(oat_file_assistant.HasOriginalDexFiles());
283
284 // Trying to make the oat file up to date should not fail or crash.
285 std::string error_msg;
Richard Uhlerf4b34872016-04-13 11:03:46 -0700286 EXPECT_EQ(OatFileAssistant::kUpdateSucceeded, oat_file_assistant.MakeUpToDate(&error_msg));
Richard Uhler9b994ea2015-06-24 08:44:19 -0700287
288 // Trying to get the best oat file should fail, but not crash.
Richard Uhler66d874d2015-01-15 09:37:19 -0800289 std::unique_ptr<OatFile> oat_file = oat_file_assistant.GetBestOatFile();
290 EXPECT_EQ(nullptr, oat_file.get());
291}
292
293// Case: We have a DEX file and up-to-date OAT file for it.
Richard Uhler95abd042015-03-24 09:51:28 -0700294// Expect: The status is kNoDexOptNeeded.
Richard Uhler66d874d2015-01-15 09:37:19 -0800295TEST_F(OatFileAssistantTest, OatUpToDate) {
296 std::string dex_location = GetScratchDir() + "/OatUpToDate.jar";
297 Copy(GetDexSrc1(), dex_location);
Andreas Gampe29d38e72016-03-23 15:31:51 +0000298 GenerateOatForTest(dex_location.c_str(), CompilerFilter::kSpeed);
Richard Uhler66d874d2015-01-15 09:37:19 -0800299
Andreas Gampe29d38e72016-03-23 15:31:51 +0000300 OatFileAssistant oat_file_assistant(dex_location.c_str(), kRuntimeISA, false, false);
Richard Uhler66d874d2015-01-15 09:37:19 -0800301
Andreas Gampe29d38e72016-03-23 15:31:51 +0000302 EXPECT_EQ(OatFileAssistant::kNoDexOptNeeded,
303 oat_file_assistant.GetDexOptNeeded(CompilerFilter::kSpeed));
304 EXPECT_EQ(OatFileAssistant::kNoDexOptNeeded,
305 oat_file_assistant.GetDexOptNeeded(CompilerFilter::kInterpretOnly));
306 EXPECT_EQ(OatFileAssistant::kNoDexOptNeeded,
307 oat_file_assistant.GetDexOptNeeded(CompilerFilter::kVerifyAtRuntime));
308 EXPECT_EQ(OatFileAssistant::kDex2OatNeeded,
309 oat_file_assistant.GetDexOptNeeded(CompilerFilter::kEverything));
310
Richard Uhler66d874d2015-01-15 09:37:19 -0800311 EXPECT_FALSE(oat_file_assistant.IsInBootClassPath());
312 EXPECT_FALSE(oat_file_assistant.OdexFileExists());
313 EXPECT_TRUE(oat_file_assistant.OdexFileIsOutOfDate());
314 EXPECT_FALSE(oat_file_assistant.OdexFileIsUpToDate());
315 EXPECT_TRUE(oat_file_assistant.OatFileExists());
316 EXPECT_FALSE(oat_file_assistant.OatFileIsOutOfDate());
317 EXPECT_FALSE(oat_file_assistant.OatFileNeedsRelocation());
318 EXPECT_TRUE(oat_file_assistant.OatFileIsUpToDate());
Richard Uhler95abd042015-03-24 09:51:28 -0700319 EXPECT_EQ(OatFileAssistant::kOatUpToDate, oat_file_assistant.OatFileStatus());
Richard Uhler9b994ea2015-06-24 08:44:19 -0700320 EXPECT_TRUE(oat_file_assistant.HasOriginalDexFiles());
Richard Uhler66d874d2015-01-15 09:37:19 -0800321}
322
Andreas Gampe29d38e72016-03-23 15:31:51 +0000323// Case: We have a DEX file and speed-profile OAT file for it.
324// Expect: The status is kNoDexOptNeeded if the profile hasn't changed.
325TEST_F(OatFileAssistantTest, ProfileOatUpToDate) {
326 std::string dex_location = GetScratchDir() + "/ProfileOatUpToDate.jar";
327 Copy(GetDexSrc1(), dex_location);
328 GenerateOatForTest(dex_location.c_str(), CompilerFilter::kSpeedProfile);
329
330 OatFileAssistant oat_file_assistant(dex_location.c_str(), kRuntimeISA, false, false);
331
332 EXPECT_EQ(OatFileAssistant::kNoDexOptNeeded,
333 oat_file_assistant.GetDexOptNeeded(CompilerFilter::kSpeedProfile));
334 EXPECT_EQ(OatFileAssistant::kNoDexOptNeeded,
335 oat_file_assistant.GetDexOptNeeded(CompilerFilter::kInterpretOnly));
336
337 EXPECT_FALSE(oat_file_assistant.IsInBootClassPath());
338 EXPECT_FALSE(oat_file_assistant.OdexFileExists());
339 EXPECT_TRUE(oat_file_assistant.OdexFileIsOutOfDate());
340 EXPECT_FALSE(oat_file_assistant.OdexFileIsUpToDate());
341 EXPECT_TRUE(oat_file_assistant.OatFileExists());
342 EXPECT_FALSE(oat_file_assistant.OatFileIsOutOfDate());
343 EXPECT_FALSE(oat_file_assistant.OatFileNeedsRelocation());
344 EXPECT_TRUE(oat_file_assistant.OatFileIsUpToDate());
345 EXPECT_EQ(OatFileAssistant::kOatUpToDate, oat_file_assistant.OatFileStatus());
346 EXPECT_TRUE(oat_file_assistant.HasOriginalDexFiles());
347}
348
349// Case: We have a DEX file and speed-profile OAT file for it.
350// Expect: The status is kNoDex2OatNeeded if the profile has changed.
351TEST_F(OatFileAssistantTest, ProfileOatOutOfDate) {
352 std::string dex_location = GetScratchDir() + "/ProfileOatOutOfDate.jar";
353 Copy(GetDexSrc1(), dex_location);
354 GenerateOatForTest(dex_location.c_str(), CompilerFilter::kSpeedProfile);
355
356 OatFileAssistant oat_file_assistant(dex_location.c_str(), kRuntimeISA, true, false);
357
358 EXPECT_EQ(OatFileAssistant::kDex2OatNeeded,
359 oat_file_assistant.GetDexOptNeeded(CompilerFilter::kSpeedProfile));
360 EXPECT_EQ(OatFileAssistant::kDex2OatNeeded,
361 oat_file_assistant.GetDexOptNeeded(CompilerFilter::kInterpretOnly));
362
363 EXPECT_FALSE(oat_file_assistant.IsInBootClassPath());
364 EXPECT_FALSE(oat_file_assistant.OdexFileExists());
365 EXPECT_TRUE(oat_file_assistant.OdexFileIsOutOfDate());
366 EXPECT_FALSE(oat_file_assistant.OdexFileIsUpToDate());
367 EXPECT_TRUE(oat_file_assistant.OatFileExists());
368 EXPECT_TRUE(oat_file_assistant.OatFileIsOutOfDate());
369 EXPECT_FALSE(oat_file_assistant.OatFileNeedsRelocation());
370 EXPECT_FALSE(oat_file_assistant.OatFileIsUpToDate());
371 EXPECT_EQ(OatFileAssistant::kOatOutOfDate, oat_file_assistant.OatFileStatus());
372 EXPECT_TRUE(oat_file_assistant.HasOriginalDexFiles());
373}
374
Richard Uhler66d874d2015-01-15 09:37:19 -0800375// Case: We have a MultiDEX file and up-to-date OAT file for it.
Richard Uhler95abd042015-03-24 09:51:28 -0700376// Expect: The status is kNoDexOptNeeded and we load all dex files.
Richard Uhler66d874d2015-01-15 09:37:19 -0800377TEST_F(OatFileAssistantTest, MultiDexOatUpToDate) {
378 std::string dex_location = GetScratchDir() + "/MultiDexOatUpToDate.jar";
379 Copy(GetMultiDexSrc1(), dex_location);
Andreas Gampe29d38e72016-03-23 15:31:51 +0000380 GenerateOatForTest(dex_location.c_str(), CompilerFilter::kSpeed);
Richard Uhler66d874d2015-01-15 09:37:19 -0800381
Andreas Gampe29d38e72016-03-23 15:31:51 +0000382 OatFileAssistant oat_file_assistant(dex_location.c_str(), kRuntimeISA, false, true);
383 EXPECT_EQ(OatFileAssistant::kNoDexOptNeeded,
384 oat_file_assistant.GetDexOptNeeded(CompilerFilter::kSpeed));
Richard Uhler9b994ea2015-06-24 08:44:19 -0700385 EXPECT_TRUE(oat_file_assistant.HasOriginalDexFiles());
Richard Uhler95abd042015-03-24 09:51:28 -0700386
387 // Verify we can load both dex files.
Richard Uhlere5fed032015-03-18 08:21:11 -0700388 std::unique_ptr<OatFile> oat_file = oat_file_assistant.GetBestOatFile();
Richard Uhler66d874d2015-01-15 09:37:19 -0800389 ASSERT_TRUE(oat_file.get() != nullptr);
390 EXPECT_TRUE(oat_file->IsExecutable());
391 std::vector<std::unique_ptr<const DexFile>> dex_files;
Richard Uhlere5fed032015-03-18 08:21:11 -0700392 dex_files = oat_file_assistant.LoadDexFiles(*oat_file, dex_location.c_str());
393 EXPECT_EQ(2u, dex_files.size());
394}
395
Richard Uhler67ff7d12015-05-14 13:21:13 -0700396// Case: We have a MultiDEX file where the secondary dex file is out of date.
397// Expect: The status is kDex2OatNeeded.
398TEST_F(OatFileAssistantTest, MultiDexSecondaryOutOfDate) {
399 std::string dex_location = GetScratchDir() + "/MultiDexSecondaryOutOfDate.jar";
400
401 // Compile code for GetMultiDexSrc1.
402 Copy(GetMultiDexSrc1(), dex_location);
Andreas Gampe29d38e72016-03-23 15:31:51 +0000403 GenerateOatForTest(dex_location.c_str(), CompilerFilter::kSpeed);
Richard Uhler67ff7d12015-05-14 13:21:13 -0700404
405 // Now overwrite the dex file with GetMultiDexSrc2 so the secondary checksum
406 // is out of date.
407 Copy(GetMultiDexSrc2(), dex_location);
408
Andreas Gampe29d38e72016-03-23 15:31:51 +0000409 OatFileAssistant oat_file_assistant(dex_location.c_str(), kRuntimeISA, false, true);
410 EXPECT_EQ(OatFileAssistant::kDex2OatNeeded,
411 oat_file_assistant.GetDexOptNeeded(CompilerFilter::kSpeed));
Richard Uhler9b994ea2015-06-24 08:44:19 -0700412 EXPECT_TRUE(oat_file_assistant.HasOriginalDexFiles());
Richard Uhler67ff7d12015-05-14 13:21:13 -0700413}
414
Richard Uhlere5fed032015-03-18 08:21:11 -0700415// Case: We have a MultiDEX file and up-to-date OAT file for it with relative
416// encoded dex locations.
Richard Uhler95abd042015-03-24 09:51:28 -0700417// Expect: The oat file status is kNoDexOptNeeded.
Richard Uhlere5fed032015-03-18 08:21:11 -0700418TEST_F(OatFileAssistantTest, RelativeEncodedDexLocation) {
419 std::string dex_location = GetScratchDir() + "/RelativeEncodedDexLocation.jar";
Richard Uhler63434112015-03-16 14:32:16 -0700420 std::string oat_location = GetOdexDir() + "/RelativeEncodedDexLocation.oat";
Richard Uhlere5fed032015-03-18 08:21:11 -0700421
422 // Create the dex file
423 Copy(GetMultiDexSrc1(), dex_location);
424
425 // Create the oat file with relative encoded dex location.
426 std::vector<std::string> args;
427 args.push_back("--dex-file=" + dex_location);
428 args.push_back("--dex-location=" + std::string("RelativeEncodedDexLocation.jar"));
429 args.push_back("--oat-file=" + oat_location);
Andreas Gampe29d38e72016-03-23 15:31:51 +0000430 args.push_back("--compiler-filter=speed");
Richard Uhlere5fed032015-03-18 08:21:11 -0700431
432 std::string error_msg;
Igor Murashkinb1d8c312015-08-04 11:18:43 -0700433 ASSERT_TRUE(OatFileAssistant::Dex2Oat(args, &error_msg)) << error_msg;
Richard Uhlere5fed032015-03-18 08:21:11 -0700434
435 // Verify we can load both dex files.
436 OatFileAssistant oat_file_assistant(dex_location.c_str(),
437 oat_location.c_str(),
Andreas Gampe29d38e72016-03-23 15:31:51 +0000438 kRuntimeISA, false, true);
Richard Uhlere5fed032015-03-18 08:21:11 -0700439 std::unique_ptr<OatFile> oat_file = oat_file_assistant.GetBestOatFile();
440 ASSERT_TRUE(oat_file.get() != nullptr);
441 EXPECT_TRUE(oat_file->IsExecutable());
442 std::vector<std::unique_ptr<const DexFile>> dex_files;
443 dex_files = oat_file_assistant.LoadDexFiles(*oat_file, dex_location.c_str());
Richard Uhler66d874d2015-01-15 09:37:19 -0800444 EXPECT_EQ(2u, dex_files.size());
445}
446
Richard Uhler95abd042015-03-24 09:51:28 -0700447// Case: We have a DEX file and out-of-date OAT file.
448// Expect: The status is kDex2OatNeeded.
Richard Uhler66d874d2015-01-15 09:37:19 -0800449TEST_F(OatFileAssistantTest, OatOutOfDate) {
450 std::string dex_location = GetScratchDir() + "/OatOutOfDate.jar";
451
452 // We create a dex, generate an oat for it, then overwrite the dex with a
453 // different dex to make the oat out of date.
454 Copy(GetDexSrc1(), dex_location);
Andreas Gampe29d38e72016-03-23 15:31:51 +0000455 GenerateOatForTest(dex_location.c_str(), CompilerFilter::kSpeed);
Richard Uhler66d874d2015-01-15 09:37:19 -0800456 Copy(GetDexSrc2(), dex_location);
457
Andreas Gampe29d38e72016-03-23 15:31:51 +0000458 OatFileAssistant oat_file_assistant(dex_location.c_str(), kRuntimeISA, false, false);
459 EXPECT_EQ(OatFileAssistant::kDex2OatNeeded,
460 oat_file_assistant.GetDexOptNeeded(CompilerFilter::kVerifyAtRuntime));
461 EXPECT_EQ(OatFileAssistant::kDex2OatNeeded,
462 oat_file_assistant.GetDexOptNeeded(CompilerFilter::kSpeed));
Richard Uhler66d874d2015-01-15 09:37:19 -0800463
464 EXPECT_FALSE(oat_file_assistant.IsInBootClassPath());
465 EXPECT_FALSE(oat_file_assistant.OdexFileExists());
466 EXPECT_TRUE(oat_file_assistant.OdexFileIsOutOfDate());
467 EXPECT_FALSE(oat_file_assistant.OdexFileIsUpToDate());
468 EXPECT_TRUE(oat_file_assistant.OatFileExists());
469 EXPECT_TRUE(oat_file_assistant.OatFileIsOutOfDate());
470 EXPECT_FALSE(oat_file_assistant.OatFileIsUpToDate());
Richard Uhler9b994ea2015-06-24 08:44:19 -0700471 EXPECT_TRUE(oat_file_assistant.HasOriginalDexFiles());
Richard Uhler66d874d2015-01-15 09:37:19 -0800472}
473
474// Case: We have a DEX file and an ODEX file, but no OAT file.
Richard Uhler95abd042015-03-24 09:51:28 -0700475// Expect: The status is kPatchOatNeeded.
Richard Uhler66d874d2015-01-15 09:37:19 -0800476TEST_F(OatFileAssistantTest, DexOdexNoOat) {
477 std::string dex_location = GetScratchDir() + "/DexOdexNoOat.jar";
Richard Uhler63434112015-03-16 14:32:16 -0700478 std::string odex_location = GetOdexDir() + "/DexOdexNoOat.odex";
Richard Uhler66d874d2015-01-15 09:37:19 -0800479
480 // Create the dex and odex files
481 Copy(GetDexSrc1(), dex_location);
Andreas Gampe29d38e72016-03-23 15:31:51 +0000482 GenerateOdexForTest(dex_location, odex_location, CompilerFilter::kSpeed);
Richard Uhler66d874d2015-01-15 09:37:19 -0800483
484 // Verify the status.
Andreas Gampe29d38e72016-03-23 15:31:51 +0000485 OatFileAssistant oat_file_assistant(dex_location.c_str(), kRuntimeISA, false, false);
Richard Uhler66d874d2015-01-15 09:37:19 -0800486
Andreas Gampe29d38e72016-03-23 15:31:51 +0000487 EXPECT_EQ(OatFileAssistant::kNoDexOptNeeded,
488 oat_file_assistant.GetDexOptNeeded(CompilerFilter::kVerifyAtRuntime));
489 EXPECT_EQ(OatFileAssistant::kPatchOatNeeded,
490 oat_file_assistant.GetDexOptNeeded(CompilerFilter::kSpeed));
Richard Uhler66d874d2015-01-15 09:37:19 -0800491
492 EXPECT_FALSE(oat_file_assistant.IsInBootClassPath());
493 EXPECT_TRUE(oat_file_assistant.OdexFileExists());
494 EXPECT_FALSE(oat_file_assistant.OdexFileIsOutOfDate());
495 EXPECT_FALSE(oat_file_assistant.OdexFileIsUpToDate());
496 EXPECT_TRUE(oat_file_assistant.OdexFileNeedsRelocation());
Richard Uhler66d874d2015-01-15 09:37:19 -0800497 EXPECT_FALSE(oat_file_assistant.OatFileExists());
498 EXPECT_TRUE(oat_file_assistant.OatFileIsOutOfDate());
499 EXPECT_FALSE(oat_file_assistant.OatFileIsUpToDate());
Richard Uhler9b994ea2015-06-24 08:44:19 -0700500 EXPECT_TRUE(oat_file_assistant.HasOriginalDexFiles());
Richard Uhler5f946da2015-07-17 12:28:32 -0700501
502 // We should still be able to get the non-executable odex file to run from.
503 std::unique_ptr<OatFile> oat_file = oat_file_assistant.GetBestOatFile();
504 ASSERT_TRUE(oat_file.get() != nullptr);
Richard Uhler66d874d2015-01-15 09:37:19 -0800505}
506
507// Case: We have a stripped DEX file and an ODEX file, but no OAT file.
Richard Uhler95abd042015-03-24 09:51:28 -0700508// Expect: The status is kPatchOatNeeded
Richard Uhler66d874d2015-01-15 09:37:19 -0800509TEST_F(OatFileAssistantTest, StrippedDexOdexNoOat) {
510 std::string dex_location = GetScratchDir() + "/StrippedDexOdexNoOat.jar";
Richard Uhler63434112015-03-16 14:32:16 -0700511 std::string odex_location = GetOdexDir() + "/StrippedDexOdexNoOat.odex";
Richard Uhler66d874d2015-01-15 09:37:19 -0800512
513 // Create the dex and odex files
514 Copy(GetDexSrc1(), dex_location);
Andreas Gampe29d38e72016-03-23 15:31:51 +0000515 GenerateOdexForTest(dex_location, odex_location, CompilerFilter::kSpeed);
Richard Uhler66d874d2015-01-15 09:37:19 -0800516
517 // Strip the dex file
518 Copy(GetStrippedDexSrc1(), dex_location);
519
520 // Verify the status.
Andreas Gampe29d38e72016-03-23 15:31:51 +0000521 OatFileAssistant oat_file_assistant(dex_location.c_str(), kRuntimeISA, false, true);
Richard Uhler66d874d2015-01-15 09:37:19 -0800522
Andreas Gampe29d38e72016-03-23 15:31:51 +0000523 EXPECT_EQ(OatFileAssistant::kPatchOatNeeded,
524 oat_file_assistant.GetDexOptNeeded(CompilerFilter::kSpeed));
Richard Uhler66d874d2015-01-15 09:37:19 -0800525
526 EXPECT_FALSE(oat_file_assistant.IsInBootClassPath());
527 EXPECT_TRUE(oat_file_assistant.OdexFileExists());
528 EXPECT_FALSE(oat_file_assistant.OdexFileIsOutOfDate());
529 EXPECT_FALSE(oat_file_assistant.OdexFileIsUpToDate());
530 EXPECT_FALSE(oat_file_assistant.OatFileExists());
531 EXPECT_TRUE(oat_file_assistant.OatFileIsOutOfDate());
532 EXPECT_FALSE(oat_file_assistant.OatFileIsUpToDate());
Richard Uhler9b994ea2015-06-24 08:44:19 -0700533 EXPECT_FALSE(oat_file_assistant.HasOriginalDexFiles());
Richard Uhler66d874d2015-01-15 09:37:19 -0800534
535 // Make the oat file up to date.
536 std::string error_msg;
Richard Uhlerf4b34872016-04-13 11:03:46 -0700537 Runtime::Current()->AddCompilerOption("--compiler-filter=speed");
Richard Uhler1e860612016-03-30 12:17:55 -0700538 ASSERT_EQ(OatFileAssistant::kUpdateSucceeded,
Richard Uhlerf4b34872016-04-13 11:03:46 -0700539 oat_file_assistant.MakeUpToDate(&error_msg)) << error_msg;
Richard Uhler66d874d2015-01-15 09:37:19 -0800540
Andreas Gampe29d38e72016-03-23 15:31:51 +0000541 EXPECT_EQ(OatFileAssistant::kNoDexOptNeeded,
542 oat_file_assistant.GetDexOptNeeded(CompilerFilter::kSpeed));
Richard Uhler66d874d2015-01-15 09:37:19 -0800543
544 EXPECT_FALSE(oat_file_assistant.IsInBootClassPath());
545 EXPECT_TRUE(oat_file_assistant.OdexFileExists());
546 EXPECT_FALSE(oat_file_assistant.OdexFileIsOutOfDate());
547 EXPECT_FALSE(oat_file_assistant.OdexFileIsUpToDate());
548 EXPECT_TRUE(oat_file_assistant.OatFileExists());
549 EXPECT_FALSE(oat_file_assistant.OatFileIsOutOfDate());
550 EXPECT_TRUE(oat_file_assistant.OatFileIsUpToDate());
Richard Uhler9b994ea2015-06-24 08:44:19 -0700551 EXPECT_FALSE(oat_file_assistant.HasOriginalDexFiles());
Richard Uhler66d874d2015-01-15 09:37:19 -0800552
553 // Verify we can load the dex files from it.
554 std::unique_ptr<OatFile> oat_file = oat_file_assistant.GetBestOatFile();
555 ASSERT_TRUE(oat_file.get() != nullptr);
556 EXPECT_TRUE(oat_file->IsExecutable());
557 std::vector<std::unique_ptr<const DexFile>> dex_files;
558 dex_files = oat_file_assistant.LoadDexFiles(*oat_file, dex_location.c_str());
559 EXPECT_EQ(1u, dex_files.size());
560}
561
Richard Uhler95abd042015-03-24 09:51:28 -0700562// Case: We have a stripped DEX file, an ODEX file, and an out-of-date OAT file.
563// Expect: The status is kPatchOatNeeded.
Richard Uhler66d874d2015-01-15 09:37:19 -0800564TEST_F(OatFileAssistantTest, StrippedDexOdexOat) {
565 std::string dex_location = GetScratchDir() + "/StrippedDexOdexOat.jar";
Richard Uhler63434112015-03-16 14:32:16 -0700566 std::string odex_location = GetOdexDir() + "/StrippedDexOdexOat.odex";
Richard Uhler66d874d2015-01-15 09:37:19 -0800567
568 // Create the oat file from a different dex file so it looks out of date.
569 Copy(GetDexSrc2(), dex_location);
Andreas Gampe29d38e72016-03-23 15:31:51 +0000570 GenerateOatForTest(dex_location.c_str(), CompilerFilter::kSpeed);
Richard Uhler66d874d2015-01-15 09:37:19 -0800571
572 // Create the odex file
573 Copy(GetDexSrc1(), dex_location);
Andreas Gampe29d38e72016-03-23 15:31:51 +0000574 GenerateOdexForTest(dex_location, odex_location, CompilerFilter::kSpeed);
Richard Uhler66d874d2015-01-15 09:37:19 -0800575
576 // Strip the dex file.
577 Copy(GetStrippedDexSrc1(), dex_location);
578
579 // Verify the status.
Andreas Gampe29d38e72016-03-23 15:31:51 +0000580 OatFileAssistant oat_file_assistant(dex_location.c_str(), kRuntimeISA, false, true);
Richard Uhler66d874d2015-01-15 09:37:19 -0800581
Andreas Gampe29d38e72016-03-23 15:31:51 +0000582 EXPECT_EQ(OatFileAssistant::kNoDexOptNeeded,
583 oat_file_assistant.GetDexOptNeeded(CompilerFilter::kVerifyAtRuntime));
584 EXPECT_EQ(OatFileAssistant::kPatchOatNeeded,
585 oat_file_assistant.GetDexOptNeeded(CompilerFilter::kSpeed));
586 EXPECT_EQ(OatFileAssistant::kNoDexOptNeeded, // Can't run dex2oat because dex file is stripped.
587 oat_file_assistant.GetDexOptNeeded(CompilerFilter::kEverything));
Richard Uhler66d874d2015-01-15 09:37:19 -0800588
589 EXPECT_FALSE(oat_file_assistant.IsInBootClassPath());
590 EXPECT_TRUE(oat_file_assistant.OdexFileExists());
591 EXPECT_FALSE(oat_file_assistant.OdexFileIsOutOfDate());
592 EXPECT_TRUE(oat_file_assistant.OdexFileNeedsRelocation());
593 EXPECT_FALSE(oat_file_assistant.OdexFileIsUpToDate());
594 EXPECT_TRUE(oat_file_assistant.OatFileExists());
595 EXPECT_TRUE(oat_file_assistant.OatFileIsOutOfDate());
596 EXPECT_FALSE(oat_file_assistant.OatFileIsUpToDate());
Richard Uhler9b994ea2015-06-24 08:44:19 -0700597 EXPECT_FALSE(oat_file_assistant.HasOriginalDexFiles());
Richard Uhler66d874d2015-01-15 09:37:19 -0800598
599 // Make the oat file up to date.
600 std::string error_msg;
Richard Uhlerf4b34872016-04-13 11:03:46 -0700601 Runtime::Current()->AddCompilerOption("--compiler-filter=speed");
Richard Uhler1e860612016-03-30 12:17:55 -0700602 ASSERT_EQ(OatFileAssistant::kUpdateSucceeded,
Richard Uhlerf4b34872016-04-13 11:03:46 -0700603 oat_file_assistant.MakeUpToDate(&error_msg)) << error_msg;
Richard Uhler66d874d2015-01-15 09:37:19 -0800604
Andreas Gampe29d38e72016-03-23 15:31:51 +0000605 EXPECT_EQ(OatFileAssistant::kNoDexOptNeeded,
606 oat_file_assistant.GetDexOptNeeded(CompilerFilter::kSpeed));
607 EXPECT_EQ(OatFileAssistant::kNoDexOptNeeded, // Can't run dex2oat because dex file is stripped.
608 oat_file_assistant.GetDexOptNeeded(CompilerFilter::kEverything));
Richard Uhler66d874d2015-01-15 09:37:19 -0800609
610 EXPECT_FALSE(oat_file_assistant.IsInBootClassPath());
611 EXPECT_TRUE(oat_file_assistant.OdexFileExists());
612 EXPECT_FALSE(oat_file_assistant.OdexFileIsOutOfDate());
613 EXPECT_TRUE(oat_file_assistant.OdexFileNeedsRelocation());
614 EXPECT_FALSE(oat_file_assistant.OdexFileIsUpToDate());
615 EXPECT_TRUE(oat_file_assistant.OatFileExists());
616 EXPECT_FALSE(oat_file_assistant.OatFileIsOutOfDate());
617 EXPECT_FALSE(oat_file_assistant.OatFileNeedsRelocation());
618 EXPECT_TRUE(oat_file_assistant.OatFileIsUpToDate());
Richard Uhler9b994ea2015-06-24 08:44:19 -0700619 EXPECT_FALSE(oat_file_assistant.HasOriginalDexFiles());
Richard Uhler66d874d2015-01-15 09:37:19 -0800620
621 // Verify we can load the dex files from it.
622 std::unique_ptr<OatFile> oat_file = oat_file_assistant.GetBestOatFile();
623 ASSERT_TRUE(oat_file.get() != nullptr);
624 EXPECT_TRUE(oat_file->IsExecutable());
625 std::vector<std::unique_ptr<const DexFile>> dex_files;
626 dex_files = oat_file_assistant.LoadDexFiles(*oat_file, dex_location.c_str());
627 EXPECT_EQ(1u, dex_files.size());
628}
629
Richard Uhler9b994ea2015-06-24 08:44:19 -0700630// Case: We have a stripped (or resource-only) DEX file, no ODEX file and no
631// OAT file. Expect: The status is kNoDexOptNeeded.
632TEST_F(OatFileAssistantTest, ResourceOnlyDex) {
633 std::string dex_location = GetScratchDir() + "/ResourceOnlyDex.jar";
634
635 Copy(GetStrippedDexSrc1(), dex_location);
636
637 // Verify the status.
Andreas Gampe29d38e72016-03-23 15:31:51 +0000638 OatFileAssistant oat_file_assistant(dex_location.c_str(), kRuntimeISA, false, true);
Richard Uhler9b994ea2015-06-24 08:44:19 -0700639
Andreas Gampe29d38e72016-03-23 15:31:51 +0000640 EXPECT_EQ(OatFileAssistant::kNoDexOptNeeded,
641 oat_file_assistant.GetDexOptNeeded(CompilerFilter::kSpeed));
642 EXPECT_EQ(OatFileAssistant::kNoDexOptNeeded,
643 oat_file_assistant.GetDexOptNeeded(CompilerFilter::kVerifyAtRuntime));
644 EXPECT_EQ(OatFileAssistant::kNoDexOptNeeded,
645 oat_file_assistant.GetDexOptNeeded(CompilerFilter::kInterpretOnly));
Richard Uhler9b994ea2015-06-24 08:44:19 -0700646
647 EXPECT_FALSE(oat_file_assistant.IsInBootClassPath());
648 EXPECT_FALSE(oat_file_assistant.OdexFileExists());
649 EXPECT_TRUE(oat_file_assistant.OdexFileIsOutOfDate());
650 EXPECT_FALSE(oat_file_assistant.OdexFileNeedsRelocation());
651 EXPECT_FALSE(oat_file_assistant.OdexFileIsUpToDate());
652 EXPECT_FALSE(oat_file_assistant.OatFileExists());
653 EXPECT_TRUE(oat_file_assistant.OatFileIsOutOfDate());
654 EXPECT_FALSE(oat_file_assistant.OatFileIsUpToDate());
655 EXPECT_FALSE(oat_file_assistant.HasOriginalDexFiles());
656
657 // Make the oat file up to date. This should have no effect.
658 std::string error_msg;
Richard Uhlerf4b34872016-04-13 11:03:46 -0700659 Runtime::Current()->AddCompilerOption("--compiler-filter=speed");
Richard Uhler1e860612016-03-30 12:17:55 -0700660 EXPECT_EQ(OatFileAssistant::kUpdateSucceeded,
Richard Uhlerf4b34872016-04-13 11:03:46 -0700661 oat_file_assistant.MakeUpToDate(&error_msg)) << error_msg;
Richard Uhler9b994ea2015-06-24 08:44:19 -0700662
Andreas Gampe29d38e72016-03-23 15:31:51 +0000663 EXPECT_EQ(OatFileAssistant::kNoDexOptNeeded,
664 oat_file_assistant.GetDexOptNeeded(CompilerFilter::kSpeed));
Richard Uhler9b994ea2015-06-24 08:44:19 -0700665
666 EXPECT_FALSE(oat_file_assistant.IsInBootClassPath());
667 EXPECT_FALSE(oat_file_assistant.OdexFileExists());
668 EXPECT_TRUE(oat_file_assistant.OdexFileIsOutOfDate());
669 EXPECT_FALSE(oat_file_assistant.OdexFileNeedsRelocation());
670 EXPECT_FALSE(oat_file_assistant.OdexFileIsUpToDate());
671 EXPECT_FALSE(oat_file_assistant.OatFileExists());
672 EXPECT_TRUE(oat_file_assistant.OatFileIsOutOfDate());
673 EXPECT_FALSE(oat_file_assistant.OatFileIsUpToDate());
674 EXPECT_FALSE(oat_file_assistant.HasOriginalDexFiles());
675}
676
Richard Uhler95abd042015-03-24 09:51:28 -0700677// Case: We have a DEX file, no ODEX file and an OAT file that needs
678// relocation.
679// Expect: The status is kSelfPatchOatNeeded.
680TEST_F(OatFileAssistantTest, SelfRelocation) {
681 std::string dex_location = GetScratchDir() + "/SelfRelocation.jar";
682 std::string oat_location = GetOdexDir() + "/SelfRelocation.oat";
683
684 // Create the dex and odex files
685 Copy(GetDexSrc1(), dex_location);
Andreas Gampe29d38e72016-03-23 15:31:51 +0000686 GenerateOdexForTest(dex_location, oat_location, CompilerFilter::kSpeed);
Richard Uhler95abd042015-03-24 09:51:28 -0700687
688 OatFileAssistant oat_file_assistant(dex_location.c_str(),
Andreas Gampe29d38e72016-03-23 15:31:51 +0000689 oat_location.c_str(), kRuntimeISA, false, true);
Richard Uhler95abd042015-03-24 09:51:28 -0700690
Andreas Gampe29d38e72016-03-23 15:31:51 +0000691 EXPECT_EQ(OatFileAssistant::kNoDexOptNeeded,
692 oat_file_assistant.GetDexOptNeeded(CompilerFilter::kInterpretOnly));
693 EXPECT_EQ(OatFileAssistant::kSelfPatchOatNeeded,
694 oat_file_assistant.GetDexOptNeeded(CompilerFilter::kSpeed));
695 EXPECT_EQ(OatFileAssistant::kDex2OatNeeded,
696 oat_file_assistant.GetDexOptNeeded(CompilerFilter::kEverything));
Richard Uhler95abd042015-03-24 09:51:28 -0700697
698 EXPECT_FALSE(oat_file_assistant.IsInBootClassPath());
699 EXPECT_FALSE(oat_file_assistant.OdexFileExists());
700 EXPECT_TRUE(oat_file_assistant.OdexFileIsOutOfDate());
701 EXPECT_FALSE(oat_file_assistant.OdexFileNeedsRelocation());
702 EXPECT_FALSE(oat_file_assistant.OdexFileIsUpToDate());
703 EXPECT_TRUE(oat_file_assistant.OatFileExists());
704 EXPECT_TRUE(oat_file_assistant.OatFileNeedsRelocation());
705 EXPECT_FALSE(oat_file_assistant.OatFileIsOutOfDate());
706 EXPECT_FALSE(oat_file_assistant.OatFileIsUpToDate());
Richard Uhler9b994ea2015-06-24 08:44:19 -0700707 EXPECT_TRUE(oat_file_assistant.HasOriginalDexFiles());
Richard Uhler95abd042015-03-24 09:51:28 -0700708
709 // Make the oat file up to date.
710 std::string error_msg;
Richard Uhlerf4b34872016-04-13 11:03:46 -0700711 Runtime::Current()->AddCompilerOption("--compiler-filter=speed");
Richard Uhler1e860612016-03-30 12:17:55 -0700712 ASSERT_EQ(OatFileAssistant::kUpdateSucceeded,
Richard Uhlerf4b34872016-04-13 11:03:46 -0700713 oat_file_assistant.MakeUpToDate(&error_msg)) << error_msg;
Richard Uhler95abd042015-03-24 09:51:28 -0700714
Andreas Gampe29d38e72016-03-23 15:31:51 +0000715 EXPECT_EQ(OatFileAssistant::kNoDexOptNeeded,
716 oat_file_assistant.GetDexOptNeeded(CompilerFilter::kSpeed));
Richard Uhler95abd042015-03-24 09:51:28 -0700717
718 EXPECT_FALSE(oat_file_assistant.IsInBootClassPath());
719 EXPECT_FALSE(oat_file_assistant.OdexFileExists());
720 EXPECT_TRUE(oat_file_assistant.OdexFileIsOutOfDate());
721 EXPECT_FALSE(oat_file_assistant.OdexFileNeedsRelocation());
722 EXPECT_FALSE(oat_file_assistant.OdexFileIsUpToDate());
723 EXPECT_TRUE(oat_file_assistant.OatFileExists());
724 EXPECT_FALSE(oat_file_assistant.OatFileIsOutOfDate());
725 EXPECT_FALSE(oat_file_assistant.OatFileNeedsRelocation());
726 EXPECT_TRUE(oat_file_assistant.OatFileIsUpToDate());
Richard Uhler9b994ea2015-06-24 08:44:19 -0700727 EXPECT_TRUE(oat_file_assistant.HasOriginalDexFiles());
Richard Uhler95abd042015-03-24 09:51:28 -0700728
729 std::unique_ptr<OatFile> oat_file = oat_file_assistant.GetBestOatFile();
730 ASSERT_TRUE(oat_file.get() != nullptr);
731 EXPECT_TRUE(oat_file->IsExecutable());
732 std::vector<std::unique_ptr<const DexFile>> dex_files;
733 dex_files = oat_file_assistant.LoadDexFiles(*oat_file, dex_location.c_str());
734 EXPECT_EQ(1u, dex_files.size());
735}
736
Richard Uhlerd1537b52016-03-29 13:27:41 -0700737// Case: We have a DEX file, no ODEX file and an OAT file that needs
738// relocation but doesn't have patch info.
739// Expect: The status is kDex2OatNeeded, because we can't run patchoat.
740TEST_F(OatFileAssistantTest, NoSelfRelocation) {
741 std::string dex_location = GetScratchDir() + "/NoSelfRelocation.jar";
742 std::string oat_location = GetOdexDir() + "/NoSelfRelocation.oat";
743
744 // Create the dex and odex files
745 Copy(GetDexSrc1(), dex_location);
746 GenerateNoPatchOdexForTest(dex_location, oat_location, CompilerFilter::kSpeed);
747
748 OatFileAssistant oat_file_assistant(dex_location.c_str(),
749 oat_location.c_str(), kRuntimeISA, false, true);
750
751 EXPECT_EQ(OatFileAssistant::kDex2OatNeeded,
752 oat_file_assistant.GetDexOptNeeded(CompilerFilter::kSpeed));
753
754 // Make the oat file up to date.
755 std::string error_msg;
Richard Uhlerf4b34872016-04-13 11:03:46 -0700756 Runtime::Current()->AddCompilerOption("--compiler-filter=speed");
Richard Uhler1e860612016-03-30 12:17:55 -0700757 ASSERT_EQ(OatFileAssistant::kUpdateSucceeded,
Richard Uhlerf4b34872016-04-13 11:03:46 -0700758 oat_file_assistant.MakeUpToDate(&error_msg)) << error_msg;
Richard Uhlerd1537b52016-03-29 13:27:41 -0700759 EXPECT_EQ(OatFileAssistant::kNoDexOptNeeded,
760 oat_file_assistant.GetDexOptNeeded(CompilerFilter::kSpeed));
761
762 std::unique_ptr<OatFile> oat_file = oat_file_assistant.GetBestOatFile();
763 ASSERT_TRUE(oat_file.get() != nullptr);
764 EXPECT_TRUE(oat_file->IsExecutable());
765 std::vector<std::unique_ptr<const DexFile>> dex_files;
766 dex_files = oat_file_assistant.LoadDexFiles(*oat_file, dex_location.c_str());
767 EXPECT_EQ(1u, dex_files.size());
768}
769
Richard Uhler66d874d2015-01-15 09:37:19 -0800770// Case: We have a DEX file, an ODEX file and an OAT file, where the ODEX and
771// OAT files both have patch delta of 0.
Richard Uhler95abd042015-03-24 09:51:28 -0700772// Expect: It shouldn't crash, and status is kPatchOatNeeded.
Richard Uhler66d874d2015-01-15 09:37:19 -0800773TEST_F(OatFileAssistantTest, OdexOatOverlap) {
774 std::string dex_location = GetScratchDir() + "/OdexOatOverlap.jar";
Richard Uhler63434112015-03-16 14:32:16 -0700775 std::string odex_location = GetOdexDir() + "/OdexOatOverlap.odex";
776 std::string oat_location = GetOdexDir() + "/OdexOatOverlap.oat";
Richard Uhler66d874d2015-01-15 09:37:19 -0800777
778 // Create the dex and odex files
779 Copy(GetDexSrc1(), dex_location);
Andreas Gampe29d38e72016-03-23 15:31:51 +0000780 GenerateOdexForTest(dex_location, odex_location, CompilerFilter::kSpeed);
Richard Uhler66d874d2015-01-15 09:37:19 -0800781
782 // Create the oat file by copying the odex so they are located in the same
783 // place in memory.
784 Copy(odex_location, oat_location);
785
786 // Verify things don't go bad.
787 OatFileAssistant oat_file_assistant(dex_location.c_str(),
Andreas Gampe29d38e72016-03-23 15:31:51 +0000788 oat_location.c_str(), kRuntimeISA, false, true);
Richard Uhler66d874d2015-01-15 09:37:19 -0800789
Andreas Gampe29d38e72016-03-23 15:31:51 +0000790 EXPECT_EQ(OatFileAssistant::kPatchOatNeeded,
791 oat_file_assistant.GetDexOptNeeded(CompilerFilter::kSpeed));
Richard Uhler66d874d2015-01-15 09:37:19 -0800792
793 EXPECT_FALSE(oat_file_assistant.IsInBootClassPath());
794 EXPECT_TRUE(oat_file_assistant.OdexFileExists());
795 EXPECT_FALSE(oat_file_assistant.OdexFileIsOutOfDate());
796 EXPECT_FALSE(oat_file_assistant.OdexFileIsUpToDate());
797 EXPECT_TRUE(oat_file_assistant.OatFileExists());
798 EXPECT_FALSE(oat_file_assistant.OatFileIsOutOfDate());
799 EXPECT_FALSE(oat_file_assistant.OatFileIsUpToDate());
Richard Uhler9b994ea2015-06-24 08:44:19 -0700800 EXPECT_TRUE(oat_file_assistant.HasOriginalDexFiles());
Richard Uhler66d874d2015-01-15 09:37:19 -0800801
802 // Things aren't relocated, so it should fall back to interpreted.
803 std::unique_ptr<OatFile> oat_file = oat_file_assistant.GetBestOatFile();
804 ASSERT_TRUE(oat_file.get() != nullptr);
Richard Uhlerf16d5722015-05-11 09:32:47 -0700805
Richard Uhler66d874d2015-01-15 09:37:19 -0800806 EXPECT_FALSE(oat_file->IsExecutable());
807 std::vector<std::unique_ptr<const DexFile>> dex_files;
808 dex_files = oat_file_assistant.LoadDexFiles(*oat_file, dex_location.c_str());
809 EXPECT_EQ(1u, dex_files.size());
810}
811
812// Case: We have a DEX file and a PIC ODEX file, but no OAT file.
Richard Uhler95abd042015-03-24 09:51:28 -0700813// Expect: The status is kNoDexOptNeeded, because PIC needs no relocation.
Richard Uhler66d874d2015-01-15 09:37:19 -0800814TEST_F(OatFileAssistantTest, DexPicOdexNoOat) {
815 std::string dex_location = GetScratchDir() + "/DexPicOdexNoOat.jar";
Richard Uhler63434112015-03-16 14:32:16 -0700816 std::string odex_location = GetOdexDir() + "/DexPicOdexNoOat.odex";
Richard Uhler66d874d2015-01-15 09:37:19 -0800817
818 // Create the dex and odex files
819 Copy(GetDexSrc1(), dex_location);
Andreas Gampe29d38e72016-03-23 15:31:51 +0000820 GeneratePicOdexForTest(dex_location, odex_location, CompilerFilter::kSpeed);
Richard Uhler66d874d2015-01-15 09:37:19 -0800821
822 // Verify the status.
Andreas Gampe29d38e72016-03-23 15:31:51 +0000823 OatFileAssistant oat_file_assistant(dex_location.c_str(), kRuntimeISA, false, false);
Richard Uhler66d874d2015-01-15 09:37:19 -0800824
Andreas Gampe29d38e72016-03-23 15:31:51 +0000825 EXPECT_EQ(OatFileAssistant::kNoDexOptNeeded,
826 oat_file_assistant.GetDexOptNeeded(CompilerFilter::kSpeed));
827 EXPECT_EQ(OatFileAssistant::kDex2OatNeeded,
828 oat_file_assistant.GetDexOptNeeded(CompilerFilter::kEverything));
Richard Uhler66d874d2015-01-15 09:37:19 -0800829
830 EXPECT_FALSE(oat_file_assistant.IsInBootClassPath());
831 EXPECT_TRUE(oat_file_assistant.OdexFileExists());
832 EXPECT_FALSE(oat_file_assistant.OdexFileIsOutOfDate());
833 EXPECT_TRUE(oat_file_assistant.OdexFileIsUpToDate());
834 EXPECT_FALSE(oat_file_assistant.OatFileExists());
835 EXPECT_TRUE(oat_file_assistant.OatFileIsOutOfDate());
836 EXPECT_FALSE(oat_file_assistant.OatFileIsUpToDate());
Richard Uhler9b994ea2015-06-24 08:44:19 -0700837 EXPECT_TRUE(oat_file_assistant.HasOriginalDexFiles());
Richard Uhler66d874d2015-01-15 09:37:19 -0800838}
839
Andreas Gampe29d38e72016-03-23 15:31:51 +0000840// Case: We have a DEX file and a VerifyAtRuntime ODEX file, but no OAT file.
841// Expect: The status is kNoDexOptNeeded, because VerifyAtRuntime contains no code.
842TEST_F(OatFileAssistantTest, DexVerifyAtRuntimeOdexNoOat) {
843 std::string dex_location = GetScratchDir() + "/DexVerifyAtRuntimeOdexNoOat.jar";
844 std::string odex_location = GetOdexDir() + "/DexVerifyAtRuntimeOdexNoOat.odex";
David Brazdilce4b0ba2016-01-28 15:05:49 +0000845
846 // Create the dex and odex files
847 Copy(GetDexSrc1(), dex_location);
Andreas Gampe29d38e72016-03-23 15:31:51 +0000848 GenerateOdexForTest(dex_location, odex_location, CompilerFilter::kVerifyAtRuntime);
David Brazdilce4b0ba2016-01-28 15:05:49 +0000849
850 // Verify the status.
Andreas Gampe29d38e72016-03-23 15:31:51 +0000851 OatFileAssistant oat_file_assistant(dex_location.c_str(), kRuntimeISA, false, false);
David Brazdilce4b0ba2016-01-28 15:05:49 +0000852
Andreas Gampe29d38e72016-03-23 15:31:51 +0000853 EXPECT_EQ(OatFileAssistant::kNoDexOptNeeded,
854 oat_file_assistant.GetDexOptNeeded(CompilerFilter::kVerifyAtRuntime));
855 EXPECT_EQ(OatFileAssistant::kDex2OatNeeded,
856 oat_file_assistant.GetDexOptNeeded(CompilerFilter::kSpeed));
David Brazdilce4b0ba2016-01-28 15:05:49 +0000857
858 EXPECT_FALSE(oat_file_assistant.IsInBootClassPath());
859 EXPECT_TRUE(oat_file_assistant.OdexFileExists());
860 EXPECT_FALSE(oat_file_assistant.OdexFileIsOutOfDate());
Nicolas Geoffray845e5062016-03-23 06:42:05 +0000861 EXPECT_TRUE(oat_file_assistant.OdexFileIsUpToDate());
David Brazdilce4b0ba2016-01-28 15:05:49 +0000862 EXPECT_FALSE(oat_file_assistant.OatFileExists());
863 EXPECT_TRUE(oat_file_assistant.OatFileIsOutOfDate());
864 EXPECT_FALSE(oat_file_assistant.OatFileIsUpToDate());
865 EXPECT_TRUE(oat_file_assistant.HasOriginalDexFiles());
866}
867
Richard Uhler66d874d2015-01-15 09:37:19 -0800868// Case: We have a DEX file and up-to-date OAT file for it.
869// Expect: We should load an executable dex file.
870TEST_F(OatFileAssistantTest, LoadOatUpToDate) {
871 std::string dex_location = GetScratchDir() + "/LoadOatUpToDate.jar";
872
873 Copy(GetDexSrc1(), dex_location);
Andreas Gampe29d38e72016-03-23 15:31:51 +0000874 GenerateOatForTest(dex_location.c_str(), CompilerFilter::kSpeed);
Richard Uhler66d874d2015-01-15 09:37:19 -0800875
876 // Load the oat using an oat file assistant.
Andreas Gampe29d38e72016-03-23 15:31:51 +0000877 OatFileAssistant oat_file_assistant(dex_location.c_str(), kRuntimeISA, false, true);
878
879 std::unique_ptr<OatFile> oat_file = oat_file_assistant.GetBestOatFile();
880 ASSERT_TRUE(oat_file.get() != nullptr);
881 EXPECT_TRUE(oat_file->IsExecutable());
882 std::vector<std::unique_ptr<const DexFile>> dex_files;
883 dex_files = oat_file_assistant.LoadDexFiles(*oat_file, dex_location.c_str());
884 EXPECT_EQ(1u, dex_files.size());
885}
886
887// Case: We have a DEX file and up-to-date interpret-only OAT file for it.
888// Expect: We should still load the oat file as executable.
889TEST_F(OatFileAssistantTest, LoadExecInterpretOnlyOatUpToDate) {
890 std::string dex_location = GetScratchDir() + "/LoadExecInterpretOnlyOatUpToDate.jar";
891
892 Copy(GetDexSrc1(), dex_location);
893 GenerateOatForTest(dex_location.c_str(), CompilerFilter::kInterpretOnly);
894
895 // Load the oat using an oat file assistant.
896 OatFileAssistant oat_file_assistant(dex_location.c_str(), kRuntimeISA, false, true);
Richard Uhler66d874d2015-01-15 09:37:19 -0800897
898 std::unique_ptr<OatFile> oat_file = oat_file_assistant.GetBestOatFile();
899 ASSERT_TRUE(oat_file.get() != nullptr);
900 EXPECT_TRUE(oat_file->IsExecutable());
901 std::vector<std::unique_ptr<const DexFile>> dex_files;
902 dex_files = oat_file_assistant.LoadDexFiles(*oat_file, dex_location.c_str());
903 EXPECT_EQ(1u, dex_files.size());
904}
905
906// Case: We have a DEX file and up-to-date OAT file for it.
907// Expect: Loading non-executable should load the oat non-executable.
908TEST_F(OatFileAssistantTest, LoadNoExecOatUpToDate) {
909 std::string dex_location = GetScratchDir() + "/LoadNoExecOatUpToDate.jar";
910
911 Copy(GetDexSrc1(), dex_location);
Andreas Gampe29d38e72016-03-23 15:31:51 +0000912 GenerateOatForTest(dex_location.c_str(), CompilerFilter::kSpeed);
Richard Uhler66d874d2015-01-15 09:37:19 -0800913
914 // Load the oat using an oat file assistant.
Andreas Gampe29d38e72016-03-23 15:31:51 +0000915 OatFileAssistant oat_file_assistant(dex_location.c_str(), kRuntimeISA, false, false);
Richard Uhler66d874d2015-01-15 09:37:19 -0800916
917 std::unique_ptr<OatFile> oat_file = oat_file_assistant.GetBestOatFile();
918 ASSERT_TRUE(oat_file.get() != nullptr);
919 EXPECT_FALSE(oat_file->IsExecutable());
920 std::vector<std::unique_ptr<const DexFile>> dex_files;
921 dex_files = oat_file_assistant.LoadDexFiles(*oat_file, dex_location.c_str());
922 EXPECT_EQ(1u, dex_files.size());
923}
924
925// Case: We have a DEX file.
926// Expect: We should load an executable dex file from an alternative oat
927// location.
928TEST_F(OatFileAssistantTest, LoadDexNoAlternateOat) {
929 std::string dex_location = GetScratchDir() + "/LoadDexNoAlternateOat.jar";
930 std::string oat_location = GetScratchDir() + "/LoadDexNoAlternateOat.oat";
931
932 Copy(GetDexSrc1(), dex_location);
933
934 OatFileAssistant oat_file_assistant(
Andreas Gampe29d38e72016-03-23 15:31:51 +0000935 dex_location.c_str(), oat_location.c_str(), kRuntimeISA, false, true);
Richard Uhler66d874d2015-01-15 09:37:19 -0800936 std::string error_msg;
Richard Uhlerf4b34872016-04-13 11:03:46 -0700937 Runtime::Current()->AddCompilerOption("--compiler-filter=speed");
Richard Uhler1e860612016-03-30 12:17:55 -0700938 ASSERT_EQ(OatFileAssistant::kUpdateSucceeded,
Richard Uhlerf4b34872016-04-13 11:03:46 -0700939 oat_file_assistant.MakeUpToDate(&error_msg)) << error_msg;
Richard Uhler66d874d2015-01-15 09:37:19 -0800940
941 std::unique_ptr<OatFile> oat_file = oat_file_assistant.GetBestOatFile();
942 ASSERT_TRUE(oat_file.get() != nullptr);
943 EXPECT_TRUE(oat_file->IsExecutable());
944 std::vector<std::unique_ptr<const DexFile>> dex_files;
945 dex_files = oat_file_assistant.LoadDexFiles(*oat_file, dex_location.c_str());
946 EXPECT_EQ(1u, dex_files.size());
947
948 EXPECT_TRUE(OS::FileExists(oat_location.c_str()));
949
950 // Verify it didn't create an oat in the default location.
Andreas Gampe29d38e72016-03-23 15:31:51 +0000951 OatFileAssistant ofm(dex_location.c_str(), kRuntimeISA, false, false);
Richard Uhler66d874d2015-01-15 09:37:19 -0800952 EXPECT_FALSE(ofm.OatFileExists());
953}
954
Richard Uhler8327cf72015-10-13 16:34:59 -0700955// Case: We have a DEX file but can't write the oat file.
956// Expect: We should fail to make the oat file up to date.
957TEST_F(OatFileAssistantTest, LoadDexUnwriteableAlternateOat) {
958 std::string dex_location = GetScratchDir() + "/LoadDexUnwriteableAlternateOat.jar";
959
960 // Make the oat location unwritable by inserting some non-existent
961 // intermediate directories.
962 std::string oat_location = GetScratchDir() + "/foo/bar/LoadDexUnwriteableAlternateOat.oat";
963
964 Copy(GetDexSrc1(), dex_location);
965
966 OatFileAssistant oat_file_assistant(
Andreas Gampe29d38e72016-03-23 15:31:51 +0000967 dex_location.c_str(), oat_location.c_str(), kRuntimeISA, false, true);
Richard Uhler8327cf72015-10-13 16:34:59 -0700968 std::string error_msg;
Richard Uhlerf4b34872016-04-13 11:03:46 -0700969 Runtime::Current()->AddCompilerOption("--compiler-filter=speed");
Richard Uhler1e860612016-03-30 12:17:55 -0700970 ASSERT_EQ(OatFileAssistant::kUpdateNotAttempted,
Richard Uhlerf4b34872016-04-13 11:03:46 -0700971 oat_file_assistant.MakeUpToDate(&error_msg));
Richard Uhler8327cf72015-10-13 16:34:59 -0700972
973 std::unique_ptr<OatFile> oat_file = oat_file_assistant.GetBestOatFile();
974 ASSERT_TRUE(oat_file.get() == nullptr);
975}
976
977// Case: We don't have a DEX file and can't write the oat file.
978// Expect: We should fail to generate the oat file without crashing.
979TEST_F(OatFileAssistantTest, GenNoDex) {
980 std::string dex_location = GetScratchDir() + "/GenNoDex.jar";
981 std::string oat_location = GetScratchDir() + "/GenNoDex.oat";
982
983 OatFileAssistant oat_file_assistant(
Andreas Gampe29d38e72016-03-23 15:31:51 +0000984 dex_location.c_str(), oat_location.c_str(), kRuntimeISA, false, true);
Richard Uhler8327cf72015-10-13 16:34:59 -0700985 std::string error_msg;
Richard Uhlerf4b34872016-04-13 11:03:46 -0700986 Runtime::Current()->AddCompilerOption("--compiler-filter=speed");
Richard Uhler1e860612016-03-30 12:17:55 -0700987 EXPECT_EQ(OatFileAssistant::kUpdateNotAttempted,
Richard Uhlerf4b34872016-04-13 11:03:46 -0700988 oat_file_assistant.GenerateOatFile(&error_msg));
Richard Uhler8327cf72015-10-13 16:34:59 -0700989}
990
Richard Uhler66d874d2015-01-15 09:37:19 -0800991// Turn an absolute path into a path relative to the current working
992// directory.
993static std::string MakePathRelative(std::string target) {
994 char buf[MAXPATHLEN];
995 std::string cwd = getcwd(buf, MAXPATHLEN);
996
997 // Split the target and cwd paths into components.
998 std::vector<std::string> target_path;
999 std::vector<std::string> cwd_path;
1000 Split(target, '/', &target_path);
1001 Split(cwd, '/', &cwd_path);
1002
1003 // Reverse the path components, so we can use pop_back().
1004 std::reverse(target_path.begin(), target_path.end());
1005 std::reverse(cwd_path.begin(), cwd_path.end());
1006
1007 // Drop the common prefix of the paths. Because we reversed the path
1008 // components, this becomes the common suffix of target_path and cwd_path.
1009 while (!target_path.empty() && !cwd_path.empty()
1010 && target_path.back() == cwd_path.back()) {
1011 target_path.pop_back();
1012 cwd_path.pop_back();
1013 }
1014
1015 // For each element of the remaining cwd_path, add '..' to the beginning
1016 // of the target path. Because we reversed the path components, we add to
1017 // the end of target_path.
1018 for (unsigned int i = 0; i < cwd_path.size(); i++) {
1019 target_path.push_back("..");
1020 }
1021
1022 // Reverse again to get the right path order, and join to get the result.
1023 std::reverse(target_path.begin(), target_path.end());
1024 return Join(target_path, '/');
1025}
1026
1027// Case: Non-absolute path to Dex location.
1028// Expect: Not sure, but it shouldn't crash.
1029TEST_F(OatFileAssistantTest, NonAbsoluteDexLocation) {
1030 std::string abs_dex_location = GetScratchDir() + "/NonAbsoluteDexLocation.jar";
1031 Copy(GetDexSrc1(), abs_dex_location);
1032
1033 std::string dex_location = MakePathRelative(abs_dex_location);
Andreas Gampe29d38e72016-03-23 15:31:51 +00001034 OatFileAssistant oat_file_assistant(dex_location.c_str(), kRuntimeISA, false, true);
Richard Uhler66d874d2015-01-15 09:37:19 -08001035
1036 EXPECT_FALSE(oat_file_assistant.IsInBootClassPath());
Andreas Gampe29d38e72016-03-23 15:31:51 +00001037 EXPECT_EQ(OatFileAssistant::kDex2OatNeeded,
1038 oat_file_assistant.GetDexOptNeeded(CompilerFilter::kSpeed));
Richard Uhler66d874d2015-01-15 09:37:19 -08001039 EXPECT_FALSE(oat_file_assistant.OdexFileExists());
1040 EXPECT_FALSE(oat_file_assistant.OatFileExists());
1041 EXPECT_TRUE(oat_file_assistant.OdexFileIsOutOfDate());
1042 EXPECT_FALSE(oat_file_assistant.OdexFileIsUpToDate());
1043 EXPECT_TRUE(oat_file_assistant.OatFileIsOutOfDate());
1044 EXPECT_FALSE(oat_file_assistant.OatFileIsUpToDate());
1045}
1046
1047// Case: Very short, non-existent Dex location.
Richard Uhler9b994ea2015-06-24 08:44:19 -07001048// Expect: kNoDexOptNeeded.
Richard Uhler66d874d2015-01-15 09:37:19 -08001049TEST_F(OatFileAssistantTest, ShortDexLocation) {
1050 std::string dex_location = "/xx";
1051
Andreas Gampe29d38e72016-03-23 15:31:51 +00001052 OatFileAssistant oat_file_assistant(dex_location.c_str(), kRuntimeISA, false, true);
Richard Uhler66d874d2015-01-15 09:37:19 -08001053
1054 EXPECT_FALSE(oat_file_assistant.IsInBootClassPath());
Andreas Gampe29d38e72016-03-23 15:31:51 +00001055 EXPECT_EQ(OatFileAssistant::kNoDexOptNeeded,
1056 oat_file_assistant.GetDexOptNeeded(CompilerFilter::kSpeed));
Richard Uhler66d874d2015-01-15 09:37:19 -08001057 EXPECT_FALSE(oat_file_assistant.OdexFileExists());
1058 EXPECT_FALSE(oat_file_assistant.OatFileExists());
1059 EXPECT_TRUE(oat_file_assistant.OdexFileIsOutOfDate());
1060 EXPECT_FALSE(oat_file_assistant.OdexFileIsUpToDate());
1061 EXPECT_TRUE(oat_file_assistant.OatFileIsOutOfDate());
1062 EXPECT_FALSE(oat_file_assistant.OatFileIsUpToDate());
Richard Uhler9b994ea2015-06-24 08:44:19 -07001063 EXPECT_FALSE(oat_file_assistant.HasOriginalDexFiles());
Richard Uhler66d874d2015-01-15 09:37:19 -08001064
Richard Uhler9b994ea2015-06-24 08:44:19 -07001065 // Trying to make it up to date should have no effect.
Richard Uhler66d874d2015-01-15 09:37:19 -08001066 std::string error_msg;
Richard Uhlerf4b34872016-04-13 11:03:46 -07001067 Runtime::Current()->AddCompilerOption("--compiler-filter=speed");
Richard Uhler1e860612016-03-30 12:17:55 -07001068 EXPECT_EQ(OatFileAssistant::kUpdateSucceeded,
Richard Uhlerf4b34872016-04-13 11:03:46 -07001069 oat_file_assistant.MakeUpToDate(&error_msg));
Richard Uhler9b994ea2015-06-24 08:44:19 -07001070 EXPECT_TRUE(error_msg.empty());
Richard Uhler66d874d2015-01-15 09:37:19 -08001071}
1072
1073// Case: Non-standard extension for dex file.
Richard Uhler95abd042015-03-24 09:51:28 -07001074// Expect: The status is kDex2OatNeeded.
Richard Uhler66d874d2015-01-15 09:37:19 -08001075TEST_F(OatFileAssistantTest, LongDexExtension) {
1076 std::string dex_location = GetScratchDir() + "/LongDexExtension.jarx";
1077 Copy(GetDexSrc1(), dex_location);
1078
Andreas Gampe29d38e72016-03-23 15:31:51 +00001079 OatFileAssistant oat_file_assistant(dex_location.c_str(), kRuntimeISA, false, false);
Richard Uhler66d874d2015-01-15 09:37:19 -08001080
Andreas Gampe29d38e72016-03-23 15:31:51 +00001081 EXPECT_EQ(OatFileAssistant::kDex2OatNeeded,
1082 oat_file_assistant.GetDexOptNeeded(CompilerFilter::kSpeed));
Richard Uhler66d874d2015-01-15 09:37:19 -08001083
1084 EXPECT_FALSE(oat_file_assistant.IsInBootClassPath());
1085 EXPECT_FALSE(oat_file_assistant.OdexFileExists());
1086 EXPECT_TRUE(oat_file_assistant.OdexFileIsOutOfDate());
1087 EXPECT_FALSE(oat_file_assistant.OdexFileIsUpToDate());
1088 EXPECT_FALSE(oat_file_assistant.OatFileExists());
1089 EXPECT_TRUE(oat_file_assistant.OatFileIsOutOfDate());
1090 EXPECT_FALSE(oat_file_assistant.OatFileIsUpToDate());
1091}
1092
1093// A task to generate a dex location. Used by the RaceToGenerate test.
1094class RaceGenerateTask : public Task {
1095 public:
1096 explicit RaceGenerateTask(const std::string& dex_location, const std::string& oat_location)
Jeff Haof0192c82016-03-28 20:39:50 -07001097 : dex_location_(dex_location), oat_location_(oat_location), loaded_oat_file_(nullptr)
Richard Uhler66d874d2015-01-15 09:37:19 -08001098 {}
1099
Roland Levillain4b8f1ec2015-08-26 18:34:03 +01001100 void Run(Thread* self ATTRIBUTE_UNUSED) {
Richard Uhler66d874d2015-01-15 09:37:19 -08001101 // Load the dex files, and save a pointer to the loaded oat file, so that
1102 // we can verify only one oat file was loaded for the dex location.
Richard Uhler66d874d2015-01-15 09:37:19 -08001103 std::vector<std::unique_ptr<const DexFile>> dex_files;
1104 std::vector<std::string> error_msgs;
Mathieu Chartiere58991b2015-10-13 07:59:34 -07001105 const OatFile* oat_file = nullptr;
Mathieu Chartierf9c6fc62015-10-07 11:44:05 -07001106 dex_files = Runtime::Current()->GetOatFileManager().OpenDexFilesFromOat(
1107 dex_location_.c_str(),
1108 oat_location_.c_str(),
Mathieu Chartierfbc31082016-01-24 11:59:56 -08001109 /*class_loader*/nullptr,
1110 /*dex_elements*/nullptr,
Mathieu Chartiere58991b2015-10-13 07:59:34 -07001111 &oat_file,
Mathieu Chartierf9c6fc62015-10-07 11:44:05 -07001112 &error_msgs);
Richard Uhler66d874d2015-01-15 09:37:19 -08001113 CHECK(!dex_files.empty()) << Join(error_msgs, '\n');
Richard Uhler07b3c232015-03-31 15:57:54 -07001114 CHECK(dex_files[0]->GetOatDexFile() != nullptr) << dex_files[0]->GetLocation();
1115 loaded_oat_file_ = dex_files[0]->GetOatDexFile()->GetOatFile();
Mathieu Chartiere58991b2015-10-13 07:59:34 -07001116 CHECK_EQ(loaded_oat_file_, oat_file);
Richard Uhler66d874d2015-01-15 09:37:19 -08001117 }
1118
1119 const OatFile* GetLoadedOatFile() const {
1120 return loaded_oat_file_;
1121 }
1122
1123 private:
1124 std::string dex_location_;
1125 std::string oat_location_;
1126 const OatFile* loaded_oat_file_;
1127};
1128
1129// Test the case where multiple processes race to generate an oat file.
1130// This simulates multiple processes using multiple threads.
1131//
Mathieu Chartierf9c6fc62015-10-07 11:44:05 -07001132// We want unique Oat files to be loaded even when there is a race to load.
1133// TODO: The test case no longer tests locking the way it was intended since we now get multiple
1134// copies of the same Oat files mapped at different locations.
Richard Uhler66d874d2015-01-15 09:37:19 -08001135TEST_F(OatFileAssistantTest, RaceToGenerate) {
1136 std::string dex_location = GetScratchDir() + "/RaceToGenerate.jar";
Richard Uhler63434112015-03-16 14:32:16 -07001137 std::string oat_location = GetOdexDir() + "/RaceToGenerate.oat";
Richard Uhler66d874d2015-01-15 09:37:19 -08001138
1139 // We use the lib core dex file, because it's large, and hopefully should
1140 // take a while to generate.
Narayan Kamathd1ef4362015-11-12 11:49:06 +00001141 Copy(GetLibCoreDexFileNames()[0], dex_location);
Richard Uhler66d874d2015-01-15 09:37:19 -08001142
1143 const int kNumThreads = 32;
1144 Thread* self = Thread::Current();
1145 ThreadPool thread_pool("Oat file assistant test thread pool", kNumThreads);
1146 std::vector<std::unique_ptr<RaceGenerateTask>> tasks;
1147 for (int i = 0; i < kNumThreads; i++) {
1148 std::unique_ptr<RaceGenerateTask> task(new RaceGenerateTask(dex_location, oat_location));
1149 thread_pool.AddTask(self, task.get());
1150 tasks.push_back(std::move(task));
1151 }
1152 thread_pool.StartWorkers(self);
1153 thread_pool.Wait(self, true, false);
1154
Mathieu Chartierf9c6fc62015-10-07 11:44:05 -07001155 // Verify every task got a unique oat file.
1156 std::set<const OatFile*> oat_files;
Richard Uhler66d874d2015-01-15 09:37:19 -08001157 for (auto& task : tasks) {
Mathieu Chartierf9c6fc62015-10-07 11:44:05 -07001158 const OatFile* oat_file = task->GetLoadedOatFile();
1159 EXPECT_TRUE(oat_files.find(oat_file) == oat_files.end());
1160 oat_files.insert(oat_file);
Richard Uhler66d874d2015-01-15 09:37:19 -08001161 }
1162}
1163
1164// Case: We have a DEX file and an ODEX file, no OAT file, and dex2oat is
1165// disabled.
1166// Expect: We should load the odex file non-executable.
1167TEST_F(OatFileAssistantNoDex2OatTest, LoadDexOdexNoOat) {
1168 std::string dex_location = GetScratchDir() + "/LoadDexOdexNoOat.jar";
Richard Uhler63434112015-03-16 14:32:16 -07001169 std::string odex_location = GetOdexDir() + "/LoadDexOdexNoOat.odex";
Richard Uhler66d874d2015-01-15 09:37:19 -08001170
1171 // Create the dex and odex files
1172 Copy(GetDexSrc1(), dex_location);
Andreas Gampe29d38e72016-03-23 15:31:51 +00001173 GenerateOdexForTest(dex_location, odex_location, CompilerFilter::kSpeed);
Richard Uhler66d874d2015-01-15 09:37:19 -08001174
1175 // Load the oat using an executable oat file assistant.
Andreas Gampe29d38e72016-03-23 15:31:51 +00001176 OatFileAssistant oat_file_assistant(dex_location.c_str(), kRuntimeISA, false, true);
Richard Uhler66d874d2015-01-15 09:37:19 -08001177
1178 std::unique_ptr<OatFile> oat_file = oat_file_assistant.GetBestOatFile();
1179 ASSERT_TRUE(oat_file.get() != nullptr);
1180 EXPECT_FALSE(oat_file->IsExecutable());
1181 std::vector<std::unique_ptr<const DexFile>> dex_files;
1182 dex_files = oat_file_assistant.LoadDexFiles(*oat_file, dex_location.c_str());
1183 EXPECT_EQ(1u, dex_files.size());
1184}
1185
1186// Case: We have a MultiDEX file and an ODEX file, no OAT file, and dex2oat is
1187// disabled.
1188// Expect: We should load the odex file non-executable.
1189TEST_F(OatFileAssistantNoDex2OatTest, LoadMultiDexOdexNoOat) {
1190 std::string dex_location = GetScratchDir() + "/LoadMultiDexOdexNoOat.jar";
Richard Uhler63434112015-03-16 14:32:16 -07001191 std::string odex_location = GetOdexDir() + "/LoadMultiDexOdexNoOat.odex";
Richard Uhler66d874d2015-01-15 09:37:19 -08001192
1193 // Create the dex and odex files
1194 Copy(GetMultiDexSrc1(), dex_location);
Andreas Gampe29d38e72016-03-23 15:31:51 +00001195 GenerateOdexForTest(dex_location, odex_location, CompilerFilter::kSpeed);
Richard Uhler66d874d2015-01-15 09:37:19 -08001196
1197 // Load the oat using an executable oat file assistant.
Andreas Gampe29d38e72016-03-23 15:31:51 +00001198 OatFileAssistant oat_file_assistant(dex_location.c_str(), kRuntimeISA, false, true);
Richard Uhler66d874d2015-01-15 09:37:19 -08001199
1200 std::unique_ptr<OatFile> oat_file = oat_file_assistant.GetBestOatFile();
1201 ASSERT_TRUE(oat_file.get() != nullptr);
1202 EXPECT_FALSE(oat_file->IsExecutable());
1203 std::vector<std::unique_ptr<const DexFile>> dex_files;
1204 dex_files = oat_file_assistant.LoadDexFiles(*oat_file, dex_location.c_str());
1205 EXPECT_EQ(2u, dex_files.size());
1206}
1207
Richard Uhlerf4b34872016-04-13 11:03:46 -07001208TEST_F(OatFileAssistantTest, RuntimeCompilerFilterOptionUsed) {
1209 std::string dex_location = GetScratchDir() + "/RuntimeCompilerFilterOptionUsed.jar";
1210 Copy(GetDexSrc1(), dex_location);
1211
1212 OatFileAssistant oat_file_assistant(dex_location.c_str(), kRuntimeISA, false, false);
1213
1214 std::string error_msg;
1215 Runtime::Current()->AddCompilerOption("--compiler-filter=interpret-only");
1216 EXPECT_EQ(OatFileAssistant::kUpdateSucceeded,
1217 oat_file_assistant.MakeUpToDate(&error_msg)) << error_msg;
1218 EXPECT_EQ(OatFileAssistant::kNoDexOptNeeded,
1219 oat_file_assistant.GetDexOptNeeded(CompilerFilter::kInterpretOnly));
1220 EXPECT_EQ(OatFileAssistant::kDex2OatNeeded,
1221 oat_file_assistant.GetDexOptNeeded(CompilerFilter::kSpeed));
1222
1223 Runtime::Current()->AddCompilerOption("--compiler-filter=speed");
1224 EXPECT_EQ(OatFileAssistant::kUpdateSucceeded,
1225 oat_file_assistant.MakeUpToDate(&error_msg)) << error_msg;
1226 EXPECT_EQ(OatFileAssistant::kNoDexOptNeeded,
1227 oat_file_assistant.GetDexOptNeeded(CompilerFilter::kInterpretOnly));
1228 EXPECT_EQ(OatFileAssistant::kNoDexOptNeeded,
1229 oat_file_assistant.GetDexOptNeeded(CompilerFilter::kSpeed));
1230
1231 Runtime::Current()->AddCompilerOption("--compiler-filter=bogus");
1232 EXPECT_EQ(OatFileAssistant::kUpdateNotAttempted,
1233 oat_file_assistant.MakeUpToDate(&error_msg));
1234}
1235
Richard Uhler66d874d2015-01-15 09:37:19 -08001236TEST(OatFileAssistantUtilsTest, DexFilenameToOdexFilename) {
1237 std::string error_msg;
1238 std::string odex_file;
1239
1240 EXPECT_TRUE(OatFileAssistant::DexFilenameToOdexFilename(
Igor Murashkinb1d8c312015-08-04 11:18:43 -07001241 "/foo/bar/baz.jar", kArm, &odex_file, &error_msg)) << error_msg;
Richard Uhler63434112015-03-16 14:32:16 -07001242 EXPECT_EQ("/foo/bar/oat/arm/baz.odex", odex_file);
Richard Uhler66d874d2015-01-15 09:37:19 -08001243
1244 EXPECT_TRUE(OatFileAssistant::DexFilenameToOdexFilename(
Igor Murashkinb1d8c312015-08-04 11:18:43 -07001245 "/foo/bar/baz.funnyext", kArm, &odex_file, &error_msg)) << error_msg;
Richard Uhler63434112015-03-16 14:32:16 -07001246 EXPECT_EQ("/foo/bar/oat/arm/baz.odex", odex_file);
Richard Uhler66d874d2015-01-15 09:37:19 -08001247
1248 EXPECT_FALSE(OatFileAssistant::DexFilenameToOdexFilename(
Igor Murashkinb1d8c312015-08-04 11:18:43 -07001249 "nopath.jar", kArm, &odex_file, &error_msg));
Richard Uhler66d874d2015-01-15 09:37:19 -08001250 EXPECT_FALSE(OatFileAssistant::DexFilenameToOdexFilename(
Igor Murashkinb1d8c312015-08-04 11:18:43 -07001251 "/foo/bar/baz_noext", kArm, &odex_file, &error_msg));
Richard Uhler66d874d2015-01-15 09:37:19 -08001252}
1253
Richard Uhler23cedd22015-04-08 13:17:29 -07001254// Verify the dexopt status values from dalvik.system.DexFile
1255// match the OatFileAssistant::DexOptStatus values.
1256TEST_F(OatFileAssistantTest, DexOptStatusValues) {
1257 ScopedObjectAccess soa(Thread::Current());
1258 StackHandleScope<1> hs(soa.Self());
1259 ClassLinker* linker = Runtime::Current()->GetClassLinker();
1260 Handle<mirror::Class> dexfile(
1261 hs.NewHandle(linker->FindSystemClass(soa.Self(), "Ldalvik/system/DexFile;")));
1262 ASSERT_FALSE(dexfile.Get() == nullptr);
1263 linker->EnsureInitialized(soa.Self(), dexfile, true, true);
1264
Mathieu Chartierc7853442015-03-27 14:35:38 -07001265 ArtField* no_dexopt_needed = mirror::Class::FindStaticField(
Richard Uhler23cedd22015-04-08 13:17:29 -07001266 soa.Self(), dexfile, "NO_DEXOPT_NEEDED", "I");
1267 ASSERT_FALSE(no_dexopt_needed == nullptr);
1268 EXPECT_EQ(no_dexopt_needed->GetTypeAsPrimitiveType(), Primitive::kPrimInt);
1269 EXPECT_EQ(OatFileAssistant::kNoDexOptNeeded, no_dexopt_needed->GetInt(dexfile.Get()));
1270
Mathieu Chartierc7853442015-03-27 14:35:38 -07001271 ArtField* dex2oat_needed = mirror::Class::FindStaticField(
Richard Uhler23cedd22015-04-08 13:17:29 -07001272 soa.Self(), dexfile, "DEX2OAT_NEEDED", "I");
1273 ASSERT_FALSE(dex2oat_needed == nullptr);
1274 EXPECT_EQ(dex2oat_needed->GetTypeAsPrimitiveType(), Primitive::kPrimInt);
1275 EXPECT_EQ(OatFileAssistant::kDex2OatNeeded, dex2oat_needed->GetInt(dexfile.Get()));
1276
Mathieu Chartierc7853442015-03-27 14:35:38 -07001277 ArtField* patchoat_needed = mirror::Class::FindStaticField(
Richard Uhler23cedd22015-04-08 13:17:29 -07001278 soa.Self(), dexfile, "PATCHOAT_NEEDED", "I");
1279 ASSERT_FALSE(patchoat_needed == nullptr);
1280 EXPECT_EQ(patchoat_needed->GetTypeAsPrimitiveType(), Primitive::kPrimInt);
1281 EXPECT_EQ(OatFileAssistant::kPatchOatNeeded, patchoat_needed->GetInt(dexfile.Get()));
1282
Mathieu Chartierc7853442015-03-27 14:35:38 -07001283 ArtField* self_patchoat_needed = mirror::Class::FindStaticField(
Richard Uhler23cedd22015-04-08 13:17:29 -07001284 soa.Self(), dexfile, "SELF_PATCHOAT_NEEDED", "I");
1285 ASSERT_FALSE(self_patchoat_needed == nullptr);
1286 EXPECT_EQ(self_patchoat_needed->GetTypeAsPrimitiveType(), Primitive::kPrimInt);
1287 EXPECT_EQ(OatFileAssistant::kSelfPatchOatNeeded, self_patchoat_needed->GetInt(dexfile.Get()));
1288}
Richard Uhler66d874d2015-01-15 09:37:19 -08001289
1290// TODO: More Tests:
Andreas Gampe29d38e72016-03-23 15:31:51 +00001291// * Image checksum change is out of date for kIntepretOnly, but not
1292// kVerifyAtRuntime. But target of kVerifyAtRuntime still says current
1293// kInterpretOnly is out of date.
Richard Uhler66d874d2015-01-15 09:37:19 -08001294// * Test class linker falls back to unquickened dex for DexNoOat
1295// * Test class linker falls back to unquickened dex for MultiDexNoOat
Richard Uhler66d874d2015-01-15 09:37:19 -08001296// * Test using secondary isa
Richard Uhler66d874d2015-01-15 09:37:19 -08001297// * Test for status of oat while oat is being generated (how?)
1298// * Test case where 32 and 64 bit boot class paths differ,
1299// and we ask IsInBootClassPath for a class in exactly one of the 32 or
1300// 64 bit boot class paths.
1301// * Test unexpected scenarios (?):
1302// - Dex is stripped, don't have odex.
1303// - Oat file corrupted after status check, before reload unexecutable
1304// because it's unrelocated and no dex2oat
Calin Juravleb077e152016-02-18 18:47:37 +00001305// * Test unrelocated specific target compilation type can be relocated to
1306// make it up to date.
Richard Uhler66d874d2015-01-15 09:37:19 -08001307
1308} // namespace art