From 3ae062d8d63a574077823713a7ffcedb356da40e Mon Sep 17 00:00:00 2001 From: Ryan Prichard Date: Mon, 20 May 2024 15:34:32 -0700 Subject: [PATCH] Build mainline tests with static libc++ and version script Bug: 341216801 Test: bpf_existence_test connectivity_native_test Change-Id: Ib1ad48902472fcf2fbfad3012426f9fd6a5102f6 --- tests/common/Android.bp | 5 ++++ tests/common/connectivity_mainline_test.map | 27 +++++++++++++++++++ tests/mts/Android.bp | 2 ++ .../connectivity_native_test/Android.bp | 4 ++- 4 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 tests/common/connectivity_mainline_test.map diff --git a/tests/common/Android.bp b/tests/common/Android.bp index 6e9d614381..e95a81a569 100644 --- a/tests/common/Android.bp +++ b/tests/common/Android.bp @@ -201,3 +201,8 @@ java_defaults { name: "connectivity-mainline-presubmit-java-defaults", test_mainline_modules: mainline_presubmit_modules, } + +filegroup { + name: "connectivity_mainline_test_map", + srcs: ["connectivity_mainline_test.map"], +} diff --git a/tests/common/connectivity_mainline_test.map b/tests/common/connectivity_mainline_test.map new file mode 100644 index 0000000000..043312e886 --- /dev/null +++ b/tests/common/connectivity_mainline_test.map @@ -0,0 +1,27 @@ +# +# Copyright (C) 2024 The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +# Some connectivity tests run on older OS versions, and for those tests, many +# library dependencies (such as libbase and libc++) need to be linked +# statically. The tests also need to be linked with a version script to ensure +# that the statically-linked library isn't exported from the executable, where +# it would override the shared libraries that the OS itself uses. See +# b/333438055 for an example of what goes wrong when libc++ is partially +# exported from an executable. +{ + local: + *; +}; diff --git a/tests/mts/Android.bp b/tests/mts/Android.bp index 336be2e081..c118d0afc5 100644 --- a/tests/mts/Android.bp +++ b/tests/mts/Android.bp @@ -31,6 +31,8 @@ cc_test { header_libs: [ "bpf_headers", ], + version_script: ":connectivity_mainline_test_map", + stl: "libc++_static", static_libs: [ "libbase", "libmodules-utils-build", diff --git a/tests/native/connectivity_native_test/Android.bp b/tests/native/connectivity_native_test/Android.bp index 2f66d17c54..c5088c6fea 100644 --- a/tests/native/connectivity_native_test/Android.bp +++ b/tests/native/connectivity_native_test/Android.bp @@ -17,8 +17,9 @@ cc_test { "connectivity_native_test.cpp", ], header_libs: ["bpf_connectivity_headers"], + version_script: ":connectivity_mainline_test_map", + stl: "libc++_static", shared_libs: [ - "libbase", "libbinder_ndk", "liblog", "libnetutils", @@ -26,6 +27,7 @@ cc_test { ], static_libs: [ "connectivity_native_aidl_interface-lateststable-ndk", + "libbase", "libcutils", "libmodules-utils-build", "libutils",