summaryrefslogtreecommitdiff
path: root/runtime/oat_file_assistant_test.cc
diff options
context:
space:
mode:
author Vladimir Marko <vmarko@google.com> 2018-12-21 16:38:47 +0000
committer Nicolas Geoffray <ngeoffray@google.com> 2019-01-16 13:51:03 +0000
commitf3d88a8a16245f4561ea7e920f1f84690a07411c (patch)
treef4fe7356dd22404a7f1b663f30970e318d7b3d5d /runtime/oat_file_assistant_test.cc
parentc7d1ef1d424e632d2fcfdfef35d6c694e29adb09 (diff)
Support oat files compiled with partial boot class path.
Test: oat_file_assistant_test Bug: 119868597 Bug: 122937705 Change-Id: I07c59957983c0ec61ade5215bb83c41e7cb4b672
Diffstat (limited to 'runtime/oat_file_assistant_test.cc')
-rw-r--r--runtime/oat_file_assistant_test.cc55
1 files changed, 48 insertions, 7 deletions
diff --git a/runtime/oat_file_assistant_test.cc b/runtime/oat_file_assistant_test.cc
index 521e419d2f..a99bd51457 100644
--- a/runtime/oat_file_assistant_test.cc
+++ b/runtime/oat_file_assistant_test.cc
@@ -61,6 +61,14 @@ class OatFileAssistantTest : public DexoptTest {
VerifyOptimizationStatus(
file, CompilerFilter::NameOfFilter(expected_filter), expected_reason);
}
+ void InsertNewBootClasspathEntry() {
+ std::string extra_dex_filename = GetMultiDexSrc1();
+ Runtime* runtime = Runtime::Current();
+ runtime->boot_class_path_.push_back(extra_dex_filename);
+ if (!runtime->boot_class_path_locations_.empty()) {
+ runtime->boot_class_path_locations_.push_back(extra_dex_filename);
+ }
+ }
};
class ScopedNonWritable {
@@ -236,17 +244,50 @@ TEST_F(OatFileAssistantTest, OdexUpToDate) {
Copy(GetDexSrc1(), dex_location);
GenerateOdexForTest(dex_location, odex_location, CompilerFilter::kSpeed, "install");
- // For the use of oat location by making the dex parent not writable.
- OatFileAssistant oat_file_assistant(dex_location.c_str(), kRuntimeISA, false);
+ // Force the use of oat location by making the dex parent not writable.
+ OatFileAssistant oat_file_assistant(
+ dex_location.c_str(), kRuntimeISA, /*load_executable=*/ false);
EXPECT_EQ(-OatFileAssistant::kNoDexOptNeeded,
- oat_file_assistant.GetDexOptNeeded(CompilerFilter::kSpeed));
+ oat_file_assistant.GetDexOptNeeded(CompilerFilter::kSpeed));
EXPECT_EQ(-OatFileAssistant::kNoDexOptNeeded,
- oat_file_assistant.GetDexOptNeeded(CompilerFilter::kQuicken));
+ oat_file_assistant.GetDexOptNeeded(CompilerFilter::kQuicken));
EXPECT_EQ(-OatFileAssistant::kNoDexOptNeeded,
- oat_file_assistant.GetDexOptNeeded(CompilerFilter::kExtract));
+ oat_file_assistant.GetDexOptNeeded(CompilerFilter::kExtract));
EXPECT_EQ(-OatFileAssistant::kDex2OatForFilter,
- oat_file_assistant.GetDexOptNeeded(CompilerFilter::kEverything));
+ oat_file_assistant.GetDexOptNeeded(CompilerFilter::kEverything));
+
+ EXPECT_FALSE(oat_file_assistant.IsInBootClassPath());
+ EXPECT_EQ(OatFileAssistant::kOatUpToDate, oat_file_assistant.OdexFileStatus());
+ EXPECT_EQ(OatFileAssistant::kOatCannotOpen, oat_file_assistant.OatFileStatus());
+ EXPECT_TRUE(oat_file_assistant.HasOriginalDexFiles());
+
+ VerifyOptimizationStatus(dex_location, CompilerFilter::kSpeed, "install");
+}
+
+// Case: We have an ODEX file compiled against partial boot image.
+// Expect: The status is kNoDexOptNeeded.
+TEST_F(OatFileAssistantTest, OdexUpToDatePartialBootImage) {
+ std::string dex_location = GetScratchDir() + "/OdexUpToDate.jar";
+ std::string odex_location = GetOdexDir() + "/OdexUpToDate.odex";
+ Copy(GetDexSrc1(), dex_location);
+ GenerateOdexForTest(dex_location, odex_location, CompilerFilter::kSpeed, "install");
+
+ // Insert an extra dex file to the boot class path.
+ InsertNewBootClasspathEntry();
+
+ // Force the use of oat location by making the dex parent not writable.
+ OatFileAssistant oat_file_assistant(
+ dex_location.c_str(), kRuntimeISA, /*load_executable=*/ false);
+
+ EXPECT_EQ(-OatFileAssistant::kNoDexOptNeeded,
+ oat_file_assistant.GetDexOptNeeded(CompilerFilter::kSpeed));
+ EXPECT_EQ(-OatFileAssistant::kNoDexOptNeeded,
+ oat_file_assistant.GetDexOptNeeded(CompilerFilter::kQuicken));
+ EXPECT_EQ(-OatFileAssistant::kNoDexOptNeeded,
+ oat_file_assistant.GetDexOptNeeded(CompilerFilter::kExtract));
+ EXPECT_EQ(-OatFileAssistant::kDex2OatForFilter,
+ oat_file_assistant.GetDexOptNeeded(CompilerFilter::kEverything));
EXPECT_FALSE(oat_file_assistant.IsInBootClassPath());
EXPECT_EQ(OatFileAssistant::kOatUpToDate, oat_file_assistant.OdexFileStatus());
@@ -302,7 +343,7 @@ TEST_F(OatFileAssistantTest, OatUpToDate) {
Copy(GetDexSrc1(), dex_location);
GenerateOatForTest(dex_location.c_str(), CompilerFilter::kSpeed);
- // For the use of oat location by making the dex parent not writable.
+ // Force the use of oat location by making the dex parent not writable.
ScopedNonWritable scoped_non_writable(dex_location);
ASSERT_TRUE(scoped_non_writable.IsSuccessful());