summaryrefslogtreecommitdiffstats
path: root/runtime/class_loader_context_test.cc
diff options
context:
space:
mode:
authorCalin Juravle <calin@google.com>2017-09-05 17:10:48 -0700
committerCalin Juravle <calin@google.com>2017-09-06 11:39:00 -0700
commit1e96a5d58d68909cbc2d6bf2ee08c6c11f7b858e (patch)
tree6018dd7f5ecff7e0f7298581546eea8bc9761453 /runtime/class_loader_context_test.cc
parent821a2595e2438554424879d6cb3594810ca8e636 (diff)
downloadart-1e96a5d58d68909cbc2d6bf2ee08c6c11f7b858e.tar.gz
art-1e96a5d58d68909cbc2d6bf2ee08c6c11f7b858e.tar.bz2
art-1e96a5d58d68909cbc2d6bf2ee08c6c11f7b858e.zip
Fix context verification for relative dependencies
If --classpath-dir is passed, dex2oat encodes the dependencies as relative paths in the class loader context. However, at runtime we always get the full apk paths. This means we will always get a context mismatch because even if we have the same file we encode its path differently at runtime and compile time. Only the split apks are affected by this issue since they will depend on the base apk which will be encoded as a relative location. The fix is to propagate the behavior from OatFile::Setup() which resolves the relative locations. In fixing this I took a bit more general approach and try to infer the context locations that should be compared based on the actual context and the expected context. Bug: 65385993 Test: m test-art-host-gtest manual with split-apks Change-Id: I4c8e7c4f0a3a18dba8daca752a21da4822cce490
Diffstat (limited to 'runtime/class_loader_context_test.cc')
-rw-r--r--runtime/class_loader_context_test.cc12
1 files changed, 11 insertions, 1 deletions
diff --git a/runtime/class_loader_context_test.cc b/runtime/class_loader_context_test.cc
index 458f9f3345..9c8e127f55 100644
--- a/runtime/class_loader_context_test.cc
+++ b/runtime/class_loader_context_test.cc
@@ -590,7 +590,17 @@ TEST_F(ClassLoaderContextTest, VerifyClassLoaderContextMatchAfterEncoding) {
std::unique_ptr<ClassLoaderContext> context = CreateContextForClassLoader(class_loader_d);
- ASSERT_TRUE(context->VerifyClassLoaderContextMatch(context->EncodeContextForOatFile("")));
+ std::string context_with_no_base_dir = context->EncodeContextForOatFile("");
+ ASSERT_TRUE(context->VerifyClassLoaderContextMatch(context_with_no_base_dir));
+
+ std::string dex_location = GetTestDexFileName("ForClassLoaderA");
+ size_t pos = dex_location.rfind('/');
+ ASSERT_NE(std::string::npos, pos);
+ std::string parent = dex_location.substr(0, pos);
+
+ std::string context_with_base_dir = context->EncodeContextForOatFile(parent);
+ ASSERT_NE(context_with_base_dir, context_with_no_base_dir);
+ ASSERT_TRUE(context->VerifyClassLoaderContextMatch(context_with_base_dir));
}
TEST_F(ClassLoaderContextTest, VerifyClassLoaderContextMatchAfterEncodingMultidex) {