blob: 20347a90633ca4dd8059b6a0b6212aa9556ba162 [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
17#include "oat_file_assistant.h"
18
19#include <algorithm>
20#include <fstream>
21#include <string>
22#include <vector>
23#include <sys/param.h>
24
25#include <backtrace/BacktraceMap.h>
26#include <gtest/gtest.h>
27
Mathieu Chartierc7853442015-03-27 14:35:38 -070028#include "art_field-inl.h"
Vladimir Marko3481ba22015-04-13 12:22:36 +010029#include "class_linker-inl.h"
Richard Uhler66d874d2015-01-15 09:37:19 -080030#include "common_runtime_test.h"
Andreas Gampebb9c6b12015-03-29 13:56:36 -070031#include "compiler_callbacks.h"
Richard Uhlerf16d5722015-05-11 09:32:47 -070032#include "gc/space/image_space.h"
Richard Uhler66d874d2015-01-15 09:37:19 -080033#include "mem_map.h"
34#include "os.h"
Richard Uhler23cedd22015-04-08 13:17:29 -070035#include "scoped_thread_state_change.h"
Richard Uhler66d874d2015-01-15 09:37:19 -080036#include "thread-inl.h"
37#include "utils.h"
38
39namespace art {
40
41class OatFileAssistantTest : public CommonRuntimeTest {
42 public:
43 virtual void SetUp() {
44 ReserveImageSpace();
45 CommonRuntimeTest::SetUp();
46
47 // Create a scratch directory to work from.
48 scratch_dir_ = android_data_ + "/OatFileAssistantTest";
49 ASSERT_EQ(0, mkdir(scratch_dir_.c_str(), 0700));
50
Richard Uhler63434112015-03-16 14:32:16 -070051 // Create a subdirectory in scratch for odex files.
52 odex_oat_dir_ = scratch_dir_ + "/oat";
53 ASSERT_EQ(0, mkdir(odex_oat_dir_.c_str(), 0700));
54
55 odex_dir_ = odex_oat_dir_ + "/" + std::string(GetInstructionSetString(kRuntimeISA));
56 ASSERT_EQ(0, mkdir(odex_dir_.c_str(), 0700));
57
Richard Uhler66d874d2015-01-15 09:37:19 -080058
59 // Verify the environment is as we expect
60 uint32_t checksum;
61 std::string error_msg;
62 ASSERT_TRUE(OS::FileExists(GetImageFile().c_str()))
63 << "Expected pre-compiled boot image to be at: " << GetImageFile();
64 ASSERT_TRUE(OS::FileExists(GetDexSrc1().c_str()))
65 << "Expected dex file to be at: " << GetDexSrc1();
66 ASSERT_TRUE(OS::FileExists(GetStrippedDexSrc1().c_str()))
67 << "Expected stripped dex file to be at: " << GetStrippedDexSrc1();
Igor Murashkinb1d8c312015-08-04 11:18:43 -070068 ASSERT_FALSE(DexFile::GetChecksum(GetStrippedDexSrc1().c_str(), &checksum, &error_msg))
Richard Uhler66d874d2015-01-15 09:37:19 -080069 << "Expected stripped dex file to be stripped: " << GetStrippedDexSrc1();
Richard Uhler66d874d2015-01-15 09:37:19 -080070 ASSERT_TRUE(OS::FileExists(GetDexSrc2().c_str()))
71 << "Expected dex file to be at: " << GetDexSrc2();
Richard Uhler67ff7d12015-05-14 13:21:13 -070072
73 // GetMultiDexSrc2 should have the same primary dex checksum as
74 // GetMultiDexSrc1, but a different secondary dex checksum.
75 std::vector<std::unique_ptr<const DexFile>> multi1;
76 ASSERT_TRUE(DexFile::Open(GetMultiDexSrc1().c_str(),
Igor Murashkinb1d8c312015-08-04 11:18:43 -070077 GetMultiDexSrc1().c_str(), &error_msg, &multi1)) << error_msg;
Richard Uhler67ff7d12015-05-14 13:21:13 -070078 ASSERT_GT(multi1.size(), 1u);
79
80 std::vector<std::unique_ptr<const DexFile>> multi2;
81 ASSERT_TRUE(DexFile::Open(GetMultiDexSrc2().c_str(),
Igor Murashkinb1d8c312015-08-04 11:18:43 -070082 GetMultiDexSrc2().c_str(), &error_msg, &multi2)) << error_msg;
Richard Uhler67ff7d12015-05-14 13:21:13 -070083 ASSERT_GT(multi2.size(), 1u);
84
85 ASSERT_EQ(multi1[0]->GetLocationChecksum(), multi2[0]->GetLocationChecksum());
86 ASSERT_NE(multi1[1]->GetLocationChecksum(), multi2[1]->GetLocationChecksum());
Richard Uhler66d874d2015-01-15 09:37:19 -080087 }
88
89 virtual void SetUpRuntimeOptions(RuntimeOptions* options) {
Richard Uhler892fc962015-03-10 16:57:05 +000090 // options->push_back(std::make_pair("-verbose:oat", nullptr));
Richard Uhler66d874d2015-01-15 09:37:19 -080091
92 // Set up the image location.
93 options->push_back(std::make_pair("-Ximage:" + GetImageLocation(),
94 nullptr));
95 // Make sure compilercallbacks are not set so that relocation will be
96 // enabled.
Andreas Gampebb9c6b12015-03-29 13:56:36 -070097 callbacks_.reset();
Richard Uhler66d874d2015-01-15 09:37:19 -080098 }
99
100 virtual void PreRuntimeCreate() {
101 UnreserveImageSpace();
102 }
103
104 virtual void PostRuntimeCreate() {
105 ReserveImageSpace();
106 }
107
108 virtual void TearDown() {
Richard Uhler63434112015-03-16 14:32:16 -0700109 ClearDirectory(odex_dir_.c_str());
110 ASSERT_EQ(0, rmdir(odex_dir_.c_str()));
111
112 ClearDirectory(odex_oat_dir_.c_str());
113 ASSERT_EQ(0, rmdir(odex_oat_dir_.c_str()));
Richard Uhler66d874d2015-01-15 09:37:19 -0800114
115 ClearDirectory(scratch_dir_.c_str());
116 ASSERT_EQ(0, rmdir(scratch_dir_.c_str()));
117
118 CommonRuntimeTest::TearDown();
119 }
120
121 void Copy(std::string src, std::string dst) {
122 std::ifstream src_stream(src, std::ios::binary);
123 std::ofstream dst_stream(dst, std::ios::binary);
124
125 dst_stream << src_stream.rdbuf();
126 }
127
128 // Returns the directory where the pre-compiled core.art can be found.
129 // TODO: We should factor out this into common tests somewhere rather than
130 // re-hardcoding it here (This was copied originally from the elf writer
131 // test).
132 std::string GetImageDirectory() {
133 if (IsHost()) {
134 const char* host_dir = getenv("ANDROID_HOST_OUT");
Mathieu Chartier2cebb242015-04-21 16:50:40 -0700135 CHECK(host_dir != nullptr);
Richard Uhler66d874d2015-01-15 09:37:19 -0800136 return std::string(host_dir) + "/framework";
137 } else {
138 return std::string("/data/art-test");
139 }
140 }
141
142 std::string GetImageLocation() {
143 return GetImageDirectory() + "/core.art";
144 }
145
146 std::string GetImageFile() {
147 return GetImageDirectory() + "/" + GetInstructionSetString(kRuntimeISA)
148 + "/core.art";
149 }
150
151 std::string GetDexSrc1() {
152 return GetTestDexFileName("Main");
153 }
154
155 // Returns the path to a dex file equivalent to GetDexSrc1, but with the dex
156 // file stripped.
157 std::string GetStrippedDexSrc1() {
158 return GetTestDexFileName("MainStripped");
159 }
160
161 std::string GetMultiDexSrc1() {
162 return GetTestDexFileName("MultiDex");
163 }
164
Richard Uhler67ff7d12015-05-14 13:21:13 -0700165 // Returns the path to a multidex file equivalent to GetMultiDexSrc2, but
166 // with the contents of the secondary dex file changed.
167 std::string GetMultiDexSrc2() {
168 return GetTestDexFileName("MultiDexModifiedSecondary");
169 }
170
Richard Uhler66d874d2015-01-15 09:37:19 -0800171 std::string GetDexSrc2() {
172 return GetTestDexFileName("Nested");
173 }
174
175 // Scratch directory, for dex and odex files (oat files will go in the
176 // dalvik cache).
177 std::string GetScratchDir() {
178 return scratch_dir_;
179 }
180
Richard Uhler63434112015-03-16 14:32:16 -0700181 // Odex directory is the subdirectory in the scratch directory where odex
Richard Uhler66d874d2015-01-15 09:37:19 -0800182 // files should be located.
Richard Uhler63434112015-03-16 14:32:16 -0700183 std::string GetOdexDir() {
184 return odex_dir_;
Richard Uhler66d874d2015-01-15 09:37:19 -0800185 }
186
Richard Uhler93aa2102015-08-10 14:47:41 -0700187 // Generate a non-PIC odex file for the purposes of test.
Richard Uhler94f5bda2015-07-22 08:25:11 -0700188 // The generated odex file will be un-relocated.
Richard Uhler66d874d2015-01-15 09:37:19 -0800189 void GenerateOdexForTest(const std::string& dex_location,
Richard Uhler93aa2102015-08-10 14:47:41 -0700190 const std::string& odex_location) {
191 // To generate an un-relocated odex file, we first compile a relocated
192 // version of the file, then manually call patchoat to make it look as if
193 // it is unrelocated.
194 std::string relocated_odex_location = odex_location + ".relocated";
195 std::vector<std::string> args;
196 args.push_back("--dex-file=" + dex_location);
197 args.push_back("--oat-file=" + relocated_odex_location);
198 args.push_back("--include-patch-information");
199
200 // We need to use the quick compiler to generate non-PIC code, because
201 // the optimizing compiler always generates PIC.
202 args.push_back("--compiler-backend=Quick");
203
204 std::string error_msg;
205 ASSERT_TRUE(OatFileAssistant::Dex2Oat(args, &error_msg)) << error_msg;
206
207 // Use patchoat to unrelocate the relocated odex file.
208 Runtime* runtime = Runtime::Current();
209 std::vector<std::string> argv;
210 argv.push_back(runtime->GetPatchoatExecutable());
211 argv.push_back("--instruction-set=" + std::string(GetInstructionSetString(kRuntimeISA)));
212 argv.push_back("--input-oat-file=" + relocated_odex_location);
213 argv.push_back("--output-oat-file=" + odex_location);
214 argv.push_back("--base-offset-delta=0x00008000");
215 std::string command_line(Join(argv, ' '));
216 ASSERT_TRUE(Exec(argv, &error_msg)) << error_msg;
217
218 // Verify the odex file was generated as expected and really is
219 // unrelocated.
220 std::unique_ptr<OatFile> odex_file(OatFile::Open(
221 odex_location.c_str(), odex_location.c_str(), nullptr, nullptr,
222 false, dex_location.c_str(), &error_msg));
223 ASSERT_TRUE(odex_file.get() != nullptr) << error_msg;
224
225 const gc::space::ImageSpace* image_space = runtime->GetHeap()->GetImageSpace();
226 ASSERT_TRUE(image_space != nullptr);
227 const ImageHeader& image_header = image_space->GetImageHeader();
228 const OatHeader& oat_header = odex_file->GetOatHeader();
229 EXPECT_FALSE(odex_file->IsPic());
230 EXPECT_EQ(image_header.GetOatChecksum(), oat_header.GetImageFileLocationOatChecksum());
231 EXPECT_NE(reinterpret_cast<uintptr_t>(image_header.GetOatDataBegin()),
232 oat_header.GetImageFileLocationOatDataBegin());
233 EXPECT_NE(image_header.GetPatchDelta(), oat_header.GetImagePatchDelta());
234 }
235
236 void GeneratePicOdexForTest(const std::string& dex_location,
237 const std::string& odex_location) {
238 // Temporarily redirect the dalvik cache so dex2oat doesn't find the
239 // relocated image file.
Richard Uhler66d874d2015-01-15 09:37:19 -0800240 std::string android_data_tmp = GetScratchDir() + "AndroidDataTmp";
241 setenv("ANDROID_DATA", android_data_tmp.c_str(), 1);
242 std::vector<std::string> args;
243 args.push_back("--dex-file=" + dex_location);
244 args.push_back("--oat-file=" + odex_location);
Richard Uhler93aa2102015-08-10 14:47:41 -0700245 args.push_back("--compile-pic");
Richard Uhler66d874d2015-01-15 09:37:19 -0800246 args.push_back("--runtime-arg");
247 args.push_back("-Xnorelocate");
248 std::string error_msg;
Igor Murashkinb1d8c312015-08-04 11:18:43 -0700249 ASSERT_TRUE(OatFileAssistant::Dex2Oat(args, &error_msg)) << error_msg;
Richard Uhler66d874d2015-01-15 09:37:19 -0800250 setenv("ANDROID_DATA", android_data_.c_str(), 1);
Richard Uhler94f5bda2015-07-22 08:25:11 -0700251
252 // Verify the odex file was generated as expected.
253 std::unique_ptr<OatFile> odex_file(OatFile::Open(
254 odex_location.c_str(), odex_location.c_str(), nullptr, nullptr,
Igor Murashkinb1d8c312015-08-04 11:18:43 -0700255 false, dex_location.c_str(), &error_msg));
Richard Uhler94f5bda2015-07-22 08:25:11 -0700256 ASSERT_TRUE(odex_file.get() != nullptr) << error_msg;
Richard Uhler93aa2102015-08-10 14:47:41 -0700257 EXPECT_TRUE(odex_file->IsPic());
Richard Uhler66d874d2015-01-15 09:37:19 -0800258 }
259
260 private:
261 // Reserve memory around where the image will be loaded so other memory
262 // won't conflict when it comes time to load the image.
263 // This can be called with an already loaded image to reserve the space
264 // around it.
265 void ReserveImageSpace() {
266 MemMap::Init();
267
268 // Ensure a chunk of memory is reserved for the image space.
269 uintptr_t reservation_start = ART_BASE_ADDRESS + ART_BASE_ADDRESS_MIN_DELTA;
270 uintptr_t reservation_end = ART_BASE_ADDRESS + ART_BASE_ADDRESS_MAX_DELTA
Hiroshi Yamauchi3dbf2342015-03-17 16:01:11 -0700271 // Include the main space that has to come right after the
272 // image in case of the GSS collector.
273 + 384 * MB;
Richard Uhler66d874d2015-01-15 09:37:19 -0800274
Richard Uhler66d874d2015-01-15 09:37:19 -0800275 std::unique_ptr<BacktraceMap> map(BacktraceMap::Create(getpid(), true));
276 ASSERT_TRUE(map.get() != nullptr) << "Failed to build process map";
277 for (BacktraceMap::const_iterator it = map->begin();
278 reservation_start < reservation_end && it != map->end(); ++it) {
Richard Uhler3efe9792015-03-30 16:18:03 -0700279 ReserveImageSpaceChunk(reservation_start, std::min(it->start, reservation_end));
280 reservation_start = std::max(reservation_start, it->end);
281 }
282 ReserveImageSpaceChunk(reservation_start, reservation_end);
283 }
Richard Uhler66d874d2015-01-15 09:37:19 -0800284
Richard Uhler3efe9792015-03-30 16:18:03 -0700285 // Reserve a chunk of memory for the image space in the given range.
286 // Only has effect for chunks with a positive number of bytes.
287 void ReserveImageSpaceChunk(uintptr_t start, uintptr_t end) {
288 if (start < end) {
289 std::string error_msg;
Richard Uhler66d874d2015-01-15 09:37:19 -0800290 image_reservation_.push_back(std::unique_ptr<MemMap>(
291 MemMap::MapAnonymous("image reservation",
Richard Uhler3efe9792015-03-30 16:18:03 -0700292 reinterpret_cast<uint8_t*>(start), end - start,
Igor Murashkinb1d8c312015-08-04 11:18:43 -0700293 PROT_NONE, false, false, &error_msg)));
Richard Uhler66d874d2015-01-15 09:37:19 -0800294 ASSERT_TRUE(image_reservation_.back().get() != nullptr) << error_msg;
295 LOG(INFO) << "Reserved space for image " <<
296 reinterpret_cast<void*>(image_reservation_.back()->Begin()) << "-" <<
297 reinterpret_cast<void*>(image_reservation_.back()->End());
Richard Uhler66d874d2015-01-15 09:37:19 -0800298 }
299 }
300
301
302 // Unreserve any memory reserved by ReserveImageSpace. This should be called
303 // before the image is loaded.
304 void UnreserveImageSpace() {
305 image_reservation_.clear();
306 }
307
308 std::string scratch_dir_;
Richard Uhler63434112015-03-16 14:32:16 -0700309 std::string odex_oat_dir_;
310 std::string odex_dir_;
Richard Uhler66d874d2015-01-15 09:37:19 -0800311 std::vector<std::unique_ptr<MemMap>> image_reservation_;
312};
313
314class OatFileAssistantNoDex2OatTest : public OatFileAssistantTest {
315 public:
316 virtual void SetUpRuntimeOptions(RuntimeOptions* options) {
317 OatFileAssistantTest::SetUpRuntimeOptions(options);
318 options->push_back(std::make_pair("-Xnodex2oat", nullptr));
319 }
320};
321
322// Generate an oat file for the purposes of test, as opposed to testing
323// generation of oat files.
324static void GenerateOatForTest(const char* dex_location) {
325 OatFileAssistant oat_file_assistant(dex_location, kRuntimeISA, false);
326
327 std::string error_msg;
Igor Murashkinb1d8c312015-08-04 11:18:43 -0700328 ASSERT_TRUE(oat_file_assistant.GenerateOatFile(&error_msg)) << error_msg;
Richard Uhler66d874d2015-01-15 09:37:19 -0800329}
330
331// Case: We have a DEX file, but no OAT file for it.
Richard Uhler95abd042015-03-24 09:51:28 -0700332// Expect: The status is kDex2OatNeeded.
Richard Uhler66d874d2015-01-15 09:37:19 -0800333TEST_F(OatFileAssistantTest, DexNoOat) {
334 std::string dex_location = GetScratchDir() + "/DexNoOat.jar";
335 Copy(GetDexSrc1(), dex_location);
336
337 OatFileAssistant oat_file_assistant(dex_location.c_str(), kRuntimeISA, false);
338
Richard Uhler95abd042015-03-24 09:51:28 -0700339 EXPECT_EQ(OatFileAssistant::kDex2OatNeeded, oat_file_assistant.GetDexOptNeeded());
Richard Uhler66d874d2015-01-15 09:37:19 -0800340
341 EXPECT_FALSE(oat_file_assistant.IsInBootClassPath());
342 EXPECT_FALSE(oat_file_assistant.OdexFileExists());
343 EXPECT_TRUE(oat_file_assistant.OdexFileIsOutOfDate());
344 EXPECT_FALSE(oat_file_assistant.OdexFileNeedsRelocation());
345 EXPECT_FALSE(oat_file_assistant.OdexFileIsUpToDate());
Richard Uhler95abd042015-03-24 09:51:28 -0700346 EXPECT_EQ(OatFileAssistant::kOatOutOfDate, oat_file_assistant.OdexFileStatus());
Richard Uhler66d874d2015-01-15 09:37:19 -0800347 EXPECT_FALSE(oat_file_assistant.OatFileExists());
348 EXPECT_TRUE(oat_file_assistant.OatFileIsOutOfDate());
349 EXPECT_FALSE(oat_file_assistant.OatFileNeedsRelocation());
350 EXPECT_FALSE(oat_file_assistant.OatFileIsUpToDate());
Richard Uhler95abd042015-03-24 09:51:28 -0700351 EXPECT_EQ(OatFileAssistant::kOatOutOfDate, oat_file_assistant.OatFileStatus());
Richard Uhler9b994ea2015-06-24 08:44:19 -0700352 EXPECT_TRUE(oat_file_assistant.HasOriginalDexFiles());
Richard Uhler66d874d2015-01-15 09:37:19 -0800353}
354
355// Case: We have no DEX file and no OAT file.
Richard Uhler9b994ea2015-06-24 08:44:19 -0700356// Expect: Status is kNoDexOptNeeded. Loading should fail, but not crash.
Richard Uhler66d874d2015-01-15 09:37:19 -0800357TEST_F(OatFileAssistantTest, NoDexNoOat) {
358 std::string dex_location = GetScratchDir() + "/NoDexNoOat.jar";
359
360 OatFileAssistant oat_file_assistant(dex_location.c_str(), kRuntimeISA, true);
361
Richard Uhler9b994ea2015-06-24 08:44:19 -0700362 EXPECT_EQ(OatFileAssistant::kNoDexOptNeeded, oat_file_assistant.GetDexOptNeeded());
363 EXPECT_FALSE(oat_file_assistant.HasOriginalDexFiles());
364
365 // Trying to make the oat file up to date should not fail or crash.
366 std::string error_msg;
Igor Murashkinb1d8c312015-08-04 11:18:43 -0700367 EXPECT_TRUE(oat_file_assistant.MakeUpToDate(&error_msg));
Richard Uhler9b994ea2015-06-24 08:44:19 -0700368
369 // Trying to get the best oat file should fail, but not crash.
Richard Uhler66d874d2015-01-15 09:37:19 -0800370 std::unique_ptr<OatFile> oat_file = oat_file_assistant.GetBestOatFile();
371 EXPECT_EQ(nullptr, oat_file.get());
372}
373
374// Case: We have a DEX file and up-to-date OAT file for it.
Richard Uhler95abd042015-03-24 09:51:28 -0700375// Expect: The status is kNoDexOptNeeded.
Richard Uhler66d874d2015-01-15 09:37:19 -0800376TEST_F(OatFileAssistantTest, OatUpToDate) {
377 std::string dex_location = GetScratchDir() + "/OatUpToDate.jar";
378 Copy(GetDexSrc1(), dex_location);
379 GenerateOatForTest(dex_location.c_str());
380
381 OatFileAssistant oat_file_assistant(dex_location.c_str(), kRuntimeISA, false);
382
Richard Uhler95abd042015-03-24 09:51:28 -0700383 EXPECT_EQ(OatFileAssistant::kNoDexOptNeeded, oat_file_assistant.GetDexOptNeeded());
Richard Uhler66d874d2015-01-15 09:37:19 -0800384 EXPECT_FALSE(oat_file_assistant.IsInBootClassPath());
385 EXPECT_FALSE(oat_file_assistant.OdexFileExists());
386 EXPECT_TRUE(oat_file_assistant.OdexFileIsOutOfDate());
387 EXPECT_FALSE(oat_file_assistant.OdexFileIsUpToDate());
388 EXPECT_TRUE(oat_file_assistant.OatFileExists());
389 EXPECT_FALSE(oat_file_assistant.OatFileIsOutOfDate());
390 EXPECT_FALSE(oat_file_assistant.OatFileNeedsRelocation());
391 EXPECT_TRUE(oat_file_assistant.OatFileIsUpToDate());
Richard Uhler95abd042015-03-24 09:51:28 -0700392 EXPECT_EQ(OatFileAssistant::kOatUpToDate, oat_file_assistant.OatFileStatus());
Richard Uhler9b994ea2015-06-24 08:44:19 -0700393 EXPECT_TRUE(oat_file_assistant.HasOriginalDexFiles());
Richard Uhler66d874d2015-01-15 09:37:19 -0800394}
395
396// Case: We have a MultiDEX file and up-to-date OAT file for it.
Richard Uhler95abd042015-03-24 09:51:28 -0700397// Expect: The status is kNoDexOptNeeded and we load all dex files.
Richard Uhler66d874d2015-01-15 09:37:19 -0800398TEST_F(OatFileAssistantTest, MultiDexOatUpToDate) {
399 std::string dex_location = GetScratchDir() + "/MultiDexOatUpToDate.jar";
400 Copy(GetMultiDexSrc1(), dex_location);
401 GenerateOatForTest(dex_location.c_str());
402
Richard Uhlere5fed032015-03-18 08:21:11 -0700403 OatFileAssistant oat_file_assistant(dex_location.c_str(), kRuntimeISA, true);
Richard Uhler95abd042015-03-24 09:51:28 -0700404 EXPECT_EQ(OatFileAssistant::kNoDexOptNeeded, oat_file_assistant.GetDexOptNeeded());
Richard Uhler9b994ea2015-06-24 08:44:19 -0700405 EXPECT_TRUE(oat_file_assistant.HasOriginalDexFiles());
Richard Uhler95abd042015-03-24 09:51:28 -0700406
407 // Verify we can load both dex files.
Richard Uhlere5fed032015-03-18 08:21:11 -0700408 std::unique_ptr<OatFile> oat_file = oat_file_assistant.GetBestOatFile();
Richard Uhler66d874d2015-01-15 09:37:19 -0800409 ASSERT_TRUE(oat_file.get() != nullptr);
410 EXPECT_TRUE(oat_file->IsExecutable());
411 std::vector<std::unique_ptr<const DexFile>> dex_files;
Richard Uhlere5fed032015-03-18 08:21:11 -0700412 dex_files = oat_file_assistant.LoadDexFiles(*oat_file, dex_location.c_str());
413 EXPECT_EQ(2u, dex_files.size());
414}
415
Richard Uhler67ff7d12015-05-14 13:21:13 -0700416// Case: We have a MultiDEX file where the secondary dex file is out of date.
417// Expect: The status is kDex2OatNeeded.
418TEST_F(OatFileAssistantTest, MultiDexSecondaryOutOfDate) {
419 std::string dex_location = GetScratchDir() + "/MultiDexSecondaryOutOfDate.jar";
420
421 // Compile code for GetMultiDexSrc1.
422 Copy(GetMultiDexSrc1(), dex_location);
423 GenerateOatForTest(dex_location.c_str());
424
425 // Now overwrite the dex file with GetMultiDexSrc2 so the secondary checksum
426 // is out of date.
427 Copy(GetMultiDexSrc2(), dex_location);
428
429 OatFileAssistant oat_file_assistant(dex_location.c_str(), kRuntimeISA, true);
430 EXPECT_EQ(OatFileAssistant::kDex2OatNeeded, oat_file_assistant.GetDexOptNeeded());
Richard Uhler9b994ea2015-06-24 08:44:19 -0700431 EXPECT_TRUE(oat_file_assistant.HasOriginalDexFiles());
Richard Uhler67ff7d12015-05-14 13:21:13 -0700432}
433
Richard Uhlere5fed032015-03-18 08:21:11 -0700434// Case: We have a MultiDEX file and up-to-date OAT file for it with relative
435// encoded dex locations.
Richard Uhler95abd042015-03-24 09:51:28 -0700436// Expect: The oat file status is kNoDexOptNeeded.
Richard Uhlere5fed032015-03-18 08:21:11 -0700437TEST_F(OatFileAssistantTest, RelativeEncodedDexLocation) {
438 std::string dex_location = GetScratchDir() + "/RelativeEncodedDexLocation.jar";
Richard Uhler63434112015-03-16 14:32:16 -0700439 std::string oat_location = GetOdexDir() + "/RelativeEncodedDexLocation.oat";
Richard Uhlere5fed032015-03-18 08:21:11 -0700440
441 // Create the dex file
442 Copy(GetMultiDexSrc1(), dex_location);
443
444 // Create the oat file with relative encoded dex location.
445 std::vector<std::string> args;
446 args.push_back("--dex-file=" + dex_location);
447 args.push_back("--dex-location=" + std::string("RelativeEncodedDexLocation.jar"));
448 args.push_back("--oat-file=" + oat_location);
449
450 std::string error_msg;
Igor Murashkinb1d8c312015-08-04 11:18:43 -0700451 ASSERT_TRUE(OatFileAssistant::Dex2Oat(args, &error_msg)) << error_msg;
Richard Uhlere5fed032015-03-18 08:21:11 -0700452
453 // Verify we can load both dex files.
454 OatFileAssistant oat_file_assistant(dex_location.c_str(),
455 oat_location.c_str(),
456 kRuntimeISA, true);
457 std::unique_ptr<OatFile> oat_file = oat_file_assistant.GetBestOatFile();
458 ASSERT_TRUE(oat_file.get() != nullptr);
459 EXPECT_TRUE(oat_file->IsExecutable());
460 std::vector<std::unique_ptr<const DexFile>> dex_files;
461 dex_files = oat_file_assistant.LoadDexFiles(*oat_file, dex_location.c_str());
Richard Uhler66d874d2015-01-15 09:37:19 -0800462 EXPECT_EQ(2u, dex_files.size());
463}
464
Richard Uhler95abd042015-03-24 09:51:28 -0700465// Case: We have a DEX file and out-of-date OAT file.
466// Expect: The status is kDex2OatNeeded.
Richard Uhler66d874d2015-01-15 09:37:19 -0800467TEST_F(OatFileAssistantTest, OatOutOfDate) {
468 std::string dex_location = GetScratchDir() + "/OatOutOfDate.jar";
469
470 // We create a dex, generate an oat for it, then overwrite the dex with a
471 // different dex to make the oat out of date.
472 Copy(GetDexSrc1(), dex_location);
473 GenerateOatForTest(dex_location.c_str());
474 Copy(GetDexSrc2(), dex_location);
475
476 OatFileAssistant oat_file_assistant(dex_location.c_str(), kRuntimeISA, false);
Richard Uhler95abd042015-03-24 09:51:28 -0700477 EXPECT_EQ(OatFileAssistant::kDex2OatNeeded, oat_file_assistant.GetDexOptNeeded());
Richard Uhler66d874d2015-01-15 09:37:19 -0800478
479 EXPECT_FALSE(oat_file_assistant.IsInBootClassPath());
480 EXPECT_FALSE(oat_file_assistant.OdexFileExists());
481 EXPECT_TRUE(oat_file_assistant.OdexFileIsOutOfDate());
482 EXPECT_FALSE(oat_file_assistant.OdexFileIsUpToDate());
483 EXPECT_TRUE(oat_file_assistant.OatFileExists());
484 EXPECT_TRUE(oat_file_assistant.OatFileIsOutOfDate());
485 EXPECT_FALSE(oat_file_assistant.OatFileIsUpToDate());
Richard Uhler9b994ea2015-06-24 08:44:19 -0700486 EXPECT_TRUE(oat_file_assistant.HasOriginalDexFiles());
Richard Uhler66d874d2015-01-15 09:37:19 -0800487}
488
489// Case: We have a DEX file and an ODEX file, but no OAT file.
Richard Uhler95abd042015-03-24 09:51:28 -0700490// Expect: The status is kPatchOatNeeded.
Richard Uhler66d874d2015-01-15 09:37:19 -0800491TEST_F(OatFileAssistantTest, DexOdexNoOat) {
492 std::string dex_location = GetScratchDir() + "/DexOdexNoOat.jar";
Richard Uhler63434112015-03-16 14:32:16 -0700493 std::string odex_location = GetOdexDir() + "/DexOdexNoOat.odex";
Richard Uhler66d874d2015-01-15 09:37:19 -0800494
495 // Create the dex and odex files
496 Copy(GetDexSrc1(), dex_location);
497 GenerateOdexForTest(dex_location, odex_location);
498
499 // Verify the status.
500 OatFileAssistant oat_file_assistant(dex_location.c_str(), kRuntimeISA, false);
501
Richard Uhler95abd042015-03-24 09:51:28 -0700502 EXPECT_EQ(OatFileAssistant::kPatchOatNeeded, oat_file_assistant.GetDexOptNeeded());
Richard Uhler66d874d2015-01-15 09:37:19 -0800503
504 EXPECT_FALSE(oat_file_assistant.IsInBootClassPath());
505 EXPECT_TRUE(oat_file_assistant.OdexFileExists());
506 EXPECT_FALSE(oat_file_assistant.OdexFileIsOutOfDate());
507 EXPECT_FALSE(oat_file_assistant.OdexFileIsUpToDate());
508 EXPECT_TRUE(oat_file_assistant.OdexFileNeedsRelocation());
Richard Uhler66d874d2015-01-15 09:37:19 -0800509 EXPECT_FALSE(oat_file_assistant.OatFileExists());
510 EXPECT_TRUE(oat_file_assistant.OatFileIsOutOfDate());
511 EXPECT_FALSE(oat_file_assistant.OatFileIsUpToDate());
Richard Uhler9b994ea2015-06-24 08:44:19 -0700512 EXPECT_TRUE(oat_file_assistant.HasOriginalDexFiles());
Richard Uhler5f946da2015-07-17 12:28:32 -0700513
514 // We should still be able to get the non-executable odex file to run from.
515 std::unique_ptr<OatFile> oat_file = oat_file_assistant.GetBestOatFile();
516 ASSERT_TRUE(oat_file.get() != nullptr);
Richard Uhler66d874d2015-01-15 09:37:19 -0800517}
518
519// Case: We have a stripped DEX file and an ODEX file, but no OAT file.
Richard Uhler95abd042015-03-24 09:51:28 -0700520// Expect: The status is kPatchOatNeeded
Richard Uhler66d874d2015-01-15 09:37:19 -0800521TEST_F(OatFileAssistantTest, StrippedDexOdexNoOat) {
522 std::string dex_location = GetScratchDir() + "/StrippedDexOdexNoOat.jar";
Richard Uhler63434112015-03-16 14:32:16 -0700523 std::string odex_location = GetOdexDir() + "/StrippedDexOdexNoOat.odex";
Richard Uhler66d874d2015-01-15 09:37:19 -0800524
525 // Create the dex and odex files
526 Copy(GetDexSrc1(), dex_location);
527 GenerateOdexForTest(dex_location, odex_location);
528
529 // Strip the dex file
530 Copy(GetStrippedDexSrc1(), dex_location);
531
532 // Verify the status.
533 OatFileAssistant oat_file_assistant(dex_location.c_str(), kRuntimeISA, true);
534
Richard Uhler95abd042015-03-24 09:51:28 -0700535 EXPECT_EQ(OatFileAssistant::kPatchOatNeeded, oat_file_assistant.GetDexOptNeeded());
Richard Uhler66d874d2015-01-15 09:37:19 -0800536
537 EXPECT_FALSE(oat_file_assistant.IsInBootClassPath());
538 EXPECT_TRUE(oat_file_assistant.OdexFileExists());
539 EXPECT_FALSE(oat_file_assistant.OdexFileIsOutOfDate());
540 EXPECT_FALSE(oat_file_assistant.OdexFileIsUpToDate());
541 EXPECT_FALSE(oat_file_assistant.OatFileExists());
542 EXPECT_TRUE(oat_file_assistant.OatFileIsOutOfDate());
543 EXPECT_FALSE(oat_file_assistant.OatFileIsUpToDate());
Richard Uhler9b994ea2015-06-24 08:44:19 -0700544 EXPECT_FALSE(oat_file_assistant.HasOriginalDexFiles());
Richard Uhler66d874d2015-01-15 09:37:19 -0800545
546 // Make the oat file up to date.
547 std::string error_msg;
Igor Murashkinb1d8c312015-08-04 11:18:43 -0700548 ASSERT_TRUE(oat_file_assistant.MakeUpToDate(&error_msg)) << error_msg;
Richard Uhler66d874d2015-01-15 09:37:19 -0800549
Richard Uhler95abd042015-03-24 09:51:28 -0700550 EXPECT_EQ(OatFileAssistant::kNoDexOptNeeded, oat_file_assistant.GetDexOptNeeded());
Richard Uhler66d874d2015-01-15 09:37:19 -0800551
552 EXPECT_FALSE(oat_file_assistant.IsInBootClassPath());
553 EXPECT_TRUE(oat_file_assistant.OdexFileExists());
554 EXPECT_FALSE(oat_file_assistant.OdexFileIsOutOfDate());
555 EXPECT_FALSE(oat_file_assistant.OdexFileIsUpToDate());
556 EXPECT_TRUE(oat_file_assistant.OatFileExists());
557 EXPECT_FALSE(oat_file_assistant.OatFileIsOutOfDate());
558 EXPECT_TRUE(oat_file_assistant.OatFileIsUpToDate());
Richard Uhler9b994ea2015-06-24 08:44:19 -0700559 EXPECT_FALSE(oat_file_assistant.HasOriginalDexFiles());
Richard Uhler66d874d2015-01-15 09:37:19 -0800560
561 // Verify we can load the dex files from it.
562 std::unique_ptr<OatFile> oat_file = oat_file_assistant.GetBestOatFile();
563 ASSERT_TRUE(oat_file.get() != nullptr);
564 EXPECT_TRUE(oat_file->IsExecutable());
565 std::vector<std::unique_ptr<const DexFile>> dex_files;
566 dex_files = oat_file_assistant.LoadDexFiles(*oat_file, dex_location.c_str());
567 EXPECT_EQ(1u, dex_files.size());
568}
569
Richard Uhler95abd042015-03-24 09:51:28 -0700570// Case: We have a stripped DEX file, an ODEX file, and an out-of-date OAT file.
571// Expect: The status is kPatchOatNeeded.
Richard Uhler66d874d2015-01-15 09:37:19 -0800572TEST_F(OatFileAssistantTest, StrippedDexOdexOat) {
573 std::string dex_location = GetScratchDir() + "/StrippedDexOdexOat.jar";
Richard Uhler63434112015-03-16 14:32:16 -0700574 std::string odex_location = GetOdexDir() + "/StrippedDexOdexOat.odex";
Richard Uhler66d874d2015-01-15 09:37:19 -0800575
576 // Create the oat file from a different dex file so it looks out of date.
577 Copy(GetDexSrc2(), dex_location);
578 GenerateOatForTest(dex_location.c_str());
579
580 // Create the odex file
581 Copy(GetDexSrc1(), dex_location);
582 GenerateOdexForTest(dex_location, odex_location);
583
584 // Strip the dex file.
585 Copy(GetStrippedDexSrc1(), dex_location);
586
587 // Verify the status.
588 OatFileAssistant oat_file_assistant(dex_location.c_str(), kRuntimeISA, true);
589
Richard Uhler95abd042015-03-24 09:51:28 -0700590 EXPECT_EQ(OatFileAssistant::kPatchOatNeeded, oat_file_assistant.GetDexOptNeeded());
Richard Uhler66d874d2015-01-15 09:37:19 -0800591
592 EXPECT_FALSE(oat_file_assistant.IsInBootClassPath());
593 EXPECT_TRUE(oat_file_assistant.OdexFileExists());
594 EXPECT_FALSE(oat_file_assistant.OdexFileIsOutOfDate());
595 EXPECT_TRUE(oat_file_assistant.OdexFileNeedsRelocation());
596 EXPECT_FALSE(oat_file_assistant.OdexFileIsUpToDate());
597 EXPECT_TRUE(oat_file_assistant.OatFileExists());
598 EXPECT_TRUE(oat_file_assistant.OatFileIsOutOfDate());
599 EXPECT_FALSE(oat_file_assistant.OatFileIsUpToDate());
Richard Uhler9b994ea2015-06-24 08:44:19 -0700600 EXPECT_FALSE(oat_file_assistant.HasOriginalDexFiles());
Richard Uhler66d874d2015-01-15 09:37:19 -0800601
602 // Make the oat file up to date.
603 std::string error_msg;
Igor Murashkinb1d8c312015-08-04 11:18:43 -0700604 ASSERT_TRUE(oat_file_assistant.MakeUpToDate(&error_msg)) << error_msg;
Richard Uhler66d874d2015-01-15 09:37:19 -0800605
Richard Uhler95abd042015-03-24 09:51:28 -0700606 EXPECT_EQ(OatFileAssistant::kNoDexOptNeeded, oat_file_assistant.GetDexOptNeeded());
Richard Uhler66d874d2015-01-15 09:37:19 -0800607
608 EXPECT_FALSE(oat_file_assistant.IsInBootClassPath());
609 EXPECT_TRUE(oat_file_assistant.OdexFileExists());
610 EXPECT_FALSE(oat_file_assistant.OdexFileIsOutOfDate());
611 EXPECT_TRUE(oat_file_assistant.OdexFileNeedsRelocation());
612 EXPECT_FALSE(oat_file_assistant.OdexFileIsUpToDate());
613 EXPECT_TRUE(oat_file_assistant.OatFileExists());
614 EXPECT_FALSE(oat_file_assistant.OatFileIsOutOfDate());
615 EXPECT_FALSE(oat_file_assistant.OatFileNeedsRelocation());
616 EXPECT_TRUE(oat_file_assistant.OatFileIsUpToDate());
Richard Uhler9b994ea2015-06-24 08:44:19 -0700617 EXPECT_FALSE(oat_file_assistant.HasOriginalDexFiles());
Richard Uhler66d874d2015-01-15 09:37:19 -0800618
619 // Verify we can load the dex files from it.
620 std::unique_ptr<OatFile> oat_file = oat_file_assistant.GetBestOatFile();
621 ASSERT_TRUE(oat_file.get() != nullptr);
622 EXPECT_TRUE(oat_file->IsExecutable());
623 std::vector<std::unique_ptr<const DexFile>> dex_files;
624 dex_files = oat_file_assistant.LoadDexFiles(*oat_file, dex_location.c_str());
625 EXPECT_EQ(1u, dex_files.size());
626}
627
Richard Uhler9b994ea2015-06-24 08:44:19 -0700628// Case: We have a stripped (or resource-only) DEX file, no ODEX file and no
629// OAT file. Expect: The status is kNoDexOptNeeded.
630TEST_F(OatFileAssistantTest, ResourceOnlyDex) {
631 std::string dex_location = GetScratchDir() + "/ResourceOnlyDex.jar";
632
633 Copy(GetStrippedDexSrc1(), dex_location);
634
635 // Verify the status.
636 OatFileAssistant oat_file_assistant(dex_location.c_str(), kRuntimeISA, true);
637
638 EXPECT_EQ(OatFileAssistant::kNoDexOptNeeded, oat_file_assistant.GetDexOptNeeded());
639
640 EXPECT_FALSE(oat_file_assistant.IsInBootClassPath());
641 EXPECT_FALSE(oat_file_assistant.OdexFileExists());
642 EXPECT_TRUE(oat_file_assistant.OdexFileIsOutOfDate());
643 EXPECT_FALSE(oat_file_assistant.OdexFileNeedsRelocation());
644 EXPECT_FALSE(oat_file_assistant.OdexFileIsUpToDate());
645 EXPECT_FALSE(oat_file_assistant.OatFileExists());
646 EXPECT_TRUE(oat_file_assistant.OatFileIsOutOfDate());
647 EXPECT_FALSE(oat_file_assistant.OatFileIsUpToDate());
648 EXPECT_FALSE(oat_file_assistant.HasOriginalDexFiles());
649
650 // Make the oat file up to date. This should have no effect.
651 std::string error_msg;
Igor Murashkinb1d8c312015-08-04 11:18:43 -0700652 EXPECT_TRUE(oat_file_assistant.MakeUpToDate(&error_msg)) << error_msg;
Richard Uhler9b994ea2015-06-24 08:44:19 -0700653
654 EXPECT_EQ(OatFileAssistant::kNoDexOptNeeded, oat_file_assistant.GetDexOptNeeded());
655
656 EXPECT_FALSE(oat_file_assistant.IsInBootClassPath());
657 EXPECT_FALSE(oat_file_assistant.OdexFileExists());
658 EXPECT_TRUE(oat_file_assistant.OdexFileIsOutOfDate());
659 EXPECT_FALSE(oat_file_assistant.OdexFileNeedsRelocation());
660 EXPECT_FALSE(oat_file_assistant.OdexFileIsUpToDate());
661 EXPECT_FALSE(oat_file_assistant.OatFileExists());
662 EXPECT_TRUE(oat_file_assistant.OatFileIsOutOfDate());
663 EXPECT_FALSE(oat_file_assistant.OatFileIsUpToDate());
664 EXPECT_FALSE(oat_file_assistant.HasOriginalDexFiles());
665}
666
Richard Uhler95abd042015-03-24 09:51:28 -0700667// Case: We have a DEX file, no ODEX file and an OAT file that needs
668// relocation.
669// Expect: The status is kSelfPatchOatNeeded.
670TEST_F(OatFileAssistantTest, SelfRelocation) {
671 std::string dex_location = GetScratchDir() + "/SelfRelocation.jar";
672 std::string oat_location = GetOdexDir() + "/SelfRelocation.oat";
673
674 // Create the dex and odex files
675 Copy(GetDexSrc1(), dex_location);
676 GenerateOdexForTest(dex_location, oat_location);
677
678 OatFileAssistant oat_file_assistant(dex_location.c_str(),
679 oat_location.c_str(), kRuntimeISA, true);
680
681 EXPECT_EQ(OatFileAssistant::kSelfPatchOatNeeded, oat_file_assistant.GetDexOptNeeded());
682
683 EXPECT_FALSE(oat_file_assistant.IsInBootClassPath());
684 EXPECT_FALSE(oat_file_assistant.OdexFileExists());
685 EXPECT_TRUE(oat_file_assistant.OdexFileIsOutOfDate());
686 EXPECT_FALSE(oat_file_assistant.OdexFileNeedsRelocation());
687 EXPECT_FALSE(oat_file_assistant.OdexFileIsUpToDate());
688 EXPECT_TRUE(oat_file_assistant.OatFileExists());
689 EXPECT_TRUE(oat_file_assistant.OatFileNeedsRelocation());
690 EXPECT_FALSE(oat_file_assistant.OatFileIsOutOfDate());
691 EXPECT_FALSE(oat_file_assistant.OatFileIsUpToDate());
Richard Uhler9b994ea2015-06-24 08:44:19 -0700692 EXPECT_TRUE(oat_file_assistant.HasOriginalDexFiles());
Richard Uhler95abd042015-03-24 09:51:28 -0700693
694 // Make the oat file up to date.
695 std::string error_msg;
Igor Murashkinb1d8c312015-08-04 11:18:43 -0700696 ASSERT_TRUE(oat_file_assistant.MakeUpToDate(&error_msg)) << error_msg;
Richard Uhler95abd042015-03-24 09:51:28 -0700697
698 EXPECT_EQ(OatFileAssistant::kNoDexOptNeeded, oat_file_assistant.GetDexOptNeeded());
699
700 EXPECT_FALSE(oat_file_assistant.IsInBootClassPath());
701 EXPECT_FALSE(oat_file_assistant.OdexFileExists());
702 EXPECT_TRUE(oat_file_assistant.OdexFileIsOutOfDate());
703 EXPECT_FALSE(oat_file_assistant.OdexFileNeedsRelocation());
704 EXPECT_FALSE(oat_file_assistant.OdexFileIsUpToDate());
705 EXPECT_TRUE(oat_file_assistant.OatFileExists());
706 EXPECT_FALSE(oat_file_assistant.OatFileIsOutOfDate());
707 EXPECT_FALSE(oat_file_assistant.OatFileNeedsRelocation());
708 EXPECT_TRUE(oat_file_assistant.OatFileIsUpToDate());
Richard Uhler9b994ea2015-06-24 08:44:19 -0700709 EXPECT_TRUE(oat_file_assistant.HasOriginalDexFiles());
Richard Uhler95abd042015-03-24 09:51:28 -0700710
711 std::unique_ptr<OatFile> oat_file = oat_file_assistant.GetBestOatFile();
712 ASSERT_TRUE(oat_file.get() != nullptr);
713 EXPECT_TRUE(oat_file->IsExecutable());
714 std::vector<std::unique_ptr<const DexFile>> dex_files;
715 dex_files = oat_file_assistant.LoadDexFiles(*oat_file, dex_location.c_str());
716 EXPECT_EQ(1u, dex_files.size());
717}
718
Richard Uhler66d874d2015-01-15 09:37:19 -0800719// Case: We have a DEX file, an ODEX file and an OAT file, where the ODEX and
720// OAT files both have patch delta of 0.
Richard Uhler95abd042015-03-24 09:51:28 -0700721// Expect: It shouldn't crash, and status is kPatchOatNeeded.
Richard Uhler66d874d2015-01-15 09:37:19 -0800722TEST_F(OatFileAssistantTest, OdexOatOverlap) {
723 std::string dex_location = GetScratchDir() + "/OdexOatOverlap.jar";
Richard Uhler63434112015-03-16 14:32:16 -0700724 std::string odex_location = GetOdexDir() + "/OdexOatOverlap.odex";
725 std::string oat_location = GetOdexDir() + "/OdexOatOverlap.oat";
Richard Uhler66d874d2015-01-15 09:37:19 -0800726
727 // Create the dex and odex files
728 Copy(GetDexSrc1(), dex_location);
729 GenerateOdexForTest(dex_location, odex_location);
730
731 // Create the oat file by copying the odex so they are located in the same
732 // place in memory.
733 Copy(odex_location, oat_location);
734
735 // Verify things don't go bad.
736 OatFileAssistant oat_file_assistant(dex_location.c_str(),
737 oat_location.c_str(), kRuntimeISA, true);
738
Richard Uhler95abd042015-03-24 09:51:28 -0700739 EXPECT_EQ(OatFileAssistant::kPatchOatNeeded, oat_file_assistant.GetDexOptNeeded());
Richard Uhler66d874d2015-01-15 09:37:19 -0800740
741 EXPECT_FALSE(oat_file_assistant.IsInBootClassPath());
742 EXPECT_TRUE(oat_file_assistant.OdexFileExists());
743 EXPECT_FALSE(oat_file_assistant.OdexFileIsOutOfDate());
744 EXPECT_FALSE(oat_file_assistant.OdexFileIsUpToDate());
745 EXPECT_TRUE(oat_file_assistant.OatFileExists());
746 EXPECT_FALSE(oat_file_assistant.OatFileIsOutOfDate());
747 EXPECT_FALSE(oat_file_assistant.OatFileIsUpToDate());
Richard Uhler9b994ea2015-06-24 08:44:19 -0700748 EXPECT_TRUE(oat_file_assistant.HasOriginalDexFiles());
Richard Uhler66d874d2015-01-15 09:37:19 -0800749
750 // Things aren't relocated, so it should fall back to interpreted.
751 std::unique_ptr<OatFile> oat_file = oat_file_assistant.GetBestOatFile();
752 ASSERT_TRUE(oat_file.get() != nullptr);
Richard Uhlerf16d5722015-05-11 09:32:47 -0700753
Richard Uhler66d874d2015-01-15 09:37:19 -0800754 EXPECT_FALSE(oat_file->IsExecutable());
755 std::vector<std::unique_ptr<const DexFile>> dex_files;
756 dex_files = oat_file_assistant.LoadDexFiles(*oat_file, dex_location.c_str());
757 EXPECT_EQ(1u, dex_files.size());
758}
759
760// Case: We have a DEX file and a PIC ODEX file, but no OAT file.
Richard Uhler95abd042015-03-24 09:51:28 -0700761// Expect: The status is kNoDexOptNeeded, because PIC needs no relocation.
Richard Uhler66d874d2015-01-15 09:37:19 -0800762TEST_F(OatFileAssistantTest, DexPicOdexNoOat) {
763 std::string dex_location = GetScratchDir() + "/DexPicOdexNoOat.jar";
Richard Uhler63434112015-03-16 14:32:16 -0700764 std::string odex_location = GetOdexDir() + "/DexPicOdexNoOat.odex";
Richard Uhler66d874d2015-01-15 09:37:19 -0800765
766 // Create the dex and odex files
767 Copy(GetDexSrc1(), dex_location);
768 GeneratePicOdexForTest(dex_location, odex_location);
769
770 // Verify the status.
771 OatFileAssistant oat_file_assistant(dex_location.c_str(), kRuntimeISA, false);
772
Richard Uhler95abd042015-03-24 09:51:28 -0700773 EXPECT_EQ(OatFileAssistant::kNoDexOptNeeded, oat_file_assistant.GetDexOptNeeded());
Richard Uhler66d874d2015-01-15 09:37:19 -0800774
775 EXPECT_FALSE(oat_file_assistant.IsInBootClassPath());
776 EXPECT_TRUE(oat_file_assistant.OdexFileExists());
777 EXPECT_FALSE(oat_file_assistant.OdexFileIsOutOfDate());
778 EXPECT_TRUE(oat_file_assistant.OdexFileIsUpToDate());
779 EXPECT_FALSE(oat_file_assistant.OatFileExists());
780 EXPECT_TRUE(oat_file_assistant.OatFileIsOutOfDate());
781 EXPECT_FALSE(oat_file_assistant.OatFileIsUpToDate());
Richard Uhler9b994ea2015-06-24 08:44:19 -0700782 EXPECT_TRUE(oat_file_assistant.HasOriginalDexFiles());
Richard Uhler66d874d2015-01-15 09:37:19 -0800783}
784
785// Case: We have a DEX file and up-to-date OAT file for it.
786// Expect: We should load an executable dex file.
787TEST_F(OatFileAssistantTest, LoadOatUpToDate) {
788 std::string dex_location = GetScratchDir() + "/LoadOatUpToDate.jar";
789
790 Copy(GetDexSrc1(), dex_location);
791 GenerateOatForTest(dex_location.c_str());
792
793 // Load the oat using an oat file assistant.
794 OatFileAssistant oat_file_assistant(dex_location.c_str(), kRuntimeISA, true);
795
796 std::unique_ptr<OatFile> oat_file = oat_file_assistant.GetBestOatFile();
797 ASSERT_TRUE(oat_file.get() != nullptr);
798 EXPECT_TRUE(oat_file->IsExecutable());
799 std::vector<std::unique_ptr<const DexFile>> dex_files;
800 dex_files = oat_file_assistant.LoadDexFiles(*oat_file, dex_location.c_str());
801 EXPECT_EQ(1u, dex_files.size());
802}
803
804// Case: We have a DEX file and up-to-date OAT file for it.
805// Expect: Loading non-executable should load the oat non-executable.
806TEST_F(OatFileAssistantTest, LoadNoExecOatUpToDate) {
807 std::string dex_location = GetScratchDir() + "/LoadNoExecOatUpToDate.jar";
808
809 Copy(GetDexSrc1(), dex_location);
810 GenerateOatForTest(dex_location.c_str());
811
812 // Load the oat using an oat file assistant.
813 OatFileAssistant oat_file_assistant(dex_location.c_str(), kRuntimeISA, false);
814
815 std::unique_ptr<OatFile> oat_file = oat_file_assistant.GetBestOatFile();
816 ASSERT_TRUE(oat_file.get() != nullptr);
817 EXPECT_FALSE(oat_file->IsExecutable());
818 std::vector<std::unique_ptr<const DexFile>> dex_files;
819 dex_files = oat_file_assistant.LoadDexFiles(*oat_file, dex_location.c_str());
820 EXPECT_EQ(1u, dex_files.size());
821}
822
823// Case: We have a DEX file.
824// Expect: We should load an executable dex file from an alternative oat
825// location.
826TEST_F(OatFileAssistantTest, LoadDexNoAlternateOat) {
827 std::string dex_location = GetScratchDir() + "/LoadDexNoAlternateOat.jar";
828 std::string oat_location = GetScratchDir() + "/LoadDexNoAlternateOat.oat";
829
830 Copy(GetDexSrc1(), dex_location);
831
832 OatFileAssistant oat_file_assistant(
833 dex_location.c_str(), oat_location.c_str(), kRuntimeISA, true);
834 std::string error_msg;
Igor Murashkinb1d8c312015-08-04 11:18:43 -0700835 ASSERT_TRUE(oat_file_assistant.MakeUpToDate(&error_msg)) << error_msg;
Richard Uhler66d874d2015-01-15 09:37:19 -0800836
837 std::unique_ptr<OatFile> oat_file = oat_file_assistant.GetBestOatFile();
838 ASSERT_TRUE(oat_file.get() != nullptr);
839 EXPECT_TRUE(oat_file->IsExecutable());
840 std::vector<std::unique_ptr<const DexFile>> dex_files;
841 dex_files = oat_file_assistant.LoadDexFiles(*oat_file, dex_location.c_str());
842 EXPECT_EQ(1u, dex_files.size());
843
844 EXPECT_TRUE(OS::FileExists(oat_location.c_str()));
845
846 // Verify it didn't create an oat in the default location.
847 OatFileAssistant ofm(dex_location.c_str(), kRuntimeISA, false);
848 EXPECT_FALSE(ofm.OatFileExists());
849}
850
Richard Uhler66d874d2015-01-15 09:37:19 -0800851// Turn an absolute path into a path relative to the current working
852// directory.
853static std::string MakePathRelative(std::string target) {
854 char buf[MAXPATHLEN];
855 std::string cwd = getcwd(buf, MAXPATHLEN);
856
857 // Split the target and cwd paths into components.
858 std::vector<std::string> target_path;
859 std::vector<std::string> cwd_path;
860 Split(target, '/', &target_path);
861 Split(cwd, '/', &cwd_path);
862
863 // Reverse the path components, so we can use pop_back().
864 std::reverse(target_path.begin(), target_path.end());
865 std::reverse(cwd_path.begin(), cwd_path.end());
866
867 // Drop the common prefix of the paths. Because we reversed the path
868 // components, this becomes the common suffix of target_path and cwd_path.
869 while (!target_path.empty() && !cwd_path.empty()
870 && target_path.back() == cwd_path.back()) {
871 target_path.pop_back();
872 cwd_path.pop_back();
873 }
874
875 // For each element of the remaining cwd_path, add '..' to the beginning
876 // of the target path. Because we reversed the path components, we add to
877 // the end of target_path.
878 for (unsigned int i = 0; i < cwd_path.size(); i++) {
879 target_path.push_back("..");
880 }
881
882 // Reverse again to get the right path order, and join to get the result.
883 std::reverse(target_path.begin(), target_path.end());
884 return Join(target_path, '/');
885}
886
887// Case: Non-absolute path to Dex location.
888// Expect: Not sure, but it shouldn't crash.
889TEST_F(OatFileAssistantTest, NonAbsoluteDexLocation) {
890 std::string abs_dex_location = GetScratchDir() + "/NonAbsoluteDexLocation.jar";
891 Copy(GetDexSrc1(), abs_dex_location);
892
893 std::string dex_location = MakePathRelative(abs_dex_location);
894 OatFileAssistant oat_file_assistant(dex_location.c_str(), kRuntimeISA, true);
895
896 EXPECT_FALSE(oat_file_assistant.IsInBootClassPath());
Richard Uhler95abd042015-03-24 09:51:28 -0700897 EXPECT_EQ(OatFileAssistant::kDex2OatNeeded, oat_file_assistant.GetDexOptNeeded());
Richard Uhler66d874d2015-01-15 09:37:19 -0800898 EXPECT_FALSE(oat_file_assistant.OdexFileExists());
899 EXPECT_FALSE(oat_file_assistant.OatFileExists());
900 EXPECT_TRUE(oat_file_assistant.OdexFileIsOutOfDate());
901 EXPECT_FALSE(oat_file_assistant.OdexFileIsUpToDate());
902 EXPECT_TRUE(oat_file_assistant.OatFileIsOutOfDate());
903 EXPECT_FALSE(oat_file_assistant.OatFileIsUpToDate());
904}
905
906// Case: Very short, non-existent Dex location.
Richard Uhler9b994ea2015-06-24 08:44:19 -0700907// Expect: kNoDexOptNeeded.
Richard Uhler66d874d2015-01-15 09:37:19 -0800908TEST_F(OatFileAssistantTest, ShortDexLocation) {
909 std::string dex_location = "/xx";
910
911 OatFileAssistant oat_file_assistant(dex_location.c_str(), kRuntimeISA, true);
912
913 EXPECT_FALSE(oat_file_assistant.IsInBootClassPath());
Richard Uhler9b994ea2015-06-24 08:44:19 -0700914 EXPECT_EQ(OatFileAssistant::kNoDexOptNeeded, oat_file_assistant.GetDexOptNeeded());
Richard Uhler66d874d2015-01-15 09:37:19 -0800915 EXPECT_FALSE(oat_file_assistant.OdexFileExists());
916 EXPECT_FALSE(oat_file_assistant.OatFileExists());
917 EXPECT_TRUE(oat_file_assistant.OdexFileIsOutOfDate());
918 EXPECT_FALSE(oat_file_assistant.OdexFileIsUpToDate());
919 EXPECT_TRUE(oat_file_assistant.OatFileIsOutOfDate());
920 EXPECT_FALSE(oat_file_assistant.OatFileIsUpToDate());
Richard Uhler9b994ea2015-06-24 08:44:19 -0700921 EXPECT_FALSE(oat_file_assistant.HasOriginalDexFiles());
Richard Uhler66d874d2015-01-15 09:37:19 -0800922
Richard Uhler9b994ea2015-06-24 08:44:19 -0700923 // Trying to make it up to date should have no effect.
Richard Uhler66d874d2015-01-15 09:37:19 -0800924 std::string error_msg;
Igor Murashkinb1d8c312015-08-04 11:18:43 -0700925 EXPECT_TRUE(oat_file_assistant.MakeUpToDate(&error_msg));
Richard Uhler9b994ea2015-06-24 08:44:19 -0700926 EXPECT_TRUE(error_msg.empty());
Richard Uhler66d874d2015-01-15 09:37:19 -0800927}
928
929// Case: Non-standard extension for dex file.
Richard Uhler95abd042015-03-24 09:51:28 -0700930// Expect: The status is kDex2OatNeeded.
Richard Uhler66d874d2015-01-15 09:37:19 -0800931TEST_F(OatFileAssistantTest, LongDexExtension) {
932 std::string dex_location = GetScratchDir() + "/LongDexExtension.jarx";
933 Copy(GetDexSrc1(), dex_location);
934
935 OatFileAssistant oat_file_assistant(dex_location.c_str(), kRuntimeISA, false);
936
Richard Uhler95abd042015-03-24 09:51:28 -0700937 EXPECT_EQ(OatFileAssistant::kDex2OatNeeded, oat_file_assistant.GetDexOptNeeded());
Richard Uhler66d874d2015-01-15 09:37:19 -0800938
939 EXPECT_FALSE(oat_file_assistant.IsInBootClassPath());
940 EXPECT_FALSE(oat_file_assistant.OdexFileExists());
941 EXPECT_TRUE(oat_file_assistant.OdexFileIsOutOfDate());
942 EXPECT_FALSE(oat_file_assistant.OdexFileIsUpToDate());
943 EXPECT_FALSE(oat_file_assistant.OatFileExists());
944 EXPECT_TRUE(oat_file_assistant.OatFileIsOutOfDate());
945 EXPECT_FALSE(oat_file_assistant.OatFileIsUpToDate());
946}
947
948// A task to generate a dex location. Used by the RaceToGenerate test.
949class RaceGenerateTask : public Task {
950 public:
951 explicit RaceGenerateTask(const std::string& dex_location, const std::string& oat_location)
952 : dex_location_(dex_location), oat_location_(oat_location),
953 loaded_oat_file_(nullptr)
954 {}
955
956 void Run(Thread* self) {
957 UNUSED(self);
958
959 // Load the dex files, and save a pointer to the loaded oat file, so that
960 // we can verify only one oat file was loaded for the dex location.
961 ClassLinker* linker = Runtime::Current()->GetClassLinker();
962 std::vector<std::unique_ptr<const DexFile>> dex_files;
963 std::vector<std::string> error_msgs;
Igor Murashkinb1d8c312015-08-04 11:18:43 -0700964 dex_files = linker->OpenDexFilesFromOat(dex_location_.c_str(), oat_location_.c_str(), &error_msgs);
Richard Uhler66d874d2015-01-15 09:37:19 -0800965 CHECK(!dex_files.empty()) << Join(error_msgs, '\n');
Richard Uhler07b3c232015-03-31 15:57:54 -0700966 CHECK(dex_files[0]->GetOatDexFile() != nullptr) << dex_files[0]->GetLocation();
967 loaded_oat_file_ = dex_files[0]->GetOatDexFile()->GetOatFile();
Richard Uhler66d874d2015-01-15 09:37:19 -0800968 }
969
970 const OatFile* GetLoadedOatFile() const {
971 return loaded_oat_file_;
972 }
973
974 private:
975 std::string dex_location_;
976 std::string oat_location_;
977 const OatFile* loaded_oat_file_;
978};
979
980// Test the case where multiple processes race to generate an oat file.
981// This simulates multiple processes using multiple threads.
982//
983// We want only one Oat file to be loaded when there is a race to load, to
984// avoid using up the virtual memory address space.
985TEST_F(OatFileAssistantTest, RaceToGenerate) {
986 std::string dex_location = GetScratchDir() + "/RaceToGenerate.jar";
Richard Uhler63434112015-03-16 14:32:16 -0700987 std::string oat_location = GetOdexDir() + "/RaceToGenerate.oat";
Richard Uhler66d874d2015-01-15 09:37:19 -0800988
989 // We use the lib core dex file, because it's large, and hopefully should
990 // take a while to generate.
991 Copy(GetLibCoreDexFileName(), dex_location);
992
993 const int kNumThreads = 32;
994 Thread* self = Thread::Current();
995 ThreadPool thread_pool("Oat file assistant test thread pool", kNumThreads);
996 std::vector<std::unique_ptr<RaceGenerateTask>> tasks;
997 for (int i = 0; i < kNumThreads; i++) {
998 std::unique_ptr<RaceGenerateTask> task(new RaceGenerateTask(dex_location, oat_location));
999 thread_pool.AddTask(self, task.get());
1000 tasks.push_back(std::move(task));
1001 }
1002 thread_pool.StartWorkers(self);
1003 thread_pool.Wait(self, true, false);
1004
1005 // Verify every task got the same pointer.
1006 const OatFile* expected = tasks[0]->GetLoadedOatFile();
1007 for (auto& task : tasks) {
1008 EXPECT_EQ(expected, task->GetLoadedOatFile());
1009 }
1010}
1011
1012// Case: We have a DEX file and an ODEX file, no OAT file, and dex2oat is
1013// disabled.
1014// Expect: We should load the odex file non-executable.
1015TEST_F(OatFileAssistantNoDex2OatTest, LoadDexOdexNoOat) {
1016 std::string dex_location = GetScratchDir() + "/LoadDexOdexNoOat.jar";
Richard Uhler63434112015-03-16 14:32:16 -07001017 std::string odex_location = GetOdexDir() + "/LoadDexOdexNoOat.odex";
Richard Uhler66d874d2015-01-15 09:37:19 -08001018
1019 // Create the dex and odex files
1020 Copy(GetDexSrc1(), dex_location);
1021 GenerateOdexForTest(dex_location, odex_location);
1022
1023 // Load the oat using an executable oat file assistant.
1024 OatFileAssistant oat_file_assistant(dex_location.c_str(), kRuntimeISA, true);
1025
1026 std::unique_ptr<OatFile> oat_file = oat_file_assistant.GetBestOatFile();
1027 ASSERT_TRUE(oat_file.get() != nullptr);
1028 EXPECT_FALSE(oat_file->IsExecutable());
1029 std::vector<std::unique_ptr<const DexFile>> dex_files;
1030 dex_files = oat_file_assistant.LoadDexFiles(*oat_file, dex_location.c_str());
1031 EXPECT_EQ(1u, dex_files.size());
1032}
1033
1034// Case: We have a MultiDEX file and an ODEX file, no OAT file, and dex2oat is
1035// disabled.
1036// Expect: We should load the odex file non-executable.
1037TEST_F(OatFileAssistantNoDex2OatTest, LoadMultiDexOdexNoOat) {
1038 std::string dex_location = GetScratchDir() + "/LoadMultiDexOdexNoOat.jar";
Richard Uhler63434112015-03-16 14:32:16 -07001039 std::string odex_location = GetOdexDir() + "/LoadMultiDexOdexNoOat.odex";
Richard Uhler66d874d2015-01-15 09:37:19 -08001040
1041 // Create the dex and odex files
1042 Copy(GetMultiDexSrc1(), dex_location);
1043 GenerateOdexForTest(dex_location, odex_location);
1044
1045 // Load the oat using an executable oat file assistant.
1046 OatFileAssistant oat_file_assistant(dex_location.c_str(), kRuntimeISA, true);
1047
1048 std::unique_ptr<OatFile> oat_file = oat_file_assistant.GetBestOatFile();
1049 ASSERT_TRUE(oat_file.get() != nullptr);
1050 EXPECT_FALSE(oat_file->IsExecutable());
1051 std::vector<std::unique_ptr<const DexFile>> dex_files;
1052 dex_files = oat_file_assistant.LoadDexFiles(*oat_file, dex_location.c_str());
1053 EXPECT_EQ(2u, dex_files.size());
1054}
1055
1056TEST(OatFileAssistantUtilsTest, DexFilenameToOdexFilename) {
1057 std::string error_msg;
1058 std::string odex_file;
1059
1060 EXPECT_TRUE(OatFileAssistant::DexFilenameToOdexFilename(
Igor Murashkinb1d8c312015-08-04 11:18:43 -07001061 "/foo/bar/baz.jar", kArm, &odex_file, &error_msg)) << error_msg;
Richard Uhler63434112015-03-16 14:32:16 -07001062 EXPECT_EQ("/foo/bar/oat/arm/baz.odex", odex_file);
Richard Uhler66d874d2015-01-15 09:37:19 -08001063
1064 EXPECT_TRUE(OatFileAssistant::DexFilenameToOdexFilename(
Igor Murashkinb1d8c312015-08-04 11:18:43 -07001065 "/foo/bar/baz.funnyext", kArm, &odex_file, &error_msg)) << error_msg;
Richard Uhler63434112015-03-16 14:32:16 -07001066 EXPECT_EQ("/foo/bar/oat/arm/baz.odex", odex_file);
Richard Uhler66d874d2015-01-15 09:37:19 -08001067
1068 EXPECT_FALSE(OatFileAssistant::DexFilenameToOdexFilename(
Igor Murashkinb1d8c312015-08-04 11:18:43 -07001069 "nopath.jar", kArm, &odex_file, &error_msg));
Richard Uhler66d874d2015-01-15 09:37:19 -08001070 EXPECT_FALSE(OatFileAssistant::DexFilenameToOdexFilename(
Igor Murashkinb1d8c312015-08-04 11:18:43 -07001071 "/foo/bar/baz_noext", kArm, &odex_file, &error_msg));
Richard Uhler66d874d2015-01-15 09:37:19 -08001072}
1073
Richard Uhler23cedd22015-04-08 13:17:29 -07001074// Verify the dexopt status values from dalvik.system.DexFile
1075// match the OatFileAssistant::DexOptStatus values.
1076TEST_F(OatFileAssistantTest, DexOptStatusValues) {
1077 ScopedObjectAccess soa(Thread::Current());
1078 StackHandleScope<1> hs(soa.Self());
1079 ClassLinker* linker = Runtime::Current()->GetClassLinker();
1080 Handle<mirror::Class> dexfile(
1081 hs.NewHandle(linker->FindSystemClass(soa.Self(), "Ldalvik/system/DexFile;")));
1082 ASSERT_FALSE(dexfile.Get() == nullptr);
1083 linker->EnsureInitialized(soa.Self(), dexfile, true, true);
1084
Mathieu Chartierc7853442015-03-27 14:35:38 -07001085 ArtField* no_dexopt_needed = mirror::Class::FindStaticField(
Richard Uhler23cedd22015-04-08 13:17:29 -07001086 soa.Self(), dexfile, "NO_DEXOPT_NEEDED", "I");
1087 ASSERT_FALSE(no_dexopt_needed == nullptr);
1088 EXPECT_EQ(no_dexopt_needed->GetTypeAsPrimitiveType(), Primitive::kPrimInt);
1089 EXPECT_EQ(OatFileAssistant::kNoDexOptNeeded, no_dexopt_needed->GetInt(dexfile.Get()));
1090
Mathieu Chartierc7853442015-03-27 14:35:38 -07001091 ArtField* dex2oat_needed = mirror::Class::FindStaticField(
Richard Uhler23cedd22015-04-08 13:17:29 -07001092 soa.Self(), dexfile, "DEX2OAT_NEEDED", "I");
1093 ASSERT_FALSE(dex2oat_needed == nullptr);
1094 EXPECT_EQ(dex2oat_needed->GetTypeAsPrimitiveType(), Primitive::kPrimInt);
1095 EXPECT_EQ(OatFileAssistant::kDex2OatNeeded, dex2oat_needed->GetInt(dexfile.Get()));
1096
Mathieu Chartierc7853442015-03-27 14:35:38 -07001097 ArtField* patchoat_needed = mirror::Class::FindStaticField(
Richard Uhler23cedd22015-04-08 13:17:29 -07001098 soa.Self(), dexfile, "PATCHOAT_NEEDED", "I");
1099 ASSERT_FALSE(patchoat_needed == nullptr);
1100 EXPECT_EQ(patchoat_needed->GetTypeAsPrimitiveType(), Primitive::kPrimInt);
1101 EXPECT_EQ(OatFileAssistant::kPatchOatNeeded, patchoat_needed->GetInt(dexfile.Get()));
1102
Mathieu Chartierc7853442015-03-27 14:35:38 -07001103 ArtField* self_patchoat_needed = mirror::Class::FindStaticField(
Richard Uhler23cedd22015-04-08 13:17:29 -07001104 soa.Self(), dexfile, "SELF_PATCHOAT_NEEDED", "I");
1105 ASSERT_FALSE(self_patchoat_needed == nullptr);
1106 EXPECT_EQ(self_patchoat_needed->GetTypeAsPrimitiveType(), Primitive::kPrimInt);
1107 EXPECT_EQ(OatFileAssistant::kSelfPatchOatNeeded, self_patchoat_needed->GetInt(dexfile.Get()));
1108}
Richard Uhler66d874d2015-01-15 09:37:19 -08001109
1110// TODO: More Tests:
1111// * Test class linker falls back to unquickened dex for DexNoOat
1112// * Test class linker falls back to unquickened dex for MultiDexNoOat
Richard Uhler66d874d2015-01-15 09:37:19 -08001113// * Test using secondary isa
1114// * Test with profiling info?
1115// * Test for status of oat while oat is being generated (how?)
1116// * Test case where 32 and 64 bit boot class paths differ,
1117// and we ask IsInBootClassPath for a class in exactly one of the 32 or
1118// 64 bit boot class paths.
1119// * Test unexpected scenarios (?):
1120// - Dex is stripped, don't have odex.
1121// - Oat file corrupted after status check, before reload unexecutable
1122// because it's unrelocated and no dex2oat
1123
1124} // namespace art