From ebae647f5c9af6f508d390f949c13aa9caa96af5 Mon Sep 17 00:00:00 2001 From: Zhuoyao Zhang Date: Thu, 8 Feb 2018 20:48:38 -0800 Subject: [PATCH] Convert contexthub hal test to use VtsHalHidlTargetTestEnvBase Bug: 64203181 Test: make vts vts-tradefed run vts -m VtsHalContexthubV1_0Target Change-Id: Iaf790e6d0fb96b421a1cd29417832ffaf9d01091 --- .../VtsHalContexthubV1_0TargetTest.cpp | 24 +++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/contexthub/1.0/vts/functional/VtsHalContexthubV1_0TargetTest.cpp b/contexthub/1.0/vts/functional/VtsHalContexthubV1_0TargetTest.cpp index 5672824d44..7492152095 100644 --- a/contexthub/1.0/vts/functional/VtsHalContexthubV1_0TargetTest.cpp +++ b/contexthub/1.0/vts/functional/VtsHalContexthubV1_0TargetTest.cpp @@ -17,6 +17,7 @@ #define LOG_TAG "contexthub_hidl_hal_test" #include +#include #include #include #include @@ -92,12 +93,27 @@ std::vector getHubIds() { return hubIds; } +// Test environment for Contexthub HIDL HAL. +class ContexthubHidlEnvironment : public ::testing::VtsHalHidlTargetTestEnvBase { + public: + // get the test environment singleton + static ContexthubHidlEnvironment* Instance() { + static ContexthubHidlEnvironment* instance = new ContexthubHidlEnvironment; + return instance; + } + + virtual void registerTestServices() override { registerTestService(); } + private: + ContexthubHidlEnvironment() {} +}; + // Base test fixture that initializes the HAL and makes the context hub API // handle available class ContexthubHidlTestBase : public ::testing::VtsHalHidlTargetTestBase { public: virtual void SetUp() override { - hubApi = ::testing::VtsHalHidlTargetTestBase::getService(); + hubApi = ::testing::VtsHalHidlTargetTestBase::getService( + ContexthubHidlEnvironment::Instance()->getServiceName()); ASSERT_NE(hubApi, nullptr); // getHubs() must be called at least once for proper initialization of the @@ -381,7 +397,11 @@ INSTANTIATE_TEST_CASE_P(HubIdSpecificTests, ContexthubTxnTest, } // anonymous namespace int main(int argc, char **argv) { + ::testing::AddGlobalTestEnvironment(ContexthubHidlEnvironment::Instance()); ::testing::InitGoogleTest(&argc, argv); - return RUN_ALL_TESTS(); + ContexthubHidlEnvironment::Instance()->init(&argc, argv); + int status = RUN_ALL_TESTS(); + ALOGI ("Test result = %d", status); + return status; }