Handle empty uncompressed and aligned dex file in an archive.
Return an error message for it. Callers expect it.
Test: dex2oat_test
Bug: 131175467
Change-Id: I55c05f0a9c48cea252869f88740c6338b5b28b1f
diff --git a/dex2oat/dex2oat_test.cc b/dex2oat/dex2oat_test.cc
index 758e69f..ca06b11 100644
--- a/dex2oat/dex2oat_test.cc
+++ b/dex2oat/dex2oat_test.cc
@@ -1662,6 +1662,22 @@
ASSERT_EQ(WEXITSTATUS(status), 1) << error_msg;
}
+TEST_F(Dex2oatTest, EmptyUncompressedAlignedDexTest) {
+ std::string out_dir = GetScratchDir();
+ const std::string base_oat_name = out_dir + "/base.oat";
+ std::string error_msg;
+ int status = GenerateOdexForTestWithStatus(
+ { GetTestDexFileName("MainEmptyUncompressedAligned") },
+ base_oat_name,
+ CompilerFilter::Filter::kQuicken,
+ &error_msg,
+ { },
+ /*use_fd*/ false);
+ // Expect to fail with code 1 and not SIGSEGV or SIGABRT.
+ ASSERT_TRUE(WIFEXITED(status));
+ ASSERT_EQ(WEXITSTATUS(status), 1) << error_msg;
+}
+
// Dex file that has duplicate methods have different code items and debug info.
static const char kDuplicateMethodInputDex[] =
"ZGV4CjAzOQDEy8VPdj4qHpgPYFWtLCtOykfFP4kB8tGYDAAAcAAAAHhWNBIAAAAAAAAAANALAABI"