Add test if dex file fails to open during layout.

Bug: 34971122
Test: mm test-art-host-gtest-oat_test
Change-Id: I2cdf080783aa24193026683d98caa0d98cb7d055
diff --git a/compiler/oat_test.cc b/compiler/oat_test.cc
index d5842a8..66111f6 100644
--- a/compiler/oat_test.cc
+++ b/compiler/oat_test.cc
@@ -149,11 +149,10 @@
                 File* oat_file,
                 const std::vector<const char*>& dex_filenames,
                 SafeMap<std::string, std::string>& key_value_store,
-                bool verify) {
+                bool verify,
+                ProfileCompilationInfo* profile_compilation_info) {
     TimingLogger timings("WriteElf", false, false);
-    OatWriter oat_writer(/*compiling_boot_image*/false,
-                         &timings,
-                         /*profile_compilation_info*/nullptr);
+    OatWriter oat_writer(/*compiling_boot_image*/false, &timings, profile_compilation_info);
     for (const char* dex_filename : dex_filenames) {
       if (!oat_writer.AddDexFileSource(dex_filename, dex_filename)) {
         return false;
@@ -264,7 +263,7 @@
     return true;
   }
 
-  void TestDexFileInput(bool verify, bool low_4gb);
+  void TestDexFileInput(bool verify, bool low_4gb, bool use_profile);
   void TestZipFileInput(bool verify);
 
   std::unique_ptr<const InstructionSetFeatures> insn_features_;
@@ -568,7 +567,7 @@
   }
 }
 
-void OatTest::TestDexFileInput(bool verify, bool low_4gb) {
+void OatTest::TestDexFileInput(bool verify, bool low_4gb, bool use_profile) {
   TimingLogger timings("OatTest::DexFileInput", false, false);
 
   std::vector<const char*> input_filenames;
@@ -606,11 +605,14 @@
   ScratchFile oat_file, vdex_file(oat_file, ".vdex");
   SafeMap<std::string, std::string> key_value_store;
   key_value_store.Put(OatHeader::kImageLocationKey, "test.art");
+  std::unique_ptr<ProfileCompilationInfo>
+      profile_compilation_info(use_profile ? new ProfileCompilationInfo() : nullptr);
   success = WriteElf(vdex_file.GetFile(),
                      oat_file.GetFile(),
                      input_filenames,
                      key_value_store,
-                     verify);
+                     verify,
+                     profile_compilation_info.get());
 
   // In verify mode, we expect failure.
   if (verify) {
@@ -654,15 +656,19 @@
 }
 
 TEST_F(OatTest, DexFileInputCheckOutput) {
-  TestDexFileInput(false, /*low_4gb*/false);
+  TestDexFileInput(/*verify*/false, /*low_4gb*/false, /*use_profile*/false);
 }
 
 TEST_F(OatTest, DexFileInputCheckOutputLow4GB) {
-  TestDexFileInput(false, /*low_4gb*/true);
+  TestDexFileInput(/*verify*/false, /*low_4gb*/true, /*use_profile*/false);
 }
 
 TEST_F(OatTest, DexFileInputCheckVerifier) {
-  TestDexFileInput(true, /*low_4gb*/false);
+  TestDexFileInput(/*verify*/true, /*low_4gb*/false, /*use_profile*/false);
+}
+
+TEST_F(OatTest, DexFileFailsVerifierWithLayout) {
+  TestDexFileInput(/*verify*/true, /*low_4gb*/false, /*use_profile*/true);
 }
 
 void OatTest::TestZipFileInput(bool verify) {
@@ -717,8 +723,8 @@
     std::vector<const char*> input_filenames { zip_file.GetFilename().c_str() };  // NOLINT [readability/braces] [4]
 
     ScratchFile oat_file, vdex_file(oat_file, ".vdex");
-    success = WriteElf(vdex_file.GetFile(), oat_file.GetFile(),
-                       input_filenames, key_value_store, verify);
+    success = WriteElf(vdex_file.GetFile(), oat_file.GetFile(), input_filenames,
+                       key_value_store, verify, /*profile_compilation_info*/nullptr);
 
     if (verify) {
       ASSERT_FALSE(success);
diff --git a/compiler/oat_writer.cc b/compiler/oat_writer.cc
index a16a34b..41468ba 100644
--- a/compiler/oat_writer.cc
+++ b/compiler/oat_writer.cc
@@ -2267,7 +2267,7 @@
     dex_file = DexFile::OpenDex(raw_file->Fd(), location, /* verify_checksum */ true, &error_msg);
   }
   if (dex_file == nullptr) {
-    LOG(ERROR) << "Failed to open dex file for layout:" << error_msg;
+    LOG(ERROR) << "Failed to open dex file for layout: " << error_msg;
     return false;
   }
   Options options;