diff options
author | 2021-03-29 08:49:38 +0100 | |
---|---|---|
committer | 2021-03-29 12:46:54 +0000 | |
commit | 982ecedecd2326f9b28ee60a3feb56b299e1c2bc (patch) | |
tree | d319249a25c0f13bab0bb45efd8cf70a4a238985 /runtime/class_loader_context_test.cc | |
parent | 09108b274c15b55d8577ae3590005e990694c5b7 (diff) |
Remove '&' class loader context.
This is now an unsupported context.
Test: class_loader_context
Bug: 132357300
Change-Id: I21bc6e3529944a57379845e90c7f49759db30d40
Diffstat (limited to 'runtime/class_loader_context_test.cc')
-rw-r--r-- | runtime/class_loader_context_test.cc | 62 |
1 files changed, 3 insertions, 59 deletions
diff --git a/runtime/class_loader_context_test.cc b/runtime/class_loader_context_test.cc index ec51dee06c..bf51ae3a0f 100644 --- a/runtime/class_loader_context_test.cc +++ b/runtime/class_loader_context_test.cc @@ -208,7 +208,6 @@ class ClassLoaderContextTest : public CommonRuntimeTest { ASSERT_TRUE(context != nullptr); ASSERT_EQ(context->dex_files_state_, ClassLoaderContext::ContextDexFilesState::kDexFilesOpened); ASSERT_FALSE(context->owns_the_dex_files_); - ASSERT_FALSE(context->special_shared_library_); } void VerifyClassLoaderDexFiles(ScopedObjectAccess& soa, @@ -390,10 +389,10 @@ TEST_F(ClassLoaderContextTest, ParseValidEmptyContext) { VerifyClassLoaderPCL(context.get(), 0, ""); } -TEST_F(ClassLoaderContextTest, ParseValidSharedLibraryContext) { +TEST_F(ClassLoaderContextTest, ParseInvalidSharedLibraryContext) { + // '&' used to be a special context. std::unique_ptr<ClassLoaderContext> context = ClassLoaderContext::Create("&"); - // An shared library context should have no class loader in the chain. - VerifyContextSize(context.get(), 0); + ASSERT_TRUE(context == nullptr); } TEST_F(ClassLoaderContextTest, ParseValidContextPCL) { @@ -486,12 +485,6 @@ TEST_F(ClassLoaderContextTest, ParseValidEmptyContextSharedLibrary) { VerifySharedLibrariesSize(context.get(), 0, 0); } -TEST_F(ClassLoaderContextTest, ParseValidContextSpecialSymbol) { - std::unique_ptr<ClassLoaderContext> context = - ClassLoaderContext::Create(OatFile::kSpecialSharedLibrary); - VerifyContextSize(context.get(), 0); -} - TEST_F(ClassLoaderContextTest, ParseInvalidValidContexts) { ASSERT_TRUE(nullptr == ClassLoaderContext::Create("ABC[a.dex]")); ASSERT_TRUE(nullptr == ClassLoaderContext::Create("PCL")); @@ -675,34 +668,6 @@ TEST_F(ClassLoaderContextTest, CreateClassLoaderWithEmptyContext) { soa.Decode<mirror::Class>(WellKnownClasses::java_lang_BootClassLoader)); } -TEST_F(ClassLoaderContextTest, CreateClassLoaderWithSharedLibraryContext) { - std::unique_ptr<ClassLoaderContext> context = ClassLoaderContext::Create("&"); - - ASSERT_TRUE(context->OpenDexFiles()); - - std::vector<std::unique_ptr<const DexFile>> compilation_sources = OpenTestDexFiles("MultiDex"); - - std::vector<const DexFile*> compilation_sources_raw = - MakeNonOwningPointerVector(compilation_sources); - jobject jclass_loader = context->CreateClassLoader(compilation_sources_raw); - ASSERT_TRUE(jclass_loader != nullptr); - - ScopedObjectAccess soa(Thread::Current()); - - StackHandleScope<1> hs(soa.Self()); - Handle<mirror::ClassLoader> class_loader = hs.NewHandle( - soa.Decode<mirror::ClassLoader>(jclass_loader)); - - // A shared library context should create a single PathClassLoader with only the compilation - // sources. - VerifyClassLoaderDexFiles(soa, - class_loader, - WellKnownClasses::dalvik_system_PathClassLoader, - compilation_sources_raw); - ASSERT_TRUE(class_loader->GetParent()->GetClass() == - soa.Decode<mirror::Class>(WellKnownClasses::java_lang_BootClassLoader)); -} - TEST_F(ClassLoaderContextTest, CreateClassLoaderWithComplexChain) { // Setup the context. std::vector<std::unique_ptr<const DexFile>> classpath_dex_a = OpenTestDexFiles("ForClassLoaderA"); @@ -1470,16 +1435,6 @@ TEST_F(ClassLoaderContextTest, CreateContextForClassLoaderIMC) { VerifyClassLoaderPCLFromTestDex(context.get(), 3, "ForClassLoaderA"); } -TEST_F(ClassLoaderContextTest, VerifyClassLoaderContextFirstElement) { - std::string context_spec = "PCL[]"; - std::unique_ptr<ClassLoaderContext> context = ParseContextWithChecksums(context_spec); - ASSERT_TRUE(context != nullptr); - PretendContextOpenedDexFilesForChecksums(context.get()); - // Ensure that the special shared library marks as verified for the first thing in the class path. - ASSERT_EQ(context->VerifyClassLoaderContextMatch(OatFile::kSpecialSharedLibrary), - ClassLoaderContext::VerificationResult::kVerifies); -} - TEST_F(ClassLoaderContextTest, VerifyClassLoaderContextMatch) { std::string context_spec = "PCL[a.dex*123:b.dex*456];DLC[c.dex*890]"; std::unique_ptr<ClassLoaderContext> context = ParseContextWithChecksums(context_spec); @@ -1539,17 +1494,6 @@ TEST_F(ClassLoaderContextTest, VerifyClassLoaderContextWithIMCMatch) { ClassLoaderContext::VerificationResult::kVerifies); } -TEST_F(ClassLoaderContextTest, VerifyClassLoaderContextMatchSpecial) { - std::string context_spec = "&"; - std::unique_ptr<ClassLoaderContext> context = ParseContextWithChecksums(context_spec); - // Pretend that we successfully open the dex files to pass the DCHECKS. - // (as it's much easier to test all the corner cases without relying on actual dex files). - PretendContextOpenedDexFiles(context.get()); - - ASSERT_EQ(context->VerifyClassLoaderContextMatch(context_spec), - ClassLoaderContext::VerificationResult::kForcedToSkipChecks); -} - TEST_F(ClassLoaderContextTest, VerifyClassLoaderContextMatchWithSL) { std::string context_spec = "PCL[a.dex*123:b.dex*456]{PCL[d.dex*321];PCL[e.dex*654]#PCL[f.dex*098:g.dex*999]}" |