summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Martin Stjernholm <mast@google.com> 2024-08-09 21:01:50 +0100
committer Treehugger Robot <android-test-infra-autosubmit@system.gserviceaccount.com> 2024-08-12 15:44:39 +0000
commit606f8a4172734d4833641a2bef4b85b262ecef39 (patch)
treeddd9c8ed881a8cf7eadb65a3caa7158aaff833e3
parentbda29056665961578f2b97cd6d40daca2058694d (diff)
Allow .so files in the same directory as the test binary.
Test: `atest libnativebridge-tests` with the child CL Bug: 357950167 Change-Id: I2eba87d876d667952936379e18ab0cd4352486b3
-rw-r--r--test/Android.bp1
-rw-r--r--test/standalone_test_lib_check.cc21
2 files changed, 20 insertions, 2 deletions
diff --git a/test/Android.bp b/test/Android.bp
index 38c0ca0037..eef30336e3 100644
--- a/test/Android.bp
+++ b/test/Android.bp
@@ -195,6 +195,7 @@ filegroup {
cc_library_static {
name: "standalone_test_lib_check",
srcs: ["standalone_test_lib_check.cc"],
+ header_libs: ["art_libartbase_headers"],
static_libs: [
"libbase",
"libelf",
diff --git a/test/standalone_test_lib_check.cc b/test/standalone_test_lib_check.cc
index e5c5baa3c6..426a302f54 100644
--- a/test/standalone_test_lib_check.cc
+++ b/test/standalone_test_lib_check.cc
@@ -23,6 +23,7 @@
#include <libelf.h>
#include <algorithm>
+#include <filesystem>
#include <string>
#include <vector>
@@ -31,6 +32,7 @@
#include "android-base/scopeguard.h"
#include "android-base/strings.h"
#include "android-base/unique_fd.h"
+#include "base/stl_util.h"
#include "gmock/gmock.h"
#include "gtest/gtest.h"
@@ -154,13 +156,28 @@ TEST(StandaloneTestAllowedLibDeps, test) {
Result<std::vector<std::string>> dyn_lib_deps = GetDynamicLibDeps(path_to_self.value());
ASSERT_RESULT_OK(dyn_lib_deps);
+ // Allow .so files in the same directory as the test binary, for shared libs
+ // pushed with the test using `data_libs`.
+ std::filesystem::path self_dir = std::filesystem::path(path_to_self.value()).parent_path();
+ std::vector<std::string> test_libs;
+ for (const std::filesystem::directory_entry& entry :
+ std::filesystem::directory_iterator(self_dir)) {
+ if (entry.is_regular_file() && entry.path().extension() == ".so") {
+ test_libs.push_back(entry.path().filename());
+ }
+ }
+
std::vector<std::string> disallowed_libs;
for (const std::string& dyn_lib_dep : dyn_lib_deps.value()) {
if (std::find(std::begin(kAllowedDynamicLibDeps),
std::end(kAllowedDynamicLibDeps),
- dyn_lib_dep) == std::end(kAllowedDynamicLibDeps)) {
- disallowed_libs.push_back(dyn_lib_dep);
+ dyn_lib_dep) != std::end(kAllowedDynamicLibDeps)) {
+ continue;
+ }
+ if (art::ContainsElement(test_libs, dyn_lib_dep)) {
+ continue;
}
+ disallowed_libs.push_back(dyn_lib_dep);
}
EXPECT_THAT(disallowed_libs, testing::IsEmpty())