summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Stjernholm <mast@google.com>2024-03-04 16:48:02 +0000
committerMartin Stjernholm <mast@google.com>2024-03-20 15:43:02 +0000
commit002aca7141e7baf488b02f330b307f059c47a84d (patch)
treecbad5ba3a4565fd03dbac7d720683ef72b92bba6
parent1cffc693d9babee49cf1104b7bc8dd2214509369 (diff)
downloadart-android14-tests-dev.tar.gz
Revert "libnativebridge_test: link non-public libs statically" and fixandroid14-tests-dev
the CTS test to only call exported APIs. Reverts commit 7f5b3d89f21edd958ddb9d7bd01e03c77bd5425a. CTS tests need to link the libraries they test dynamically, and this test only tests exported stable APIs. The standalone CTS test config template includes NativeBridgeModuleController, so the test won't run in a translated environment (which has no proxy for this library and hence caused the error that prompted commit 7f5b3d89f21edd958ddb9d7bd01e03c77bd5425a). The test also used to test some non-exported APIs, which it shouldn't do in CTS. This changes it to use art_standalone_test_defaults, which doesn't have the test_for attributes that made it bypass the stub. Also reuse the trivial API-only tests for libnativebridge_lazy, and give them a more apt name for the new use. Test: atest art_libnativebridge_cts_tests \ libnativebridge-lazy-tests Test: art/libnativebridge/tests/runtests.sh Bug: 327407752 Bug: 328653757 Change-Id: Ib56148f1a651a9ffa3045bc401cc625e6f42416b Merged-In: Ib56148f1a651a9ffa3045bc401cc625e6f42416b (cherry picked from commit a87f1265e210615f7c90151f04a104a38067c196)
-rw-r--r--libnativebridge/tests/Android.bp51
-rw-r--r--libnativebridge/tests/libnativebridge_api_test.cpp (renamed from libnativebridge/tests/libnativebridge_lazy_test.cpp)15
2 files changed, 19 insertions, 47 deletions
diff --git a/libnativebridge/tests/Android.bp b/libnativebridge/tests/Android.bp
index f1725fc278..008ef5ccdf 100644
--- a/libnativebridge/tests/Android.bp
+++ b/libnativebridge/tests/Android.bp
@@ -82,14 +82,13 @@ cc_test_library {
defaults: ["libnativebridge-test-case-defaults"],
}
-cc_defaults {
- name: "libnativebridge-tests-defaults",
+cc_test {
+ name: "libnativebridge-tests",
defaults: [
"art_defaults",
"art_test_defaults",
],
- // TODO(mast): Split up art_gtest_defaults so that it can be used for the
- // following without pulling in lots of libs.
+
target: {
linux: {
cflags: [
@@ -100,11 +99,6 @@ cc_defaults {
],
},
},
-}
-
-cc_test {
- name: "libnativebridge-tests",
- defaults: ["libnativebridge-tests-defaults"],
// native_bridge.cc doesn't support reloading the native bridge after
// unloading, so each test needs to be its own process.
@@ -154,35 +148,14 @@ cc_test {
header_libs: ["libbase_headers"],
}
-// Variant of libnativebridge-tests that is part of CTS to verify backed-by API
-// coverage.
+// Very basic tests in CTS to verify backed-by API coverage of the exported API
+// in libnativebridge.map.txt.
cc_test {
name: "art_libnativebridge_cts_tests",
- defaults: [
- "art_standalone_test_defaults",
- "libnativebridge-tests-defaults",
- ],
-
- // TODO(b/189484095): Pick only a subset of the tests in
- // libnativebridge-tests that don't require the native bridge lib to be
- // loaded, to avoid the problems with test_per_src and pushing the extra
- // libnativebridge*-test-case.so files to device through tradefed.
- srcs: [
- // ValidNameNativeBridge_test.cpp needs to be first due to global state
- // had_error that isn't reset between tests.
- "ValidNameNativeBridge_test.cpp",
- "NeedsNativeBridge_test.cpp",
- "UnavailableNativeBridge_test.cpp",
- ],
- static_libs: [
- "libdl_android",
- "libnativebridge",
- ],
- shared_libs: [
- "liblog",
- ],
- header_libs: ["libbase_headers"],
-
+ defaults: ["art_standalone_test_defaults"],
+ shared_libs: ["libnativebridge"],
+ static_libs: ["libbase"],
+ srcs: ["libnativebridge_api_test.cpp"],
test_config_template: ":art-gtests-target-standalone-cts-template",
test_suites: [
"cts",
@@ -193,12 +166,10 @@ cc_test {
cc_test {
name: "libnativebridge-lazy-tests",
- defaults: ["libnativebridge-tests-defaults"],
- host_supported: false,
- test_suites: ["device-tests"],
+ defaults: ["art_standalone_test_defaults"],
static_libs: [
"libbase",
"libnativebridge_lazy",
],
- srcs: ["libnativebridge_lazy_test.cpp"],
+ srcs: ["libnativebridge_api_test.cpp"],
}
diff --git a/libnativebridge/tests/libnativebridge_lazy_test.cpp b/libnativebridge/tests/libnativebridge_api_test.cpp
index e1d66f53df..037587cd81 100644
--- a/libnativebridge/tests/libnativebridge_lazy_test.cpp
+++ b/libnativebridge/tests/libnativebridge_api_test.cpp
@@ -21,33 +21,34 @@
namespace android {
-class NativeBridgeLazyTest : public ::testing::Test {};
+class NativeBridgeApiTest : public ::testing::Test {};
+// Test the exported API in libnativebridge and libnativebridge_lazy.
// The testing we can do here is limited since there's no exported API to
// actually load the native bridge, but we only need to test the trivial
// wrappers.
-TEST_F(NativeBridgeLazyTest, NeedsNativeBridge) {
+TEST_F(NativeBridgeApiTest, NeedsNativeBridge) {
EXPECT_FALSE(NeedsNativeBridge(ABI_STRING));
}
-TEST_F(NativeBridgeLazyTest, PreInitializeNativeBridge) {
+TEST_F(NativeBridgeApiTest, PreInitializeNativeBridge) {
EXPECT_FALSE(PreInitializeNativeBridge(nullptr, ""));
}
-TEST_F(NativeBridgeLazyTest, NativeBridgeAvailable) {
+TEST_F(NativeBridgeApiTest, NativeBridgeAvailable) {
EXPECT_FALSE(NativeBridgeAvailable());
}
-TEST_F(NativeBridgeLazyTest, NativeBridgeInitialized) {
+TEST_F(NativeBridgeApiTest, NativeBridgeInitialized) {
EXPECT_FALSE(NativeBridgeInitialized());
}
-TEST_F(NativeBridgeLazyTest, NativeBridgeGetTrampoline) {
+TEST_F(NativeBridgeApiTest, NativeBridgeGetTrampoline) {
EXPECT_EQ(nullptr, NativeBridgeGetTrampoline(nullptr, nullptr, nullptr, 0));
}
-TEST_F(NativeBridgeLazyTest, NativeBridgeGetError) {
+TEST_F(NativeBridgeApiTest, NativeBridgeGetError) {
EXPECT_STREQ("native bridge is not initialized", NativeBridgeGetError());
}