diff options
author | Zhuoyao Zhang <zhuoyao@google.com> | 2017-11-20 17:36:47 -0800 |
---|---|---|
committer | Zhuoyao Zhang <zhuoyao@google.com> | 2017-12-04 21:34:25 +0000 |
commit | 2aba02af56bee0cb756ee4a47cf77b54d380476f (patch) | |
tree | 1154c67a73646cd70bfdea20494dcfc5283c079d /memtrack | |
parent | 9272727df8c5e42f3afd1315b1018f2af8ccca90 (diff) | |
download | platform_hardware_interfaces-2aba02af56bee0cb756ee4a47cf77b54d380476f.tar.gz platform_hardware_interfaces-2aba02af56bee0cb756ee4a47cf77b54d380476f.tar.bz2 platform_hardware_interfaces-2aba02af56bee0cb756ee4a47cf77b54d380476f.zip |
Convert boot, memtrack and power hal to use service name aware testing.
Motivation:
1) Support running the test against each hal service instance for the
registered hal.
2) Support testability checker to determine whether we should run the
test on the taget device.
3) Help to determine the process we want to profile for coverage data
if running on coverage build.
Bug: 64203181
Test: make vts
vts-tradefed run vts -m VtsHalBootV1_0Target
vts-tradefed run vts -m VtsHalMemtrackV1_0Target
vts-tradefed run vts -m VtsHalPowerV1_0Target
vts-tradefed run vts -m VtsHalPowerV1_1Target
Change-Id: Ie0bbd9ef9d9fbe11de5aee70fad9028fa0ae897c
Diffstat (limited to 'memtrack')
-rw-r--r-- | memtrack/1.0/vts/functional/VtsHalMemtrackV1_0TargetTest.cpp | 28 |
1 files changed, 22 insertions, 6 deletions
diff --git a/memtrack/1.0/vts/functional/VtsHalMemtrackV1_0TargetTest.cpp b/memtrack/1.0/vts/functional/VtsHalMemtrackV1_0TargetTest.cpp index 6ff566e7d7..691ecca17d 100644 --- a/memtrack/1.0/vts/functional/VtsHalMemtrackV1_0TargetTest.cpp +++ b/memtrack/1.0/vts/functional/VtsHalMemtrackV1_0TargetTest.cpp @@ -21,6 +21,7 @@ #include <android/hardware/memtrack/1.0/IMemtrack.h> #include <VtsHalHidlTargetTestBase.h> +#include <VtsHalHidlTargetTestEnvBase.h> #include <fcntl.h> #include <algorithm> @@ -38,11 +39,24 @@ using ::android::base::unique_fd; using std::vector; using std::count_if; +// Test environment for Memtrack HIDL HAL. +class MemtrackHidlEnvironment : public ::testing::VtsHalHidlTargetTestEnvBase { + public: + // get the test environment singleton + static MemtrackHidlEnvironment* Instance() { + static MemtrackHidlEnvironment* instance = new MemtrackHidlEnvironment; + return instance; + } + + virtual void registerTestServices() override { registerTestService<IMemtrack>(); } +}; + class MemtrackHidlTest : public ::testing::VtsHalHidlTargetTestBase { public: virtual void SetUp() override { - memtrack = ::testing::VtsHalHidlTargetTestBase::getService<IMemtrack>(); - ASSERT_NE(memtrack, nullptr); + memtrack = ::testing::VtsHalHidlTargetTestBase::getService<IMemtrack>( + MemtrackHidlEnvironment::Instance()->getServiceName<IMemtrack>()); + ASSERT_NE(memtrack, nullptr); } virtual void TearDown() override {} @@ -159,8 +173,10 @@ TEST_F(MemtrackHidlTest, GetMemoryTest) { } int main(int argc, char **argv) { - ::testing::InitGoogleTest(&argc, argv); - int status = RUN_ALL_TESTS(); - LOG(INFO) << "Test result = " << status; - return status; + ::testing::AddGlobalTestEnvironment(MemtrackHidlEnvironment::Instance()); + ::testing::InitGoogleTest(&argc, argv); + MemtrackHidlEnvironment::Instance()->init(&argc, argv); + int status = RUN_ALL_TESTS(); + LOG(INFO) << "Test result = " << status; + return status; } |