diff options
author | Devin Moore <devinmoore@google.com> | 2023-11-28 21:40:06 +0000 |
---|---|---|
committer | Devin Moore <devinmoore@google.com> | 2023-11-28 21:44:28 +0000 |
commit | d0b8ff93f54d535433c662c590da6635f309b35d (patch) | |
tree | 947ed46121b30518b37d382661b60a53e2ff9cf2 | |
parent | 3d1f9b0bc918bf74dbe585076fce59152170e385 (diff) | |
download | hidl-d0b8ff93f54d535433c662c590da6635f309b35d.tar.gz |
Skip these lazy tests when HIDL is not supported
The services won't be installed or registered in this case, so skip the
tests.
The libs need to be included statically because the services will no
longer be installed on the device and will not bring those dependencies.
Test: atest hidl_lazy_test
Bug: 218588089
Change-Id: I3f4a38f6099ad601c464507fa73f953c71dddcac
-rw-r--r-- | test/lazy_test/Android.bp | 8 | ||||
-rw-r--r-- | test/lazy_test/hidl_lazy_test.cpp | 10 |
2 files changed, 15 insertions, 3 deletions
diff --git a/test/lazy_test/Android.bp b/test/lazy_test/Android.bp index 801c9e61..457b7c8f 100644 --- a/test/lazy_test/Android.bp +++ b/test/lazy_test/Android.bp @@ -13,9 +13,6 @@ cc_test { srcs: ["hidl_lazy_test.cpp"], shared_libs: [ - "android.hardware.tests.lazy@1.0", - "android.hardware.tests.lazy@1.1", - "android.hardware.tests.lazy_cb@1.0", "libbase", "libcutils", "libhidl-gen-utils", @@ -23,6 +20,11 @@ cc_test { "liblog", "libutils", ], + static_libs: [ + "android.hardware.tests.lazy@1.0", + "android.hardware.tests.lazy@1.1", + "android.hardware.tests.lazy_cb@1.0", + ], test_suites: ["general-tests"], require_root: true, diff --git a/test/lazy_test/hidl_lazy_test.cpp b/test/lazy_test/hidl_lazy_test.cpp index 4f27463f..4047bec3 100644 --- a/test/lazy_test/hidl_lazy_test.cpp +++ b/test/lazy_test/hidl_lazy_test.cpp @@ -36,6 +36,7 @@ #include <hidl/HidlSupport.h> #include <hidl/HidlTransportSupport.h> #include <hidl/HidlTransportUtils.h> +#include <hidl/ServiceManagement.h> #include <hwbinder/IPCThreadState.h> using ::android::FqInstance; @@ -88,6 +89,8 @@ class HidlLazyTestBase : public ::testing::Test { class HidlLazyTest : public HidlLazyTestBase { protected: void SetUp() override { + if (!android::hardware::isHidlSupported()) + GTEST_SKIP() << "HIDL is not supported on this device"; HidlLazyTestBase::SetUp(); for (const auto& instance : gInstances) { ASSERT_FALSE(isServiceRunning(instance)) @@ -99,6 +102,8 @@ class HidlLazyTest : public HidlLazyTestBase { } void TearDown() override { + // If we skipped the setup, then we skip the TearDown. + if (!android::hardware::isHidlSupported()) return; std::cout << "Waiting " << SHUTDOWN_WAIT_TIME << " seconds before checking that the " << "service has shut down." << std::endl; IPCThreadState::self()->flushCommands(); @@ -114,6 +119,11 @@ class HidlLazyTest : public HidlLazyTestBase { class HidlLazyCbTest : public HidlLazyTestBase { protected: static constexpr size_t CALLBACK_SHUTDOWN_WAIT_TIME = 5; + void SetUp() override { + if (!android::hardware::isHidlSupported()) + GTEST_SKIP() << "HIDL is not supported on this device"; + HidlLazyTestBase::SetUp(); + } }; static constexpr size_t NUM_IMMEDIATE_GET_UNGETS = 100; |