summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libnativebridge/tests/Android.bp54
-rw-r--r--libnativebridge/tests/libnativebridge-tests.xml41
2 files changed, 67 insertions, 28 deletions
diff --git a/libnativebridge/tests/Android.bp b/libnativebridge/tests/Android.bp
index 9f6c84cbc4..76c5e27104 100644
--- a/libnativebridge/tests/Android.bp
+++ b/libnativebridge/tests/Android.bp
@@ -102,21 +102,11 @@ cc_test {
name: "libnativebridge-tests",
defaults: [
"art_defaults",
- "art_test_internal_library_defaults",
+ "art_standalone_test_defaults",
],
- target: {
- linux: {
- cflags: [
- // gtest issue
- "-Wno-used-but-marked-unused",
- "-Wno-deprecated",
- "-Wno-missing-noreturn",
- ],
- },
- },
-
isolated: true,
+ test_config: "libnativebridge-tests.xml",
srcs: [
"NativeBridgeTest.cpp",
@@ -144,35 +134,43 @@ cc_test {
"NativeBridge7CriticalNative_test.cpp",
],
- shared_libs: [
+ static_libs: [
"libbase",
- "liblog",
"libnativebridge",
+ ],
+ shared_libs: [
+ "liblog",
"libnativebridge6prezygotefork",
"libnativebridge7criticalnative",
-
- // Ideally these would only need to be listed in data_libs, but they
- // are dlopen'd by libnativebridge, not by libnativebridge-tests,
- // and the linker can't find them relative to /system/lib64/libnativebridge.so.
- // Linking them here causes them to be loaded from alongside
- // libnativebridge-tests when it is executed, and then the later dlopen
- // returns the handle to the already-loaded library.
- "libnativebridge-test-case",
- "libnativebridge2-test-case",
- "libnativebridge3-test-case",
- "libnativebridge6-test-case",
- "libnativebridge7-test-case",
],
data_libs: [
+ "libnativebridge6prezygotefork",
+ "libnativebridge7criticalnative",
+
+ // These are dlopen'd by libnativebridge, not libnativebridge-tests, but
+ // the former is statically linked into the latter, so the linker will
+ // find them next to the test binary.
"libnativebridge-test-case",
"libnativebridge2-test-case",
"libnativebridge3-test-case",
"libnativebridge6-test-case",
"libnativebridge7-test-case",
- "libnativebridge6prezygotefork",
- "libnativebridge7criticalnative",
],
+ target: {
+ linux: {
+ cflags: [
+ // gtest issue
+ "-Wno-used-but-marked-unused",
+ "-Wno-deprecated",
+ "-Wno-missing-noreturn",
+ ],
+ },
+ android: {
+ shared_libs: ["libdl_android"], // libnativebridge dependency
+ },
+ },
+
test_suites: [
"general-tests",
],
diff --git a/libnativebridge/tests/libnativebridge-tests.xml b/libnativebridge/tests/libnativebridge-tests.xml
new file mode 100644
index 0000000000..d4266a7d0c
--- /dev/null
+++ b/libnativebridge/tests/libnativebridge-tests.xml
@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2021 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.
+-->
+<configuration description="Runs libnativebridge-tests.">
+ <option name="config-descriptor:metadata" key="mainline-param" value="com.google.android.art.apex" />
+ <option name="config-descriptor:metadata" key="mainline-param" value="com.android.art.apex" />
+
+ <target_preparer class="com.android.tradefed.targetprep.PushFilePreparer">
+ <option name="cleanup" value="true" />
+ <option name="push" value="libnativebridge-tests->/data/local/tmp/libnativebridge-tests" />
+ </target_preparer>
+
+ <test class="com.android.tradefed.testtype.GTest" >
+ <option name="native-test-device-path" value="/data/local/tmp" />
+ <option name="module-name" value="libnativebridge-tests" />
+ </test>
+
+ <!-- When this test is run in a Mainline context (e.g. with `mts-tradefed`), only enable it if
+ one of the Mainline modules below is present on the device used for testing. -->
+ <object type="module_controller" class="com.android.tradefed.testtype.suite.module.MainlineTestModuleController">
+ <!-- ART Mainline Module (internal version). -->
+ <option name="mainline-module-package-name" value="com.google.android.art" />
+ <!-- ART Mainline Module (external (AOSP) version). -->
+ <option name="mainline-module-package-name" value="com.android.art" />
+ </object>
+
+ <!-- Only run tests if the device under test is SDK version 31 (Android 12) or above. -->
+ <object type="module_controller" class="com.android.tradefed.testtype.suite.module.Sdk31ModuleController" />
+</configuration>