diff options
4 files changed, 88 insertions, 24 deletions
diff --git a/boot/1.0/vts/functional/VtsHalBootV1_0TargetTest.cpp b/boot/1.0/vts/functional/VtsHalBootV1_0TargetTest.cpp index f48a95d8..d1d7f73b 100644 --- a/boot/1.0/vts/functional/VtsHalBootV1_0TargetTest.cpp +++ b/boot/1.0/vts/functional/VtsHalBootV1_0TargetTest.cpp | |||
@@ -22,6 +22,7 @@ | |||
22 | #include <android/hardware/boot/1.0/IBootControl.h> | 22 | #include <android/hardware/boot/1.0/IBootControl.h> |
23 | 23 | ||
24 | #include <VtsHalHidlTargetTestBase.h> | 24 | #include <VtsHalHidlTargetTestBase.h> |
25 | #include <VtsHalHidlTargetTestEnvBase.h> | ||
25 | 26 | ||
26 | using ::android::hardware::boot::V1_0::IBootControl; | 27 | using ::android::hardware::boot::V1_0::IBootControl; |
27 | using ::android::hardware::boot::V1_0::CommandResult; | 28 | using ::android::hardware::boot::V1_0::CommandResult; |
@@ -33,12 +34,25 @@ using ::android::sp; | |||
33 | using std::string; | 34 | using std::string; |
34 | using std::vector; | 35 | using std::vector; |
35 | 36 | ||
37 | // Test environment for Boot HIDL HAL. | ||
38 | class BootHidlEnvironment : public ::testing::VtsHalHidlTargetTestEnvBase { | ||
39 | public: | ||
40 | // get the test environment singleton | ||
41 | static BootHidlEnvironment* Instance() { | ||
42 | static BootHidlEnvironment* instance = new BootHidlEnvironment; | ||
43 | return instance; | ||
44 | } | ||
45 | |||
46 | virtual void registerTestServices() override { registerTestService<IBootControl>(); } | ||
47 | }; | ||
48 | |||
36 | // The main test class for the Boot HIDL HAL. | 49 | // The main test class for the Boot HIDL HAL. |
37 | class BootHidlTest : public ::testing::VtsHalHidlTargetTestBase { | 50 | class BootHidlTest : public ::testing::VtsHalHidlTargetTestBase { |
38 | public: | 51 | public: |
39 | virtual void SetUp() override { | 52 | virtual void SetUp() override { |
40 | boot = ::testing::VtsHalHidlTargetTestBase::getService<IBootControl>(); | 53 | boot = ::testing::VtsHalHidlTargetTestBase::getService<IBootControl>( |
41 | ASSERT_NE(boot, nullptr); | 54 | BootHidlEnvironment::Instance()->getServiceName<IBootControl>()); |
55 | ASSERT_NE(boot, nullptr); | ||
42 | } | 56 | } |
43 | 57 | ||
44 | virtual void TearDown() override {} | 58 | virtual void TearDown() override {} |
@@ -171,8 +185,10 @@ TEST_F(BootHidlTest, GetSuffix) { | |||
171 | } | 185 | } |
172 | 186 | ||
173 | int main(int argc, char **argv) { | 187 | int main(int argc, char **argv) { |
174 | ::testing::InitGoogleTest(&argc, argv); | 188 | ::testing::AddGlobalTestEnvironment(BootHidlEnvironment::Instance()); |
175 | int status = RUN_ALL_TESTS(); | 189 | ::testing::InitGoogleTest(&argc, argv); |
176 | LOG(INFO) << "Test result = " << status; | 190 | BootHidlEnvironment::Instance()->init(&argc, argv); |
177 | return status; | 191 | int status = RUN_ALL_TESTS(); |
192 | LOG(INFO) << "Test result = " << status; | ||
193 | return status; | ||
178 | } | 194 | } |
diff --git a/memtrack/1.0/vts/functional/VtsHalMemtrackV1_0TargetTest.cpp b/memtrack/1.0/vts/functional/VtsHalMemtrackV1_0TargetTest.cpp index 6ff566e7..691ecca1 100644 --- a/memtrack/1.0/vts/functional/VtsHalMemtrackV1_0TargetTest.cpp +++ b/memtrack/1.0/vts/functional/VtsHalMemtrackV1_0TargetTest.cpp | |||
@@ -21,6 +21,7 @@ | |||
21 | #include <android/hardware/memtrack/1.0/IMemtrack.h> | 21 | #include <android/hardware/memtrack/1.0/IMemtrack.h> |
22 | 22 | ||
23 | #include <VtsHalHidlTargetTestBase.h> | 23 | #include <VtsHalHidlTargetTestBase.h> |
24 | #include <VtsHalHidlTargetTestEnvBase.h> | ||
24 | 25 | ||
25 | #include <fcntl.h> | 26 | #include <fcntl.h> |
26 | #include <algorithm> | 27 | #include <algorithm> |
@@ -38,11 +39,24 @@ using ::android::base::unique_fd; | |||
38 | using std::vector; | 39 | using std::vector; |
39 | using std::count_if; | 40 | using std::count_if; |
40 | 41 | ||
42 | // Test environment for Memtrack HIDL HAL. | ||
43 | class MemtrackHidlEnvironment : public ::testing::VtsHalHidlTargetTestEnvBase { | ||
44 | public: | ||
45 | // get the test environment singleton | ||
46 | static MemtrackHidlEnvironment* Instance() { | ||
47 | static MemtrackHidlEnvironment* instance = new MemtrackHidlEnvironment; | ||
48 | return instance; | ||
49 | } | ||
50 | |||
51 | virtual void registerTestServices() override { registerTestService<IMemtrack>(); } | ||
52 | }; | ||
53 | |||
41 | class MemtrackHidlTest : public ::testing::VtsHalHidlTargetTestBase { | 54 | class MemtrackHidlTest : public ::testing::VtsHalHidlTargetTestBase { |
42 | public: | 55 | public: |
43 | virtual void SetUp() override { | 56 | virtual void SetUp() override { |
44 | memtrack = ::testing::VtsHalHidlTargetTestBase::getService<IMemtrack>(); | 57 | memtrack = ::testing::VtsHalHidlTargetTestBase::getService<IMemtrack>( |
45 | ASSERT_NE(memtrack, nullptr); | 58 | MemtrackHidlEnvironment::Instance()->getServiceName<IMemtrack>()); |
59 | ASSERT_NE(memtrack, nullptr); | ||
46 | } | 60 | } |
47 | 61 | ||
48 | virtual void TearDown() override {} | 62 | virtual void TearDown() override {} |
@@ -159,8 +173,10 @@ TEST_F(MemtrackHidlTest, GetMemoryTest) { | |||
159 | } | 173 | } |
160 | 174 | ||
161 | int main(int argc, char **argv) { | 175 | int main(int argc, char **argv) { |
162 | ::testing::InitGoogleTest(&argc, argv); | 176 | ::testing::AddGlobalTestEnvironment(MemtrackHidlEnvironment::Instance()); |
163 | int status = RUN_ALL_TESTS(); | 177 | ::testing::InitGoogleTest(&argc, argv); |
164 | LOG(INFO) << "Test result = " << status; | 178 | MemtrackHidlEnvironment::Instance()->init(&argc, argv); |
165 | return status; | 179 | int status = RUN_ALL_TESTS(); |
180 | LOG(INFO) << "Test result = " << status; | ||
181 | return status; | ||
166 | } | 182 | } |
diff --git a/power/1.0/vts/functional/VtsHalPowerV1_0TargetTest.cpp b/power/1.0/vts/functional/VtsHalPowerV1_0TargetTest.cpp index da49dfcf..999b2b42 100644 --- a/power/1.0/vts/functional/VtsHalPowerV1_0TargetTest.cpp +++ b/power/1.0/vts/functional/VtsHalPowerV1_0TargetTest.cpp | |||
@@ -23,6 +23,7 @@ | |||
23 | #include <android/hardware/power/1.0/IPower.h> | 23 | #include <android/hardware/power/1.0/IPower.h> |
24 | 24 | ||
25 | #include <VtsHalHidlTargetTestBase.h> | 25 | #include <VtsHalHidlTargetTestBase.h> |
26 | #include <VtsHalHidlTargetTestEnvBase.h> | ||
26 | 27 | ||
27 | #include <fcntl.h> | 28 | #include <fcntl.h> |
28 | #include <algorithm> | 29 | #include <algorithm> |
@@ -44,11 +45,24 @@ using std::vector; | |||
44 | #define AVAILABLE_GOVERNORS_PATH \ | 45 | #define AVAILABLE_GOVERNORS_PATH \ |
45 | "/sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors" | 46 | "/sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors" |
46 | 47 | ||
48 | // Test environment for Power HIDL HAL. | ||
49 | class PowerHidlEnvironment : public ::testing::VtsHalHidlTargetTestEnvBase { | ||
50 | public: | ||
51 | // get the test environment singleton | ||
52 | static PowerHidlEnvironment* Instance() { | ||
53 | static PowerHidlEnvironment* instance = new PowerHidlEnvironment; | ||
54 | return instance; | ||
55 | } | ||
56 | |||
57 | virtual void registerTestServices() override { registerTestService<IPower>(); } | ||
58 | }; | ||
59 | |||
47 | class PowerHidlTest : public ::testing::VtsHalHidlTargetTestBase { | 60 | class PowerHidlTest : public ::testing::VtsHalHidlTargetTestBase { |
48 | public: | 61 | public: |
49 | virtual void SetUp() override { | 62 | virtual void SetUp() override { |
50 | power = ::testing::VtsHalHidlTargetTestBase::getService<IPower>(); | 63 | power = ::testing::VtsHalHidlTargetTestBase::getService<IPower>( |
51 | ASSERT_NE(power, nullptr); | 64 | PowerHidlEnvironment::Instance()->getServiceName<IPower>()); |
65 | ASSERT_NE(power, nullptr); | ||
52 | } | 66 | } |
53 | 67 | ||
54 | virtual void TearDown() override {} | 68 | virtual void TearDown() override {} |
@@ -178,8 +192,10 @@ TEST_F(PowerHidlTest, GetPlatformLowPowerStats) { | |||
178 | } | 192 | } |
179 | 193 | ||
180 | int main(int argc, char **argv) { | 194 | int main(int argc, char **argv) { |
181 | ::testing::InitGoogleTest(&argc, argv); | 195 | ::testing::AddGlobalTestEnvironment(PowerHidlEnvironment::Instance()); |
182 | int status = RUN_ALL_TESTS(); | 196 | ::testing::InitGoogleTest(&argc, argv); |
183 | LOG(INFO) << "Test result = " << status; | 197 | PowerHidlEnvironment::Instance()->init(&argc, argv); |
184 | return status; | 198 | int status = RUN_ALL_TESTS(); |
199 | LOG(INFO) << "Test result = " << status; | ||
200 | return status; | ||
185 | } | 201 | } |
diff --git a/power/1.1/vts/functional/VtsHalPowerV1_1TargetTest.cpp b/power/1.1/vts/functional/VtsHalPowerV1_1TargetTest.cpp index dc843f49..4427b155 100644 --- a/power/1.1/vts/functional/VtsHalPowerV1_1TargetTest.cpp +++ b/power/1.1/vts/functional/VtsHalPowerV1_1TargetTest.cpp | |||
@@ -19,6 +19,7 @@ | |||
19 | #include <android/hardware/power/1.1/IPower.h> | 19 | #include <android/hardware/power/1.1/IPower.h> |
20 | 20 | ||
21 | #include <VtsHalHidlTargetTestBase.h> | 21 | #include <VtsHalHidlTargetTestBase.h> |
22 | #include <VtsHalHidlTargetTestEnvBase.h> | ||
22 | 23 | ||
23 | using ::android::hardware::power::V1_1::IPower; | 24 | using ::android::hardware::power::V1_1::IPower; |
24 | using ::android::hardware::power::V1_1::PowerStateSubsystem; | 25 | using ::android::hardware::power::V1_1::PowerStateSubsystem; |
@@ -28,11 +29,24 @@ using ::android::hardware::hidl_vec; | |||
28 | using ::android::hardware::Return; | 29 | using ::android::hardware::Return; |
29 | using ::android::sp; | 30 | using ::android::sp; |
30 | 31 | ||
32 | // Test environment for Power HIDL HAL. | ||
33 | class PowerHidlEnvironment : public ::testing::VtsHalHidlTargetTestEnvBase { | ||
34 | public: | ||
35 | // get the test environment singleton | ||
36 | static PowerHidlEnvironment* Instance() { | ||
37 | static PowerHidlEnvironment* instance = new PowerHidlEnvironment; | ||
38 | return instance; | ||
39 | } | ||
40 | |||
41 | virtual void registerTestServices() override { registerTestService<IPower>(); } | ||
42 | }; | ||
43 | |||
31 | class PowerHidlTest : public ::testing::VtsHalHidlTargetTestBase { | 44 | class PowerHidlTest : public ::testing::VtsHalHidlTargetTestBase { |
32 | public: | 45 | public: |
33 | virtual void SetUp() override { | 46 | virtual void SetUp() override { |
34 | power = ::testing::VtsHalHidlTargetTestBase::getService<IPower>(); | 47 | power = ::testing::VtsHalHidlTargetTestBase::getService<IPower>( |
35 | ASSERT_NE(power, nullptr); | 48 | PowerHidlEnvironment::Instance()->getServiceName<IPower>()); |
49 | ASSERT_NE(power, nullptr); | ||
36 | } | 50 | } |
37 | 51 | ||
38 | virtual void TearDown() override {} | 52 | virtual void TearDown() override {} |
@@ -91,8 +105,10 @@ TEST_F(PowerHidlTest, PowerHintAsync) { | |||
91 | } | 105 | } |
92 | 106 | ||
93 | int main(int argc, char **argv) { | 107 | int main(int argc, char **argv) { |
94 | ::testing::InitGoogleTest(&argc, argv); | 108 | ::testing::AddGlobalTestEnvironment(PowerHidlEnvironment::Instance()); |
95 | int status = RUN_ALL_TESTS(); | 109 | ::testing::InitGoogleTest(&argc, argv); |
96 | LOG(INFO) << "Test result = " << status; | 110 | PowerHidlEnvironment::Instance()->init(&argc, argv); |
97 | return status; | 111 | int status = RUN_ALL_TESTS(); |
112 | LOG(INFO) << "Test result = " << status; | ||
113 | return status; | ||
98 | } | 114 | } |