JniTest: Fix linker_namespace test for /vendor libraries
All libraries in /vendor are now non-executable for anything out side of
/vendor except for the same process HALs (e.g. egl libraries) that are
whitelisted in SEPolicy. This resulted in failure of linker_namespace
test failure due to denial to dlopen libraries in /vendor/lib[64].
Fix that by checking explicitly if the library being opened is in
/vendor and if the resulting dlerror is "not found".
Bug: 37216091
Test: /cts-tradefed run cts -m CtsJniTestCases --skip-device-info \
--skip-preconditions --skip-connectivity-check --abi arm64-v8a
Result: 64 Passed, 0 Failed
Change-Id: Idc6871e1760d4cdfdd70f0acd755467e5b837802
Signed-off-by: Sandeep Patil <sspatil@google.com>
(cherry picked from commit 7fcd395bf8d0978274e47fa5c4335ef5d213c4fb)
diff --git a/tests/tests/jni/libjnitest/android_jni_cts_LinkerNamespacesTest.cpp b/tests/tests/jni/libjnitest/android_jni_cts_LinkerNamespacesTest.cpp
index 3b890f2..16a202e 100644
--- a/tests/tests/jni/libjnitest/android_jni_cts_LinkerNamespacesTest.cpp
+++ b/tests/tests/jni/libjnitest/android_jni_cts_LinkerNamespacesTest.cpp
@@ -71,11 +71,14 @@
}
static bool already_loaded(const std::string& library, const std::string& err) {
- if (err.find("dlopen failed: library \"" + library + "\"") != 0 ||
- err.find("is not accessible for the namespace \"classloader-namespace\"") == std::string::npos) {
- return false;
+ // SELinux denials for /vendor libraries may return with library not found
+ if (err.find("dlopen failed: library \"" + library + "\"") == 0 &&
+ (err.find("not found") != std::string::npos ||
+ err.find("is not accessible for the namespace \"classloader-namespace\"") != std::string::npos)) {
+ return true;
}
- return true;
+
+ return false;
}
static bool check_lib(const std::string& path,