From 43b3caaa018f9dd265ff47f756e07fb2bc7d1f2a Mon Sep 17 00:00:00 2001 From: Martin Stjernholm Date: Fri, 2 Sep 2022 21:33:04 +0100 Subject: [DO NOT MERGE] Make a CTS test more lenient to work with and without M-2022-10 ART module. Test: Download libnativeloader_test from android13-tests-dev and run with ART module at AOSP head. Bug: 244766714 Change-Id: Iccebb16398a409ece97d0d2fd8390538ef3c548c --- libnativeloader/native_loader_test.cpp | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'libnativeloader/native_loader_test.cpp') diff --git a/libnativeloader/native_loader_test.cpp b/libnativeloader/native_loader_test.cpp index 9648713e70..b1a7e3538a 100644 --- a/libnativeloader/native_loader_test.cpp +++ b/libnativeloader/native_loader_test.cpp @@ -379,9 +379,24 @@ TEST_P(NativeLoaderTest_Create, UnbundledProductApp) { expected_library_path = expected_library_path + ":/product/" LIB_DIR ":/system/product/" LIB_DIR; expected_permitted_path = expected_permitted_path + ":/product/" LIB_DIR ":/system/product/" LIB_DIR; - expected_shared_libs_to_platform_ns = - default_public_libraries() + ":" + llndk_libraries_product(); expected_link_with_vndk_product_ns = true; + + // The handling of extended libraries for product apps changed in the + // M-2022-10 release of the ART module (https://r.android.com/2194871). + // Since this test is in CTS for T, we need to accept both new and old + // behaviour, i.e. with and without the extended public libraries appended + // at the end. Skip the EXPECT_CALL in + // NativeLoaderTest_Create::SetExpectations and create a more lenient + // variant of it here. + expected_link_with_platform_ns = false; + expected_shared_libs_to_platform_ns = + expected_shared_libs_to_platform_ns + ":" + llndk_libraries_product(); + EXPECT_CALL(*mock, + mock_link_namespaces(Eq(IsBridged()), + _, + NsEq("system"), + ::testing::StartsWith(expected_shared_libs_to_platform_ns))) + .WillOnce(Return(true)); } SetExpectations(); RunTest(); -- cgit v1.2.3-59-g8ed1b From e9b5db1cfee0f6f7c4ecae874e2460a8d7445268 Mon Sep 17 00:00:00 2001 From: Satoshi Niwa Date: Wed, 14 Sep 2022 17:47:54 +0900 Subject: RESTRICT AUTOMERGE: libnativeloader_test: Skip reading VNDK libs for vendor if not available (Using Merged-In with an ID of a recent ART CL to avoid merging into master.) Bug: 235217081 Test: atest libnativeloader_test Change-Id: I8e6965189e9df3ba20ff3ddc22f74f0e23e7a1ee Merged-In: I1400a701a622f9f35b3ce0781575134faca679ae --- libnativeloader/native_loader_test.cpp | 2 +- libnativeloader/public_libraries.cpp | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) (limited to 'libnativeloader/native_loader_test.cpp') diff --git a/libnativeloader/native_loader_test.cpp b/libnativeloader/native_loader_test.cpp index b1a7e3538a..2fc2b4ec81 100644 --- a/libnativeloader/native_loader_test.cpp +++ b/libnativeloader/native_loader_test.cpp @@ -344,7 +344,7 @@ TEST_P(NativeLoaderTest_Create, UnbundledVendorApp) { expected_permitted_path = expected_permitted_path + ":/vendor/" LIB_DIR; expected_shared_libs_to_platform_ns = default_public_libraries() + ":" + llndk_libraries_vendor(); - expected_link_with_vndk_ns = true; + expected_link_with_vndk_ns = !get_vndk_version(/*is_product_vndk=*/false).empty(); SetExpectations(); RunTest(); } diff --git a/libnativeloader/public_libraries.cpp b/libnativeloader/public_libraries.cpp index ffebe0b4c7..433a9095ef 100644 --- a/libnativeloader/public_libraries.cpp +++ b/libnativeloader/public_libraries.cpp @@ -212,6 +212,9 @@ static std::string InitExtendedPublicLibraries() { } static std::string InitLlndkLibrariesVendor() { + if (get_vndk_version(/*is_product_vndk=*/false).empty()) { + return ""; + } std::string config_file = kLlndkLibrariesFile; InsertVndkVersionStr(&config_file, false); auto sonames = ReadConfig(config_file, always_true); @@ -237,6 +240,9 @@ static std::string InitLlndkLibrariesProduct() { } static std::string InitVndkspLibrariesVendor() { + if (get_vndk_version(/*is_product_vndk=*/false).empty()) { + return ""; + } std::string config_file = kVndkLibrariesFile; InsertVndkVersionStr(&config_file, false); auto sonames = ReadConfig(config_file, always_true); -- cgit v1.2.3-59-g8ed1b From daa9be44dcdc6a9b46db23a5e0bc0008c09a074c Mon Sep 17 00:00:00 2001 From: Martin Stjernholm Date: Tue, 1 Nov 2022 18:51:04 +0000 Subject: Fix UnbundledProductApp CTS test to work with extended public libraries. This amends the fix https://r.android.com/2203617 which didn't handle extended public libraries correctly. When llndk_libraries_product() got appended to expected_shared_libs_to_platform_ns, it got set to default_public_libraries() + extended_public_libraries() + llndk_libraries_product(), which gets matched as a prefix against the real value default_public_libraries() + llndk_libraries_product() + extended_public_libraries() in the M-2022-11 version of the ART Module. That only works as long as extended_public_libraries() returns an empty string. Set it to default_public_libraries() + llndk_libraries_product() instead, so that the prefix match works as intended. Also fix the classloader namespace check to accept the name change made in https://r.android.com/2166783. That CL is not yet in an ART module release branch, but it will be eventually. This patch is only applicable to android13-tests-dev, where the ART module may or may not be updated. On AOSP head it should only accept the new behaviour. Merged-In set from https://r.android.com/2166783 to block merging there. Test: atest -a libnativeloader_test with and without installing an unbundled ART module built from current head on the master-art branch. Test: adb root adb remount -R adb root adb remount adb shell 'echo "libfoo.foo.so" > system/etc/public.libraries-foo.txt' atest -a libnativeloader_test with and without installing an unbundled ART module built from current head on the master-art branch. Bug: 256715954 Change-Id: I347582df87e2bce0142d0210519f013d060a0180 Merged-In: I3e8cfcb9ed8112bb0144ff2ea53fe7a8bcb63694 --- libnativeloader/native_loader_test.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'libnativeloader/native_loader_test.cpp') diff --git a/libnativeloader/native_loader_test.cpp b/libnativeloader/native_loader_test.cpp index 2fc2b4ec81..1dc778abcd 100644 --- a/libnativeloader/native_loader_test.cpp +++ b/libnativeloader/native_loader_test.cpp @@ -31,6 +31,7 @@ namespace android { namespace nativeloader { using ::testing::Eq; +using ::testing::MatchesRegex; using ::testing::NotNull; using ::testing::StrEq; using internal::ConfigEntry; @@ -224,7 +225,7 @@ class NativeLoaderTest_Create : public NativeLoaderTest { EXPECT_CALL(*mock, NativeBridgeInitialized()).Times(testing::AnyNumber()); EXPECT_CALL(*mock, mock_create_namespace( - Eq(IsBridged()), StrEq(expected_namespace_name), nullptr, + Eq(IsBridged()), MatchesRegex(expected_namespace_name), nullptr, StrEq(expected_library_path), expected_namespace_flags, StrEq(expected_permitted_path), NsEq(expected_parent_namespace.c_str()))) .WillOnce(Return(TO_MOCK_NAMESPACE(TO_ANDROID_NAMESPACE(dex_path.c_str())))); @@ -375,7 +376,7 @@ TEST_P(NativeLoaderTest_Create, UnbundledProductApp) { is_shared = false; if (is_product_vndk_version_defined()) { - expected_namespace_name = "vendor-classloader-namespace"; + expected_namespace_name = "(vendor|product)-classloader-namespace"; expected_library_path = expected_library_path + ":/product/" LIB_DIR ":/system/product/" LIB_DIR; expected_permitted_path = expected_permitted_path + ":/product/" LIB_DIR ":/system/product/" LIB_DIR; @@ -390,7 +391,7 @@ TEST_P(NativeLoaderTest_Create, UnbundledProductApp) { // variant of it here. expected_link_with_platform_ns = false; expected_shared_libs_to_platform_ns = - expected_shared_libs_to_platform_ns + ":" + llndk_libraries_product(); + default_public_libraries() + ":" + llndk_libraries_product(); EXPECT_CALL(*mock, mock_link_namespaces(Eq(IsBridged()), _, -- cgit v1.2.3-59-g8ed1b