mirror of
https://github.com/Evolution-X/hardware_interfaces
synced 2026-02-01 15:58:43 +00:00
Merge "Convert boot, memtrack and power hal to use service name aware testing."
am: b9515d9d3f
Change-Id: Ie93e66d9b829ac420ba22cf0391b48c156755c77
This commit is contained in:
@@ -22,6 +22,7 @@
|
||||
#include <android/hardware/boot/1.0/IBootControl.h>
|
||||
|
||||
#include <VtsHalHidlTargetTestBase.h>
|
||||
#include <VtsHalHidlTargetTestEnvBase.h>
|
||||
|
||||
using ::android::hardware::boot::V1_0::IBootControl;
|
||||
using ::android::hardware::boot::V1_0::CommandResult;
|
||||
@@ -33,12 +34,25 @@ using ::android::sp;
|
||||
using std::string;
|
||||
using std::vector;
|
||||
|
||||
// Test environment for Boot HIDL HAL.
|
||||
class BootHidlEnvironment : public ::testing::VtsHalHidlTargetTestEnvBase {
|
||||
public:
|
||||
// get the test environment singleton
|
||||
static BootHidlEnvironment* Instance() {
|
||||
static BootHidlEnvironment* instance = new BootHidlEnvironment;
|
||||
return instance;
|
||||
}
|
||||
|
||||
virtual void registerTestServices() override { registerTestService<IBootControl>(); }
|
||||
};
|
||||
|
||||
// The main test class for the Boot HIDL HAL.
|
||||
class BootHidlTest : public ::testing::VtsHalHidlTargetTestBase {
|
||||
public:
|
||||
virtual void SetUp() override {
|
||||
boot = ::testing::VtsHalHidlTargetTestBase::getService<IBootControl>();
|
||||
ASSERT_NE(boot, nullptr);
|
||||
boot = ::testing::VtsHalHidlTargetTestBase::getService<IBootControl>(
|
||||
BootHidlEnvironment::Instance()->getServiceName<IBootControl>());
|
||||
ASSERT_NE(boot, nullptr);
|
||||
}
|
||||
|
||||
virtual void TearDown() override {}
|
||||
@@ -171,8 +185,10 @@ TEST_F(BootHidlTest, GetSuffix) {
|
||||
}
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
::testing::InitGoogleTest(&argc, argv);
|
||||
int status = RUN_ALL_TESTS();
|
||||
LOG(INFO) << "Test result = " << status;
|
||||
return status;
|
||||
::testing::AddGlobalTestEnvironment(BootHidlEnvironment::Instance());
|
||||
::testing::InitGoogleTest(&argc, argv);
|
||||
BootHidlEnvironment::Instance()->init(&argc, argv);
|
||||
int status = RUN_ALL_TESTS();
|
||||
LOG(INFO) << "Test result = " << status;
|
||||
return status;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user