summaryrefslogtreecommitdiffstats
path: root/power
diff options
context:
space:
mode:
authorZhuoyao Zhang <zhuoyao@google.com>2017-11-20 17:36:47 -0800
committerZhuoyao Zhang <zhuoyao@google.com>2017-12-04 21:34:25 +0000
commit2aba02af56bee0cb756ee4a47cf77b54d380476f (patch)
tree1154c67a73646cd70bfdea20494dcfc5283c079d /power
parent9272727df8c5e42f3afd1315b1018f2af8ccca90 (diff)
downloadandroid_hardware_interfaces-2aba02af56bee0cb756ee4a47cf77b54d380476f.tar.gz
android_hardware_interfaces-2aba02af56bee0cb756ee4a47cf77b54d380476f.tar.bz2
android_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 'power')
-rw-r--r--power/1.0/vts/functional/VtsHalPowerV1_0TargetTest.cpp28
-rw-r--r--power/1.1/vts/functional/VtsHalPowerV1_1TargetTest.cpp28
2 files changed, 44 insertions, 12 deletions
diff --git a/power/1.0/vts/functional/VtsHalPowerV1_0TargetTest.cpp b/power/1.0/vts/functional/VtsHalPowerV1_0TargetTest.cpp
index da49dfcf3..999b2b420 100644
--- a/power/1.0/vts/functional/VtsHalPowerV1_0TargetTest.cpp
+++ b/power/1.0/vts/functional/VtsHalPowerV1_0TargetTest.cpp
@@ -23,6 +23,7 @@
#include <android/hardware/power/1.0/IPower.h>
#include <VtsHalHidlTargetTestBase.h>
+#include <VtsHalHidlTargetTestEnvBase.h>
#include <fcntl.h>
#include <algorithm>
@@ -44,11 +45,24 @@ using std::vector;
#define AVAILABLE_GOVERNORS_PATH \
"/sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors"
+// Test environment for Power HIDL HAL.
+class PowerHidlEnvironment : public ::testing::VtsHalHidlTargetTestEnvBase {
+ public:
+ // get the test environment singleton
+ static PowerHidlEnvironment* Instance() {
+ static PowerHidlEnvironment* instance = new PowerHidlEnvironment;
+ return instance;
+ }
+
+ virtual void registerTestServices() override { registerTestService<IPower>(); }
+};
+
class PowerHidlTest : public ::testing::VtsHalHidlTargetTestBase {
public:
virtual void SetUp() override {
- power = ::testing::VtsHalHidlTargetTestBase::getService<IPower>();
- ASSERT_NE(power, nullptr);
+ power = ::testing::VtsHalHidlTargetTestBase::getService<IPower>(
+ PowerHidlEnvironment::Instance()->getServiceName<IPower>());
+ ASSERT_NE(power, nullptr);
}
virtual void TearDown() override {}
@@ -178,8 +192,10 @@ TEST_F(PowerHidlTest, GetPlatformLowPowerStats) {
}
int main(int argc, char **argv) {
- ::testing::InitGoogleTest(&argc, argv);
- int status = RUN_ALL_TESTS();
- LOG(INFO) << "Test result = " << status;
- return status;
+ ::testing::AddGlobalTestEnvironment(PowerHidlEnvironment::Instance());
+ ::testing::InitGoogleTest(&argc, argv);
+ PowerHidlEnvironment::Instance()->init(&argc, argv);
+ int status = RUN_ALL_TESTS();
+ LOG(INFO) << "Test result = " << status;
+ return status;
}
diff --git a/power/1.1/vts/functional/VtsHalPowerV1_1TargetTest.cpp b/power/1.1/vts/functional/VtsHalPowerV1_1TargetTest.cpp
index dc843f49d..4427b1550 100644
--- a/power/1.1/vts/functional/VtsHalPowerV1_1TargetTest.cpp
+++ b/power/1.1/vts/functional/VtsHalPowerV1_1TargetTest.cpp
@@ -19,6 +19,7 @@
#include <android/hardware/power/1.1/IPower.h>
#include <VtsHalHidlTargetTestBase.h>
+#include <VtsHalHidlTargetTestEnvBase.h>
using ::android::hardware::power::V1_1::IPower;
using ::android::hardware::power::V1_1::PowerStateSubsystem;
@@ -28,11 +29,24 @@ using ::android::hardware::hidl_vec;
using ::android::hardware::Return;
using ::android::sp;
+// Test environment for Power HIDL HAL.
+class PowerHidlEnvironment : public ::testing::VtsHalHidlTargetTestEnvBase {
+ public:
+ // get the test environment singleton
+ static PowerHidlEnvironment* Instance() {
+ static PowerHidlEnvironment* instance = new PowerHidlEnvironment;
+ return instance;
+ }
+
+ virtual void registerTestServices() override { registerTestService<IPower>(); }
+};
+
class PowerHidlTest : public ::testing::VtsHalHidlTargetTestBase {
public:
virtual void SetUp() override {
- power = ::testing::VtsHalHidlTargetTestBase::getService<IPower>();
- ASSERT_NE(power, nullptr);
+ power = ::testing::VtsHalHidlTargetTestBase::getService<IPower>(
+ PowerHidlEnvironment::Instance()->getServiceName<IPower>());
+ ASSERT_NE(power, nullptr);
}
virtual void TearDown() override {}
@@ -91,8 +105,10 @@ TEST_F(PowerHidlTest, PowerHintAsync) {
}
int main(int argc, char **argv) {
- ::testing::InitGoogleTest(&argc, argv);
- int status = RUN_ALL_TESTS();
- LOG(INFO) << "Test result = " << status;
- return status;
+ ::testing::AddGlobalTestEnvironment(PowerHidlEnvironment::Instance());
+ ::testing::InitGoogleTest(&argc, argv);
+ PowerHidlEnvironment::Instance()->init(&argc, argv);
+ int status = RUN_ALL_TESTS();
+ LOG(INFO) << "Test result = " << status;
+ return status;
}