summaryrefslogtreecommitdiff
path: root/libnativeloader/test/src
AgeCommit message (Collapse)Author
2025-02-12Improve cleanup robustness after adb push failures. Martin Stjernholm
Should fix `Cannot invoke "String.split(String)" because "pathList" is null` seen in those cases. Change-Id: I4bcd4e7c905017e25f83a47790d8552c7d94258e Test: presubmits Bug: 395130114
2024-10-16Set native libs to non writable before loading it Linus Tufvesson
Bug: 354921003 Test: atest libnativeloader_e2e_tests Change-Id: I0abfe10e8673c25fc63e377b784a0626f02e0896
2024-03-18Give full access to native libs from Java libs in the same partition Martin Stjernholm
(reland 2). For both packages and shared Java libs in system image partitions (system, product, vendor), load native libraries from the same partition by using the linker namespace for that partition ("default" or "system", "product", "sphal", respectively). This is only done for native libraries in the <partition root>/lib(64) directories when specified by an absolute path (i.e. use java.lang.System.load rather than loadLibrary). Otherwise it's looked up using the classloader namespace for the package, as before. Since only loads with absolute paths are affected, compat issues are unlikely. However to be on the safe side it's only enabled for SDK level 35 (VIC) and later (regardless of targetSdkVersion of the package, because the affected code is in system image partitions). This relands https://r.android.com/2933611 but keeps the vendor and product API domain checks unchanged in the CreateClassLoaderNamespace code paths (cf. b/326631342). Test: atest libnativeloader_e2e_tests \ libnativeloader_test libnativeloader_lazy_test Test: libnativeloader_e2e_tests on S, Sv2, T, and U platforms in CI Test: ImsServiceEntitlementUnitTests Bug: 237577392 Change-Id: I246101c1663d81089d9b4ae9450c28d564a7603a
2024-02-23Revert "Give full access to native libs from java libs in the sa..." Becky Siegel
Revert submission 2933611-libnativeloader-shared-syslibs Reason for revert: Fixing test breakage b/326622518, b/326631342 Reverted changes: /q/submissionid:2933611-libnativeloader-shared-syslibs Change-Id: I746478191c0e3a2d1a36d87e7a3db980de196420
2024-02-23Give full access to native libs from java libs in the same partition Martin Stjernholm
(reland). For both packages and shared java libs in system image partitions (system, product, vendor), load native libraries from the same partition by using the linker namespace for that partition ("default" or "system", "product", "sphal", respectively). This is only done for native libraries in the <partition root>/lib(64) directories when specified by an absolute path (i.e. use java.lang.System.load rather than loadLibrary). Otherwise it's looked up using the classloader namespace for the package, as before. Since only loads with absolute paths are affected, compat issues are unlikely. However to be on the safe side it's only enabled for SDK level 35 (VIC) and later (regardless of targetSdkVersion of the package, because the affected code is in system image partitions). This is based on a reland of commit 453b9fe909c22eb0f01b3072a5213dd46aed6f45, but with a different solution. It also extends the approach to work for vendor and product partitions. Test: atest libnativeloader_e2e_tests \ libnativeloader_test libnativeloader_lazy_test Test: libnativeloader_e2e_tests on S, Sv2, T, and U platforms in CI Bug: 237577392 Change-Id: If8b74503edfa9229b9eada73968b7d7b5c75ca10
2024-02-21Fix test failures on sargo. Martin Stjernholm
https://r.android.com/2962585 added new tests, but some of them fail on S on sargo since the product partition comes from R and doesn't have its own linker namespace. Also switch version checks to use com.android.modules.utils.build.SdkLevel to correctly handle pre-release codenames. Test: libnativeloader_e2e_tests on AOSP with temporary code to verify that TestUtils.productAppsAreShared() returns false Test: libnativeloader_e2e_tests on sargo in heavy presubmit Test: libnativeloader_e2e_tests on Cuttlefish S image in heavy presubmit Bug: 325619263 Bug: 237577392 Change-Id: I7cc7d0a6288b10b5f70c6c674f88287b2489be75
2024-02-15Add tests for loading with absolute paths through System.load(). Martin Stjernholm
Introduce a base class for common tests for all apps. This just "documents" current behaviour as a preparation for a later CL that will change the logic for loading private native libs. Test: atest libnativeloader_e2e_tests Bug: 237577392 Change-Id: I80fd10f1d980fd79d0f6f544ec6f776987531ee6
2024-02-15Don't match dlopen errors too closely in tests. Martin Stjernholm
It doesn't matter if the load failed due to not finding the library or due to finding it in the wrong linker namespace. Add tests to check existence of private libs as a safeguard so that we don't error out for the wrong reason. Test: atest libnativeloader_e2e_tests Bug: 237577392 Change-Id: I70ebffe2763d2e5e87c45c1cf94c3b268c795fdd
2023-11-30Disable tests for the product partition that fail on S and Sv2. Martin Stjernholm
- Support for public libraries in /product was added with https://r.android.com/1789089 in T. The ProductAppTest app, being installed in /product/app, can still access them since it's in the same partition. - Apps in /product/app were loaded with shared library namespaces in S, so we cannot test cases where loading of private product, system, and system_ext libraries should fail in ProductAppTest.java. Also use min_sdk_version and a far future target_sdk_version for the test apps to make them run on both development and release platforms, without compat mode. Test: libnativeloader_e2e_tests on S, T, and U in heavy presubmits Bug: 259700260 Change-Id: I21d785d94132af09305c71ed038c74d7b5d58fcc
2023-01-07Undo giving full access to system libs from other system libs. Martin Stjernholm
Directly extending the search path to /system/${LIB} for system APKs may result in system libs being loaded in an app classloader namespace rather than the system namespace. If those libs then depend on other non-public libraries, e.g. in APEXes, that are only accessible through links from the system namespace, then those dependencies will fail to load because the app classloader namespace doesn't have the same links. This CL functionally undoes https://r.android.com/2211602, but only disables tests that break, and adds some tests to exercise the situation above. Also change native libs in the test to use `min_sdk_version` rather than `sdk_version`, because now when they contain code they need an NDK, and one with exactly version 31 is normally not available in the build. (Otoh, the java libraries with `product_specific: true` or `vendor: true` aren't allowed to use `min_sdk_version`.) Test: atest -a libnativeloader_test libnativeloader_lazy_test \ libnativeloader_e2e_tests Bug: 258340826 Bug: 237577392 Change-Id: I95a3fbc6c8021c037fffda1423aa90c62973ec89
2022-11-28Test loading of extended public libraries through absolute paths. Martin Stjernholm
Test: atest libnativeloader_e2e_tests Bug: 258340826 Change-Id: I2759a29d83b04e69bc0678e50eb154d117c1323c
2022-11-22Add tests for loading native libraries in various locations through Martin Stjernholm
absolute paths (reland). This relands https://r.android.com/2304014 with a more reliable way of determining the native library directory ("lib" or "lib64"). Test: atest libnativeloader_e2e_tests Bug: 258340826 Change-Id: I8823c93cafa4747ef24ee57a3fcfeebe0f5788c7
2022-11-18Revert "Add tests for loading native libraries in various locations through" Linyu He
This reverts commit c09e656f28e0787afd404ef03ba92b73d4117434. Reason for revert: b/259726812 Change-Id: I75091cf421011a888e9f9514b58e0e9328542082
2022-11-18Add tests for loading native libraries in various locations through Martin Stjernholm
absolute paths. Test: atest libnativeloader_e2e_tests Bug: 258340826 Change-Id: I825a9f41269bc501ec633ef25ebe205d3a0a7a73
2022-10-05Pass TestInformation directly to DeviceContext and fix setenforce Martin Stjernholm
problem. TestInformation can be retrieved with getTestInformation in individual tests. Also remove a leftover setenforce call that was missed in https://r.android.com/2239933. This uncovered a problem where remountSystemWritable() could reboot the device back to enforcing state after DisableSELinuxTargetPreparer, so move the remount too to a preparer. Test: atest libnativeloader_e2e_tests Bug: 137356719 Change-Id: I2ac05e162230717fb1d2f75efaf9e22f2c23f863
2022-10-04Extend tests to try loading private libs through product and vendor Martin Stjernholm
shared libs. Both product and vendor shared libs can already load native libs in their own partitions, so no libnativeloader change is necessary. Test: atest libnativeloader_e2e_tests Bug: 237577392 Change-Id: Icd5926044be1b08a0b66ec4a0f2cacc9848cb29d
2022-09-13Give full access to system libs from other system libs. Martin Stjernholm
In particular this addresses the case when an app without a shared namespace loads a shared system library that in turn loads a system JNI library. Give full access both ways between /system and /system_ext libraries, and add a shared system_ext library and loading from system_ext to test that. Test: atest libnativeloader_e2e_tests Bug: 237577392 Change-Id: Ief4e24dadbadd26c5602c9e593276fae01bd7038
2022-09-13Add tests that try to load non-shared native libs in each partition. Martin Stjernholm
One test case in each app that tries to load them directly, and another one that goes through a shared library in the system partition. Also set the appropriate Soong properties on the test apps, for what it may be worth (doesn't seem to have any effect that we don't get by just pushing them to the various partitions). Test: atest libnativeloader_e2e_tests Bug: 137356719 Bug: 237577392 Change-Id: I9e2c8162e0f0928020355a507b90f0fa76bf6b6b
2022-09-13Add a normal test app, i.e. one installed in /data. Martin Stjernholm
As opposed to the other apps, it's installed the normal way after the system server has been restarted. At the same time switch to using data dependencies instead of java resources for the test apps. Test: atest libnativeloader_e2e_tests Bug: 137356719 Bug: 237577392 Change-Id: Ia89748f87a53418a8ec324a7934064ca34821e8f
2022-09-13Test <uses-native-library> logic. Martin Stjernholm
Remove the use of SDK version 30 in the test apps and add the requisite <uses-native-library> instead. Also test some cases when they are missing. Test: atest libnativeloader_e2e_tests Bug: 137356719 Change-Id: I506351999de736fd0c40adf34b4745e3a263762a
2022-09-09Introduce a shared class for test utilities. Martin Stjernholm
To be used more in later CLs. Test: atest libnativeloader_e2e_tests Bug: 137356719 Bug: 237577392 Change-Id: I35ef7df45e6337d4eed91a82d561df5f48784670
2022-09-09Use a better property to find the ABI in the fallback. Martin Stjernholm
`ro.bionic.arch` is just the "top level" arch type, e.g. `arm64`, but for the arch-specific directories for JNI libs in the APKs we need the full ABI, e.g. `arm64-v8a`. Test: atest libnativeloader_e2e_tests (Can't get it to actually exercise the fallback though - I don't know what does.) Bug: 137356719 Change-Id: Id3450a7bf542e9353e25a3bd4c092be346f4416d
2022-08-06Allow apps in /product to access extended public libraries. Martin Stjernholm
Test: atest -a libnativeloader_e2e_tests Bug: 237572732 Change-Id: I93e38e81ef6f37a4dbf78833e83ec5a02d6b8211
2022-08-06Extend loadLibrary tests with apps in /system/priv-app, /system_ext, Martin Stjernholm
and /product. In /system_ext we run the same tests as in /system, because there shouldn't be any difference between them. For /product this records how it currently works, not what we want when b/237572732 is fixed. Test: atest -a libnativeloader_e2e_tests Bug: 237572732 Change-Id: I4f35c8e3b271e7bf300d410e6952a4d9073fec6b
2022-07-27Fix libnativeloader_e2e_tests to behave more like the manual tests did Martin Stjernholm
before https://r.android.com/2160662. The load failures of the libraries in /product are due to missing uses_library dependencies, which is enforced in SDK 31 and later. To make these tests comparable with the old ones, downgrade the test apps to SDK 30. Another reason for it is that I haven't had any luck with adding <uses-native-library> to the app manifests. These results are the same as the old manual tests, which has been verified by running them with a small patch https://r.android.com/2166263. Full output in http://go/paste/4596862691573760. Test: atest libnativeloader_e2e_tests: Bug: 137356719 Change-Id: I4c8492d36fc89654ba82f58d7a560dd0254db031
2022-07-25Move existing library loading tests to a TF hostside test. Martin Stjernholm
Replace the manual runtest.sh script with something that tradefed can run. It requires root and will remount, push .so libraries and public.libraries*txt files to any path they need to go to, and then do a soft reboot. Since libraries are pushed to the test locations rather than being installed through LOCAL_MODULE_PATH, the shared libraries in the build don't matter, and the same one is now used for all locations. That means it no longer exercises the `product_specific` Soong property for the two product libraries. Test: atest libnativeloader_e2e_tests Bug: 137356719 Change-Id: Ida1c70cb282946d72736da5cab0c751b60f0b03a
2019-10-11Move libnative{bridge,loader} to art/ Orion Hodson
This change moves system/core/libnative{bridge,loader} under art/. Bug: 137364733 Test: m Change-Id: I9be7333d00fcd3f36cd80520e50a30ea840187ad