Fix handling for partial cdex conversion rejection in multidex

In the case where some dex files for multidex were rejected by cdex
conversion for having duplicate ids (or other reasons), there was a
failing assert.

This change fixes the assert by skipping the dex file instead.

Test: test-art-host-gtest-dex2oat_test
Bug: 73126133

Change-Id: I05f560118d7a8d9363334f1349e2b75171f1e26d
diff --git a/dex2oat/dex2oat_test.cc b/dex2oat/dex2oat_test.cc
index b16c56a..6b75595 100644
--- a/dex2oat/dex2oat_test.cc
+++ b/dex2oat/dex2oat_test.cc
@@ -1716,6 +1716,34 @@
   }
 }
 
+TEST_F(Dex2oatTest, CompactDexGenerationFailureMultiDex) {
+  // Create a multidex file with only one dex that gets rejected for cdex conversion.
+  ScratchFile apk_file;
+  {
+    FILE* file = fdopen(apk_file.GetFd(), "w+b");
+    ZipWriter writer(file);
+    // Add vdex to zip.
+    writer.StartEntry("classes.dex", ZipWriter::kCompress);
+    size_t length = 0u;
+    std::unique_ptr<uint8_t[]> bytes(DecodeBase64(kDuplicateMethodInputDex, &length));
+    ASSERT_GE(writer.WriteBytes(&bytes[0], length), 0);
+    writer.FinishEntry();
+    writer.StartEntry("classes2.dex", ZipWriter::kCompress);
+    std::unique_ptr<const DexFile> dex(OpenTestDexFile("ManyMethods"));
+    ASSERT_GE(writer.WriteBytes(dex->Begin(), dex->Size()), 0);
+    writer.FinishEntry();
+    writer.Finish();
+    ASSERT_EQ(apk_file.GetFile()->Flush(), 0);
+  }
+  const std::string dex_location = apk_file.GetFilename();
+  const std::string odex_location = GetOdexDir() + "/output.odex";
+  GenerateOdexForTest(dex_location,
+                      odex_location,
+                      CompilerFilter::kQuicken,
+                      { "--compact-dex-level=fast" },
+                      true);
+}
+
 TEST_F(Dex2oatTest, StderrLoggerOutput) {
   std::string dex_location = GetScratchDir() + "/Dex2OatStderrLoggerTest.jar";
   std::string odex_location = GetOdexDir() + "/Dex2OatStderrLoggerTest.odex";