summaryrefslogtreecommitdiffstats
path: root/runtime/common_runtime_test.cc
diff options
context:
space:
mode:
authorRichard Uhler <ruhler@google.com>2015-01-15 09:37:19 -0800
committerRichard Uhler <ruhler@google.com>2015-03-09 14:46:23 -0700
commit66d874d96d5699bb090c59f47a5a528956ca053e (patch)
treed59bf83a08fead7d9823230831bea63c9e43a62c /runtime/common_runtime_test.cc
parent2cfdabd2bb4833d7092819d27ef08a9e1cdffead (diff)
downloadart-66d874d96d5699bb090c59f47a5a528956ca053e.zip
art-66d874d96d5699bb090c59f47a5a528956ca053e.tar.gz
art-66d874d96d5699bb090c59f47a5a528956ca053e.tar.bz2
Create OatFileAssistant class for assisting with oat files.
The oat file assistant is used for determining whether dex2oat or patchoat is needed, for running dex2oat or patchoat as needed to make an oat file up to date, and to load dex files associated with a given dex location. The introduction of the OatFileAssistant class is meant to clean up and consolidate code related to the management of oat files that was duplicated and spread across dalvik_system_DexFile.cc and class_linker.cc. Bug: 11301553 Change-Id: I0c16027b9bae4570c2c50faa9c14f581c0cbafb8
Diffstat (limited to 'runtime/common_runtime_test.cc')
-rw-r--r--runtime/common_runtime_test.cc11
1 files changed, 10 insertions, 1 deletions
diff --git a/runtime/common_runtime_test.cc b/runtime/common_runtime_test.cc
index b7ffd60..1c8a892 100644
--- a/runtime/common_runtime_test.cc
+++ b/runtime/common_runtime_test.cc
@@ -36,6 +36,7 @@
#include "gtest/gtest.h"
#include "jni_internal.h"
#include "mirror/class_loader.h"
+#include "mem_map.h"
#include "noop_compiler_callbacks.h"
#include "os.h"
#include "runtime-inl.h"
@@ -194,6 +195,7 @@ std::string CommonRuntimeTest::GetCoreOatLocation() {
std::unique_ptr<const DexFile> CommonRuntimeTest::LoadExpectSingleDexFile(const char* location) {
std::vector<std::unique_ptr<const DexFile>> dex_files;
std::string error_msg;
+ MemMap::Init();
if (!DexFile::Open(location, location, &error_msg, &dex_files)) {
LOG(FATAL) << "Could not open .dex file '" << location << "': " << error_msg << "\n";
UNREACHABLE();
@@ -225,10 +227,12 @@ void CommonRuntimeTest::SetUp() {
options.push_back(std::make_pair("compilercallbacks", callbacks_.get()));
SetUpRuntimeOptions(&options);
+ PreRuntimeCreate();
if (!Runtime::Create(options, false)) {
LOG(FATAL) << "Failed to create runtime";
return;
}
+ PostRuntimeCreate();
runtime_.reset(Runtime::Current());
class_linker_ = runtime_->GetClassLinker();
class_linker_->FixupDexCaches(runtime_->GetResolutionMethod());
@@ -335,7 +339,7 @@ std::string CommonRuntimeTest::GetTestAndroidRoot() {
#define ART_TARGET_NATIVETEST_DIR_STRING ""
#endif
-std::vector<std::unique_ptr<const DexFile>> CommonRuntimeTest::OpenTestDexFiles(const char* name) {
+std::string CommonRuntimeTest::GetTestDexFileName(const char* name) {
CHECK(name != nullptr);
std::string filename;
if (IsHost()) {
@@ -347,6 +351,11 @@ std::vector<std::unique_ptr<const DexFile>> CommonRuntimeTest::OpenTestDexFiles(
filename += "art-gtest-";
filename += name;
filename += ".jar";
+ return filename;
+}
+
+std::vector<std::unique_ptr<const DexFile>> CommonRuntimeTest::OpenTestDexFiles(const char* name) {
+ std::string filename = GetTestDexFileName(name);
std::string error_msg;
std::vector<std::unique_ptr<const DexFile>> dex_files;
bool success = DexFile::Open(filename.c_str(), filename.c_str(), &error_msg, &dex_files);