summaryrefslogtreecommitdiffstats
path: root/runtime/oat_file_assistant_test.cc
diff options
context:
space:
mode:
authorRichard Uhler <ruhler@google.com>2015-05-14 13:21:13 -0700
committerRichard Uhler <ruhler@google.com>2015-05-18 08:30:33 -0700
commit67ff7d1fd7bcaf4b6b73ecdab6011c8636562b58 (patch)
treee94fdefc21f1b6673fcdee95e9f3f61b680df8cf /runtime/oat_file_assistant_test.cc
parent2f9d1379fdebcdeeac52eaeff25ad5697c6b6ffb (diff)
downloadart-67ff7d1fd7bcaf4b6b73ecdab6011c8636562b58.tar.gz
art-67ff7d1fd7bcaf4b6b73ecdab6011c8636562b58.tar.bz2
art-67ff7d1fd7bcaf4b6b73ecdab6011c8636562b58.zip
Test and fix bug checking status of secondary multidex files.
We were accidentally returning 'false' instead of 'true' to indicate a native multidex file with an up-to-date primary dex file checksum but out-of-date secondary dex file checksum is out of date. Bug: 21022815 (cherry picked from commit a5a1c13a74225a1db3c54dc108fcd161b867bb00) Change-Id: I0cc56d2d49858a4af91ca8b05aa8bd3c17bb44be
Diffstat (limited to 'runtime/oat_file_assistant_test.cc')
-rw-r--r--runtime/oat_file_assistant_test.cc43
1 files changed, 38 insertions, 5 deletions
diff --git a/runtime/oat_file_assistant_test.cc b/runtime/oat_file_assistant_test.cc
index 865fcb063a..d8e3797ddc 100644
--- a/runtime/oat_file_assistant_test.cc
+++ b/runtime/oat_file_assistant_test.cc
@@ -67,10 +67,23 @@ class OatFileAssistantTest : public CommonRuntimeTest {
<< "Expected stripped dex file to be at: " << GetStrippedDexSrc1();
ASSERT_FALSE(DexFile::GetChecksum(GetStrippedDexSrc1().c_str(), &checksum, &error_msg))
<< "Expected stripped dex file to be stripped: " << GetStrippedDexSrc1();
- ASSERT_TRUE(OS::FileExists(GetMultiDexSrc1().c_str()))
- << "Expected multidex file to be at: " << GetMultiDexSrc1();
ASSERT_TRUE(OS::FileExists(GetDexSrc2().c_str()))
<< "Expected dex file to be at: " << GetDexSrc2();
+
+ // GetMultiDexSrc2 should have the same primary dex checksum as
+ // GetMultiDexSrc1, but a different secondary dex checksum.
+ std::vector<std::unique_ptr<const DexFile>> multi1;
+ ASSERT_TRUE(DexFile::Open(GetMultiDexSrc1().c_str(),
+ GetMultiDexSrc1().c_str(), &error_msg, &multi1)) << error_msg;
+ ASSERT_GT(multi1.size(), 1u);
+
+ std::vector<std::unique_ptr<const DexFile>> multi2;
+ ASSERT_TRUE(DexFile::Open(GetMultiDexSrc2().c_str(),
+ GetMultiDexSrc2().c_str(), &error_msg, &multi2)) << error_msg;
+ ASSERT_GT(multi2.size(), 1u);
+
+ ASSERT_EQ(multi1[0]->GetLocationChecksum(), multi2[0]->GetLocationChecksum());
+ ASSERT_NE(multi1[1]->GetLocationChecksum(), multi2[1]->GetLocationChecksum());
}
virtual void SetUpRuntimeOptions(RuntimeOptions* options) {
@@ -149,6 +162,12 @@ class OatFileAssistantTest : public CommonRuntimeTest {
return GetTestDexFileName("MultiDex");
}
+ // Returns the path to a multidex file equivalent to GetMultiDexSrc2, but
+ // with the contents of the secondary dex file changed.
+ std::string GetMultiDexSrc2() {
+ return GetTestDexFileName("MultiDexModifiedSecondary");
+ }
+
std::string GetDexSrc2() {
return GetTestDexFileName("Nested");
}
@@ -344,6 +363,23 @@ TEST_F(OatFileAssistantTest, MultiDexOatUpToDate) {
EXPECT_EQ(2u, dex_files.size());
}
+// Case: We have a MultiDEX file where the secondary dex file is out of date.
+// Expect: The status is kDex2OatNeeded.
+TEST_F(OatFileAssistantTest, MultiDexSecondaryOutOfDate) {
+ std::string dex_location = GetScratchDir() + "/MultiDexSecondaryOutOfDate.jar";
+
+ // Compile code for GetMultiDexSrc1.
+ Copy(GetMultiDexSrc1(), dex_location);
+ GenerateOatForTest(dex_location.c_str());
+
+ // Now overwrite the dex file with GetMultiDexSrc2 so the secondary checksum
+ // is out of date.
+ Copy(GetMultiDexSrc2(), dex_location);
+
+ OatFileAssistant oat_file_assistant(dex_location.c_str(), kRuntimeISA, true);
+ EXPECT_EQ(OatFileAssistant::kDex2OatNeeded, oat_file_assistant.GetDexOptNeeded());
+}
+
// Case: We have a MultiDEX file and up-to-date OAT file for it with relative
// encoded dex locations.
// Expect: The oat file status is kNoDexOptNeeded.
@@ -1001,9 +1037,6 @@ TEST_F(OatFileAssistantTest, DexOptStatusValues) {
// TODO: More Tests:
// * Test class linker falls back to unquickened dex for DexNoOat
// * Test class linker falls back to unquickened dex for MultiDexNoOat
-// * Test multidex files:
-// - Multidex with only classes2.dex out of date should have status
-// kOutOfDate
// * Test using secondary isa
// * Test with profiling info?
// * Test for status of oat while oat is being generated (how?)