Fix for gtest missing core classes, attempt 2

common_runtime_test loads both core-libart and
core-oj

Change-Id: I8a4d5750b99aed2e500cad89b841a57fe9c1ca69
diff --git a/runtime/common_runtime_test.cc b/runtime/common_runtime_test.cc
index c299210..15ef489 100644
--- a/runtime/common_runtime_test.cc
+++ b/runtime/common_runtime_test.cc
@@ -197,8 +197,16 @@
   MemMap::Init();  // For LoadExpectSingleDexFile
 
   std::string error_msg;
-  java_lang_dex_file_ = LoadExpectSingleDexFile(GetLibCoreDexFileName().c_str());
-  boot_class_path_.push_back(java_lang_dex_file_);
+
+  java_lang_dex_file_ = nullptr;
+  for (const std::string &core_dex_file_name : GetLibCoreDexFileNames()) {
+    const DexFile* dex_file = LoadExpectSingleDexFile(core_dex_file_name.c_str());
+    boot_class_path_.push_back(dex_file);
+    // Store the first dex file in java_lang_dex_file_
+    if (java_lang_dex_file_ == nullptr) {
+      java_lang_dex_file_ = dex_file;
+    }
+  }
 
   std::string min_heap_string(StringPrintf("-Xms%zdm", gc::Heap::kDefaultInitialSize / MB));
   std::string max_heap_string(StringPrintf("-Xmx%zdm", gc::Heap::kDefaultMaximumSize / MB));
@@ -283,8 +291,8 @@
   Runtime::Current()->GetHeap()->VerifyHeap();  // Check for heap corruption after the test
 }
 
-std::string CommonRuntimeTest::GetLibCoreDexFileName() {
-  return GetDexFileName("core-libart");
+std::vector<std::string> CommonRuntimeTest::GetLibCoreDexFileNames() {
+  return std::vector<std::string>({GetDexFileName("core-oj"), GetDexFileName("core-libart")});
 }
 
 std::string CommonRuntimeTest::GetDexFileName(const std::string& jar_prefix) {
diff --git a/runtime/common_runtime_test.h b/runtime/common_runtime_test.h
index c19b30f..2af8208 100644
--- a/runtime/common_runtime_test.h
+++ b/runtime/common_runtime_test.h
@@ -92,8 +92,8 @@
 
   virtual void TearDown();
 
-  // Gets the path of the libcore dex file.
-  std::string GetLibCoreDexFileName();
+  // Gets the paths of the libcore dex files.
+  std::vector<std::string> GetLibCoreDexFileNames();
 
   // Gets the path of the specified dex file for host or target.
   std::string GetDexFileName(const std::string& jar_prefix);
diff --git a/runtime/dex_file_test.cc b/runtime/dex_file_test.cc
index d5304e7..b86a02e 100644
--- a/runtime/dex_file_test.cc
+++ b/runtime/dex_file_test.cc
@@ -205,7 +205,7 @@
   uint32_t checksum;
   ScopedObjectAccess soa(Thread::Current());
   std::string error_msg;
-  EXPECT_TRUE(DexFile::GetChecksum(GetLibCoreDexFileName().c_str(), &checksum, &error_msg))
+  EXPECT_TRUE(DexFile::GetChecksum(GetLibCoreDexFileNames()[0].c_str(), &checksum, &error_msg))
       << error_msg;
   EXPECT_EQ(java_lang_dex_file_->GetLocationChecksum(), checksum);
 }
diff --git a/runtime/parsed_options_test.cc b/runtime/parsed_options_test.cc
index 5154d69..e5cb30d 100644
--- a/runtime/parsed_options_test.cc
+++ b/runtime/parsed_options_test.cc
@@ -30,18 +30,27 @@
   void* test_exit = reinterpret_cast<void*>(0xc);
   void* null = reinterpret_cast<void*>(NULL);
 
-  std::string lib_core(GetLibCoreDexFileName());
-
   std::string boot_class_path;
+  std::string class_path;
   boot_class_path += "-Xbootclasspath:";
-  boot_class_path += lib_core;
+
+  bool first_dex_file = true;
+  for (const std::string &dex_file_name : GetLibCoreDexFileNames()) {
+    if (!first_dex_file) {
+      class_path += ":";
+    } else {
+      first_dex_file = false;
+    }
+    class_path += dex_file_name;
+  }
+  boot_class_path += class_path;
 
   RuntimeOptions options;
   options.push_back(std::make_pair(boot_class_path.c_str(), null));
   options.push_back(std::make_pair("-classpath", null));
-  options.push_back(std::make_pair(lib_core.c_str(), null));
+  options.push_back(std::make_pair(class_path.c_str(), null));
   options.push_back(std::make_pair("-cp", null));
-  options.push_back(std::make_pair(lib_core.c_str(), null));
+  options.push_back(std::make_pair(class_path.c_str(), null));
   options.push_back(std::make_pair("-Ximage:boot_image", null));
   options.push_back(std::make_pair("-Xcheck:jni", null));
   options.push_back(std::make_pair("-Xms2048", null));
@@ -57,8 +66,8 @@
   std::unique_ptr<ParsedOptions> parsed(ParsedOptions::Create(options, false));
   ASSERT_TRUE(parsed.get() != NULL);
 
-  EXPECT_EQ(lib_core, parsed->boot_class_path_string_);
-  EXPECT_EQ(lib_core, parsed->class_path_string_);
+  EXPECT_EQ(class_path, parsed->boot_class_path_string_);
+  EXPECT_EQ(class_path, parsed->class_path_string_);
   EXPECT_EQ(std::string("boot_image"), parsed->image_);
   EXPECT_EQ(true, parsed->check_jni_);
   EXPECT_EQ(2048U, parsed->heap_initial_size_);
diff --git a/runtime/zip_archive_test.cc b/runtime/zip_archive_test.cc
index 70a4dda..ced47e3 100644
--- a/runtime/zip_archive_test.cc
+++ b/runtime/zip_archive_test.cc
@@ -32,7 +32,7 @@
 
 TEST_F(ZipArchiveTest, FindAndExtract) {
   std::string error_msg;
-  std::unique_ptr<ZipArchive> zip_archive(ZipArchive::Open(GetLibCoreDexFileName().c_str(), &error_msg));
+  std::unique_ptr<ZipArchive> zip_archive(ZipArchive::Open(GetLibCoreDexFileNames()[0].c_str(), &error_msg));
   ASSERT_TRUE(zip_archive.get() != nullptr) << error_msg;
   ASSERT_TRUE(error_msg.empty());
   std::unique_ptr<ZipEntry> zip_entry(zip_archive->Find("classes.dex", &error_msg));