Fix input cdex -> output non-cdex
Previously there was a bug where the shared data section would not
get copied over. Fixed this by copying it over.
Added regression test.
Test: test-art-host-gtest
Bug: 73105322
Bug: 73059081
Bug: 73059886
Bug: 73058502
Bug: 73058759
Bug: 63756964
Change-Id: I0efd4272cfaae604ea955c3548f5a054b243ec68
diff --git a/dex2oat/dex2oat_test.cc b/dex2oat/dex2oat_test.cc
index d0b0d49..1ed31d1 100644
--- a/dex2oat/dex2oat_test.cc
+++ b/dex2oat/dex2oat_test.cc
@@ -796,7 +796,7 @@
app_image_file_name,
/* use_fd */ true,
/* num_profile_classes */ 1,
- { input_vdex, output_vdex, kDisableCompactDex },
+ { input_vdex, output_vdex },
/* expect_success */ true);
EXPECT_GT(vdex_file2.GetFile()->GetLength(), 0u);
}
@@ -926,6 +926,49 @@
ASSERT_TRUE(success_);
}
+ void RunUnquickenMultiDexCDex() {
+ std::string dex_location = GetScratchDir() + "/UnquickenMultiDex.jar";
+ std::string odex_location = GetOdexDir() + "/UnquickenMultiDex.odex";
+ std::string odex_location2 = GetOdexDir() + "/UnquickenMultiDex2.odex";
+ std::string vdex_location = GetOdexDir() + "/UnquickenMultiDex.vdex";
+ std::string vdex_location2 = GetOdexDir() + "/UnquickenMultiDex2.vdex";
+ Copy(GetTestDexFileName("MultiDex"), dex_location);
+
+ std::unique_ptr<File> vdex_file1(OS::CreateEmptyFile(vdex_location.c_str()));
+ std::unique_ptr<File> vdex_file2(OS::CreateEmptyFile(vdex_location2.c_str()));
+ CHECK(vdex_file1 != nullptr) << vdex_location;
+ CHECK(vdex_file2 != nullptr) << vdex_location2;
+
+ // Quicken the dex file into a vdex file.
+ {
+ std::string input_vdex = "--input-vdex-fd=-1";
+ std::string output_vdex = StringPrintf("--output-vdex-fd=%d", vdex_file1->Fd());
+ GenerateOdexForTest(dex_location,
+ odex_location,
+ CompilerFilter::kQuicken,
+ { input_vdex, output_vdex, "--compact-dex-level=fast"},
+ /* expect_success */ true,
+ /* use_fd */ true);
+ EXPECT_GT(vdex_file1->GetLength(), 0u);
+ }
+
+ // Unquicken by running the verify compiler filter on the vdex file.
+ {
+ std::string input_vdex = StringPrintf("--input-vdex-fd=%d", vdex_file1->Fd());
+ std::string output_vdex = StringPrintf("--output-vdex-fd=%d", vdex_file2->Fd());
+ GenerateOdexForTest(dex_location,
+ odex_location2,
+ CompilerFilter::kVerify,
+ { input_vdex, output_vdex, "--compact-dex-level=none"},
+ /* expect_success */ true,
+ /* use_fd */ true);
+ }
+ ASSERT_EQ(vdex_file1->FlushCloseOrErase(), 0) << "Could not flush and close vdex file";
+ ASSERT_EQ(vdex_file2->FlushCloseOrErase(), 0) << "Could not flush and close vdex file";
+ CheckResult(dex_location, odex_location2);
+ ASSERT_TRUE(success_);
+ }
+
void CheckResult(const std::string& dex_location, const std::string& odex_location) {
std::string error_msg;
std::unique_ptr<OatFile> odex_file(OatFile::Open(odex_location.c_str(),
@@ -966,6 +1009,10 @@
RunUnquickenMultiDex();
}
+TEST_F(Dex2oatUnquickenTest, UnquickenMultiDexCDex) {
+ RunUnquickenMultiDexCDex();
+}
+
class Dex2oatWatchdogTest : public Dex2oatTest {
protected:
void RunTest(bool expect_success, const std::vector<std::string>& extra_args = {}) {