diff options
author | 2015-09-30 14:40:33 +0100 | |
---|---|---|
committer | 2015-11-12 10:15:58 +0000 | |
commit | 5b8e6e36e96d6d1921dd356fa46191d1e6a18082 (patch) | |
tree | 33d66d1cb3377447aa687ee4625c5826370d1e85 | |
parent | be26f77dac06fb02b0cc80914b740662bf8d0b26 (diff) |
Fix for gtest missing core classes, attempt 2
common_runtime_test loads both core-libart and
core-oj
Change-Id: I8a4d5750b99aed2e500cad89b841a57fe9c1ca69
-rw-r--r-- | runtime/common_runtime_test.cc | 16 | ||||
-rw-r--r-- | runtime/common_runtime_test.h | 4 | ||||
-rw-r--r-- | runtime/dex_file_test.cc | 2 | ||||
-rw-r--r-- | runtime/parsed_options_test.cc | 23 | ||||
-rw-r--r-- | runtime/zip_archive_test.cc | 2 |
5 files changed, 32 insertions, 15 deletions
diff --git a/runtime/common_runtime_test.cc b/runtime/common_runtime_test.cc index c299210461..15ef489037 100644 --- a/runtime/common_runtime_test.cc +++ b/runtime/common_runtime_test.cc @@ -197,8 +197,16 @@ void CommonRuntimeTest::SetUp() { 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 @@ void CommonRuntimeTest::TearDown() { 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 c19b30f72e..2af82085ef 100644 --- a/runtime/common_runtime_test.h +++ b/runtime/common_runtime_test.h @@ -92,8 +92,8 @@ class CommonRuntimeTest : public testing::Test { 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 d5304e7c3a..b86a02e18e 100644 --- a/runtime/dex_file_test.cc +++ b/runtime/dex_file_test.cc @@ -205,7 +205,7 @@ TEST_F(DexFileTest, GetChecksum) { 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 5154d69292..e5cb30d1b3 100644 --- a/runtime/parsed_options_test.cc +++ b/runtime/parsed_options_test.cc @@ -30,18 +30,27 @@ TEST_F(ParsedOptionsTest, ParsedOptions) { 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 @@ TEST_F(ParsedOptionsTest, ParsedOptions) { 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 70a4ddaabf..ced47e3e69 100644 --- a/runtime/zip_archive_test.cc +++ b/runtime/zip_archive_test.cc @@ -32,7 +32,7 @@ class ZipArchiveTest : public CommonRuntimeTest {}; 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)); |