diff options
author | Zhuoyao Zhang <zhuoyao@google.com> | 2018-02-08 21:08:03 -0800 |
---|---|---|
committer | Zhuoyao Zhang <zhuoyao@google.com> | 2018-02-12 22:57:05 +0000 |
commit | b51d4b2fb0892b327bd73f0a23a220b0fb2846d9 (patch) | |
tree | 7d83b17b3e190d40edcb8bb81fe280405607fad5 /tetheroffload | |
parent | 8f7ff5730b152542d476b039b15601785e3b777a (diff) | |
download | platform_hardware_interfaces-b51d4b2fb0892b327bd73f0a23a220b0fb2846d9.tar.gz platform_hardware_interfaces-b51d4b2fb0892b327bd73f0a23a220b0fb2846d9.tar.bz2 platform_hardware_interfaces-b51d4b2fb0892b327bd73f0a23a220b0fb2846d9.zip |
Convert tetheroffload hal test to use VtsHalHidlTargetTestEnvBase
* This allow VTS to test tetheroffload hal against all service
implmentations registered with different service name.
Bug: 64203181
Test: make vts
vts-tradefed run vts -m VtsHalTetherOffloadConfigV1_0Target
vts-tradefed run vts -m VtsHalTetherOffloadControlV1_0Target
Change-Id: I0b4f3cf4abd3ffbd15cef7c2126ce6252a65a28e
Diffstat (limited to 'tetheroffload')
-rw-r--r-- | tetheroffload/config/1.0/vts/functional/VtsHalTetheroffloadConfigV1_0TargetTest.cpp | 22 | ||||
-rw-r--r-- | tetheroffload/control/1.0/vts/functional/VtsHalTetheroffloadControlV1_0TargetTest.cpp | 28 |
2 files changed, 45 insertions, 5 deletions
diff --git a/tetheroffload/config/1.0/vts/functional/VtsHalTetheroffloadConfigV1_0TargetTest.cpp b/tetheroffload/config/1.0/vts/functional/VtsHalTetheroffloadConfigV1_0TargetTest.cpp index 2cbe479dc9..0ee9eb4eea 100644 --- a/tetheroffload/config/1.0/vts/functional/VtsHalTetheroffloadConfigV1_0TargetTest.cpp +++ b/tetheroffload/config/1.0/vts/functional/VtsHalTetheroffloadConfigV1_0TargetTest.cpp @@ -17,6 +17,7 @@ #define LOG_TAG "VtsOffloadConfigV1_0TargetTest" #include <VtsHalHidlTargetTestBase.h> +#include <VtsHalHidlTargetTestEnvBase.h> #include <android-base/stringprintf.h> #include <android-base/unique_fd.h> #include <android/hardware/tetheroffload/config/1.0/IOffloadConfig.h> @@ -77,10 +78,25 @@ int netlinkSocket(unsigned groups) { return netlinkSocket(NETLINK_NETFILTER, groups); } +// Test environment for OffloadConfig HIDL HAL. +class OffloadConfigHidlEnvironment : public ::testing::VtsHalHidlTargetTestEnvBase { + public: + // get the test environment singleton + static OffloadConfigHidlEnvironment* Instance() { + static OffloadConfigHidlEnvironment* instance = new OffloadConfigHidlEnvironment; + return instance; + } + + virtual void registerTestServices() override { registerTestService<IOffloadConfig>(); } + private: + OffloadConfigHidlEnvironment() {} +}; + class OffloadConfigHidlTest : public testing::VtsHalHidlTargetTestBase { public: virtual void SetUp() override { - config = testing::VtsHalHidlTargetTestBase::getService<IOffloadConfig>(); + config = testing::VtsHalHidlTargetTestBase::getService<IOffloadConfig>( + OffloadConfigHidlEnvironment::Instance()->getServiceName<IOffloadConfig>()); ASSERT_NE(nullptr, config.get()) << "Could not get HIDL instance"; } @@ -175,7 +191,9 @@ TEST_F(OffloadConfigHidlTest, TestSetHandle2OnlyNotOk) { } int main(int argc, char** argv) { - testing::InitGoogleTest(&argc, argv); + ::testing::AddGlobalTestEnvironment(OffloadConfigHidlEnvironment::Instance()); + ::testing::InitGoogleTest(&argc, argv); + OffloadConfigHidlEnvironment::Instance()->init(&argc, argv); int status = RUN_ALL_TESTS(); ALOGE("Test result with status=%d", status); return status; diff --git a/tetheroffload/control/1.0/vts/functional/VtsHalTetheroffloadControlV1_0TargetTest.cpp b/tetheroffload/control/1.0/vts/functional/VtsHalTetheroffloadControlV1_0TargetTest.cpp index c009af5d91..c5e8021801 100644 --- a/tetheroffload/control/1.0/vts/functional/VtsHalTetheroffloadControlV1_0TargetTest.cpp +++ b/tetheroffload/control/1.0/vts/functional/VtsHalTetheroffloadControlV1_0TargetTest.cpp @@ -18,6 +18,7 @@ #include <VtsHalHidlTargetCallbackBase.h> #include <VtsHalHidlTargetTestBase.h> +#include <VtsHalHidlTargetTestEnvBase.h> #include <android-base/stringprintf.h> #include <android-base/unique_fd.h> #include <android/hardware/tetheroffload/config/1.0/IOffloadConfig.h> @@ -111,6 +112,23 @@ class TetheringOffloadCallbackArgs { NatTimeoutUpdate last_params; }; +// Test environment for OffloadControl HIDL HAL. +class OffloadControlHidlEnvironment : public ::testing::VtsHalHidlTargetTestEnvBase { + public: + // get the test environment singleton + static OffloadControlHidlEnvironment* Instance() { + static OffloadControlHidlEnvironment* instance = new OffloadControlHidlEnvironment; + return instance; + } + + virtual void registerTestServices() override { + registerTestService<IOffloadConfig>(); + registerTestService<IOffloadControl>(); + } + private: + OffloadControlHidlEnvironment() {} +}; + class OffloadControlHidlTestBase : public testing::VtsHalHidlTargetTestBase { public: virtual void SetUp() override { @@ -128,7 +146,8 @@ class OffloadControlHidlTestBase : public testing::VtsHalHidlTargetTestBase { // The IOffloadConfig HAL is tested more thoroughly elsewhere. He we just // setup everything correctly and verify basic readiness. void setupConfigHal() { - config = testing::VtsHalHidlTargetTestBase::getService<IOffloadConfig>(); + config = testing::VtsHalHidlTargetTestBase::getService<IOffloadConfig>( + OffloadControlHidlEnvironment::Instance()->getServiceName<IOffloadConfig>()); ASSERT_NE(nullptr, config.get()) << "Could not get HIDL instance"; unique_fd fd1(conntrackSocket(NFNLGRP_CONNTRACK_NEW | NFNLGRP_CONNTRACK_DESTROY)); @@ -156,7 +175,8 @@ class OffloadControlHidlTestBase : public testing::VtsHalHidlTargetTestBase { } void prepareControlHal() { - control = testing::VtsHalHidlTargetTestBase::getService<IOffloadControl>(); + control = testing::VtsHalHidlTargetTestBase::getService<IOffloadControl>( + OffloadControlHidlEnvironment::Instance()->getServiceName<IOffloadControl>()); ASSERT_NE(nullptr, control.get()) << "Could not get HIDL instance"; control_cb = new TetheringOffloadCallback(); @@ -660,7 +680,9 @@ TEST_F(OffloadControlHidlTest, RemoveDownstreamBogusPrefixFails) { } int main(int argc, char** argv) { - testing::InitGoogleTest(&argc, argv); + ::testing::AddGlobalTestEnvironment(OffloadControlHidlEnvironment::Instance()); + ::testing::InitGoogleTest(&argc, argv); + OffloadControlHidlEnvironment::Instance()->init(&argc, argv); int status = RUN_ALL_TESTS(); ALOGE("Test result with status=%d", status); return status; |