Merge "Convert VtsHalPowerV1_*TargetTest to be parameterized test"
am: 6ba951f674
Change-Id: I5439fe3b04128043d2982a33b1bd2e7842faaf80
This commit is contained in:
commit
64e82b00b9
10 changed files with 78 additions and 158 deletions
|
@ -19,5 +19,5 @@ cc_test {
|
|||
defaults: ["VtsHalTargetTestDefaults"],
|
||||
srcs: ["VtsHalPowerV1_0TargetTest.cpp"],
|
||||
static_libs: ["android.hardware.power@1.0"],
|
||||
test_suites: ["general-tests"],
|
||||
test_suites: ["general-tests", "vts-core"],
|
||||
}
|
||||
|
|
|
@ -21,9 +21,9 @@
|
|||
|
||||
#include <android-base/unique_fd.h>
|
||||
#include <android/hardware/power/1.0/IPower.h>
|
||||
|
||||
#include <VtsHalHidlTargetTestBase.h>
|
||||
#include <VtsHalHidlTargetTestEnvBase.h>
|
||||
#include <gtest/gtest.h>
|
||||
#include <hidl/GtestPrinter.h>
|
||||
#include <hidl/ServiceManagement.h>
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <algorithm>
|
||||
|
@ -45,23 +45,10 @@ 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 {
|
||||
class PowerHidlTest : public testing::TestWithParam<std::string> {
|
||||
public:
|
||||
virtual void SetUp() override {
|
||||
power = ::testing::VtsHalHidlTargetTestBase::getService<IPower>(
|
||||
PowerHidlEnvironment::Instance()->getServiceName<IPower>());
|
||||
power = IPower::getService(GetParam());
|
||||
ASSERT_NE(power, nullptr);
|
||||
}
|
||||
|
||||
|
@ -71,7 +58,7 @@ class PowerHidlTest : public ::testing::VtsHalHidlTargetTestBase {
|
|||
};
|
||||
|
||||
// Sanity check Power::setInteractive.
|
||||
TEST_F(PowerHidlTest, SetInteractive) {
|
||||
TEST_P(PowerHidlTest, SetInteractive) {
|
||||
Return<void> ret;
|
||||
|
||||
ret = power->setInteractive(true);
|
||||
|
@ -83,7 +70,7 @@ TEST_F(PowerHidlTest, SetInteractive) {
|
|||
|
||||
// Test Power::setInteractive and Power::powerHint(Launch)
|
||||
// with each available CPU governor, if available
|
||||
TEST_F(PowerHidlTest, TryDifferentGovernors) {
|
||||
TEST_P(PowerHidlTest, TryDifferentGovernors) {
|
||||
Return<void> ret;
|
||||
|
||||
unique_fd fd1(open(CPU_GOVERNOR_PATH, O_RDWR));
|
||||
|
@ -125,7 +112,7 @@ TEST_F(PowerHidlTest, TryDifferentGovernors) {
|
|||
}
|
||||
|
||||
// Sanity check Power::powerHint on good and bad inputs.
|
||||
TEST_F(PowerHidlTest, PowerHint) {
|
||||
TEST_P(PowerHidlTest, PowerHint) {
|
||||
PowerHint badHint = static_cast<PowerHint>(0xA);
|
||||
auto hints = {PowerHint::VSYNC, PowerHint::INTERACTION,
|
||||
PowerHint::VIDEO_ENCODE, PowerHint::VIDEO_DECODE,
|
||||
|
@ -163,7 +150,7 @@ TEST_F(PowerHidlTest, PowerHint) {
|
|||
}
|
||||
|
||||
// Sanity check Power::setFeature() on good and bad inputs.
|
||||
TEST_F(PowerHidlTest, SetFeature) {
|
||||
TEST_P(PowerHidlTest, SetFeature) {
|
||||
Return<void> ret;
|
||||
ret = power->setFeature(Feature::POWER_FEATURE_DOUBLE_TAP_TO_WAKE, true);
|
||||
ASSERT_TRUE(ret.isOk());
|
||||
|
@ -178,7 +165,7 @@ TEST_F(PowerHidlTest, SetFeature) {
|
|||
}
|
||||
|
||||
// Sanity check Power::getPlatformLowPowerStats().
|
||||
TEST_F(PowerHidlTest, GetPlatformLowPowerStats) {
|
||||
TEST_P(PowerHidlTest, GetPlatformLowPowerStats) {
|
||||
hidl_vec<PowerStatePlatformSleepState> vec;
|
||||
Status s;
|
||||
auto cb = [&vec, &s](hidl_vec<PowerStatePlatformSleepState> states,
|
||||
|
@ -191,11 +178,7 @@ TEST_F(PowerHidlTest, GetPlatformLowPowerStats) {
|
|||
ASSERT_TRUE(s == Status::SUCCESS || s == Status::FILESYSTEM_ERROR);
|
||||
}
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
::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;
|
||||
}
|
||||
INSTANTIATE_TEST_SUITE_P(
|
||||
PerInstance, PowerHidlTest,
|
||||
testing::ValuesIn(android::hardware::getAllHalInstanceNames(IPower::descriptor)),
|
||||
android::hardware::PrintInstanceNameToString);
|
||||
|
|
|
@ -22,5 +22,5 @@ cc_test {
|
|||
"android.hardware.power@1.0",
|
||||
"android.hardware.power@1.1",
|
||||
],
|
||||
test_suites: ["general-tests"],
|
||||
test_suites: ["general-tests", "vts-core"],
|
||||
}
|
||||
|
|
|
@ -17,9 +17,9 @@
|
|||
#define LOG_TAG "power_hidl_hal_test"
|
||||
#include <android-base/logging.h>
|
||||
#include <android/hardware/power/1.1/IPower.h>
|
||||
|
||||
#include <VtsHalHidlTargetTestBase.h>
|
||||
#include <VtsHalHidlTargetTestEnvBase.h>
|
||||
#include <gtest/gtest.h>
|
||||
#include <hidl/GtestPrinter.h>
|
||||
#include <hidl/ServiceManagement.h>
|
||||
|
||||
using ::android::hardware::power::V1_1::IPower;
|
||||
using ::android::hardware::power::V1_1::PowerStateSubsystem;
|
||||
|
@ -29,23 +29,10 @@ 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 {
|
||||
class PowerHidlTest : public testing::TestWithParam<std::string> {
|
||||
public:
|
||||
virtual void SetUp() override {
|
||||
power = ::testing::VtsHalHidlTargetTestBase::getService<IPower>(
|
||||
PowerHidlEnvironment::Instance()->getServiceName<IPower>());
|
||||
power = IPower::getService(GetParam());
|
||||
ASSERT_NE(power, nullptr);
|
||||
}
|
||||
|
||||
|
@ -55,7 +42,7 @@ class PowerHidlTest : public ::testing::VtsHalHidlTargetTestBase {
|
|||
};
|
||||
|
||||
// Sanity check Power::getSubsystemLowPowerStats().
|
||||
TEST_F(PowerHidlTest, GetSubsystemLowPowerStats) {
|
||||
TEST_P(PowerHidlTest, GetSubsystemLowPowerStats) {
|
||||
hidl_vec<PowerStateSubsystem> vec;
|
||||
Status s;
|
||||
auto cb = [&vec, &s](hidl_vec<PowerStateSubsystem> subsystems,
|
||||
|
@ -70,7 +57,7 @@ TEST_F(PowerHidlTest, GetSubsystemLowPowerStats) {
|
|||
}
|
||||
|
||||
// Sanity check Power::powerHintAsync on good and bad inputs.
|
||||
TEST_F(PowerHidlTest, PowerHintAsync) {
|
||||
TEST_P(PowerHidlTest, PowerHintAsync) {
|
||||
PowerHint badHint = static_cast<PowerHint>(0xA);
|
||||
auto hints = {PowerHint::VSYNC, PowerHint::INTERACTION, PowerHint::VIDEO_ENCODE,
|
||||
PowerHint::VIDEO_DECODE, PowerHint::LOW_POWER, PowerHint::SUSTAINED_PERFORMANCE,
|
||||
|
@ -104,11 +91,7 @@ TEST_F(PowerHidlTest, PowerHintAsync) {
|
|||
} while (std::next_permutation(hints2.begin(), hints2.end(), compareHints));
|
||||
}
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
::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;
|
||||
}
|
||||
INSTANTIATE_TEST_SUITE_P(
|
||||
PerInstance, PowerHidlTest,
|
||||
testing::ValuesIn(android::hardware::getAllHalInstanceNames(IPower::descriptor)),
|
||||
android::hardware::PrintInstanceNameToString);
|
||||
|
|
|
@ -23,5 +23,5 @@ cc_test {
|
|||
"android.hardware.power@1.1",
|
||||
"android.hardware.power@1.2",
|
||||
],
|
||||
test_suites: ["general-tests"],
|
||||
test_suites: ["general-tests", "vts-core"],
|
||||
}
|
||||
|
|
|
@ -17,9 +17,9 @@
|
|||
#define LOG_TAG "power_hidl_hal_test"
|
||||
#include <android-base/logging.h>
|
||||
#include <android/hardware/power/1.2/IPower.h>
|
||||
|
||||
#include <VtsHalHidlTargetTestBase.h>
|
||||
#include <VtsHalHidlTargetTestEnvBase.h>
|
||||
#include <gtest/gtest.h>
|
||||
#include <hidl/GtestPrinter.h>
|
||||
#include <hidl/ServiceManagement.h>
|
||||
|
||||
using ::android::sp;
|
||||
using ::android::hardware::hidl_vec;
|
||||
|
@ -27,23 +27,10 @@ using ::android::hardware::Return;
|
|||
using ::android::hardware::power::V1_2::IPower;
|
||||
using ::android::hardware::power::V1_2::PowerHint;
|
||||
|
||||
// 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 {
|
||||
class PowerHidlTest : public testing::TestWithParam<std::string> {
|
||||
public:
|
||||
virtual void SetUp() override {
|
||||
power = ::testing::VtsHalHidlTargetTestBase::getService<IPower>(
|
||||
PowerHidlEnvironment::Instance()->getServiceName<IPower>());
|
||||
power = IPower::getService(GetParam());
|
||||
ASSERT_NE(power, nullptr);
|
||||
}
|
||||
|
||||
|
@ -51,7 +38,7 @@ class PowerHidlTest : public ::testing::VtsHalHidlTargetTestBase {
|
|||
};
|
||||
|
||||
// Sanity check Power::PowerHintAsync_1_2 on good and bad inputs.
|
||||
TEST_F(PowerHidlTest, PowerHintAsync_1_2) {
|
||||
TEST_P(PowerHidlTest, PowerHintAsync_1_2) {
|
||||
std::vector<PowerHint> hints;
|
||||
for (uint32_t i = static_cast<uint32_t>(PowerHint::VSYNC);
|
||||
i <= static_cast<uint32_t>(PowerHint::CAMERA_SHOT); ++i) {
|
||||
|
@ -89,11 +76,8 @@ TEST_F(PowerHidlTest, PowerHintAsync_1_2) {
|
|||
} while (std::next_permutation(hints2.begin(), hints2.end(), compareHints));
|
||||
}
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
::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;
|
||||
}
|
||||
INSTANTIATE_TEST_SUITE_P(
|
||||
PerInstance, PowerHidlTest,
|
||||
testing::ValuesIn(android::hardware::getAllHalInstanceNames(IPower::descriptor)),
|
||||
android::hardware::PrintInstanceNameToString);
|
||||
|
||||
|
|
|
@ -24,5 +24,5 @@ cc_test {
|
|||
"android.hardware.power@1.2",
|
||||
"android.hardware.power@1.3",
|
||||
],
|
||||
test_suites: ["general-tests"],
|
||||
test_suites: ["general-tests", "vts-core"],
|
||||
}
|
||||
|
|
|
@ -17,9 +17,9 @@
|
|||
#define LOG_TAG "power_hidl_hal_test"
|
||||
#include <android-base/logging.h>
|
||||
#include <android/hardware/power/1.3/IPower.h>
|
||||
|
||||
#include <VtsHalHidlTargetTestBase.h>
|
||||
#include <VtsHalHidlTargetTestEnvBase.h>
|
||||
#include <gtest/gtest.h>
|
||||
#include <hidl/GtestPrinter.h>
|
||||
#include <hidl/ServiceManagement.h>
|
||||
|
||||
using ::android::sp;
|
||||
using ::android::hardware::hidl_vec;
|
||||
|
@ -27,38 +27,21 @@ using ::android::hardware::Return;
|
|||
using ::android::hardware::power::V1_3::IPower;
|
||||
using ::android::hardware::power::V1_3::PowerHint;
|
||||
|
||||
// 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 {
|
||||
class PowerHidlTest : public testing::TestWithParam<std::string> {
|
||||
public:
|
||||
virtual void SetUp() override {
|
||||
power = ::testing::VtsHalHidlTargetTestBase::getService<IPower>(
|
||||
PowerHidlEnvironment::Instance()->getServiceName<IPower>());
|
||||
power = IPower::getService(GetParam());
|
||||
ASSERT_NE(power, nullptr);
|
||||
}
|
||||
|
||||
sp<IPower> power;
|
||||
};
|
||||
|
||||
TEST_F(PowerHidlTest, PowerHintAsync_1_3) {
|
||||
TEST_P(PowerHidlTest, PowerHintAsync_1_3) {
|
||||
ASSERT_TRUE(power->powerHintAsync_1_3(PowerHint::EXPENSIVE_RENDERING, 0).isOk());
|
||||
}
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
::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;
|
||||
}
|
||||
INSTANTIATE_TEST_SUITE_P(
|
||||
PerInstance, PowerHidlTest,
|
||||
testing::ValuesIn(android::hardware::getAllHalInstanceNames(IPower::descriptor)),
|
||||
android::hardware::PrintInstanceNameToString);
|
||||
|
|
|
@ -33,4 +33,5 @@ cc_test {
|
|||
"libfmq",
|
||||
"libutils",
|
||||
],
|
||||
test_suites: ["general-tests", "vts-core"],
|
||||
}
|
||||
|
|
|
@ -16,13 +16,15 @@
|
|||
|
||||
#define LOG_TAG "android.power.stats.vts"
|
||||
|
||||
#include <VtsHalHidlTargetTestBase.h>
|
||||
#include <VtsHalHidlTargetTestEnvBase.h>
|
||||
#include <android-base/logging.h>
|
||||
#include <android/hardware/power/stats/1.0/IPowerStats.h>
|
||||
#include <fmq/MessageQueue.h>
|
||||
#include <gtest/gtest.h>
|
||||
#include <hidl/GtestPrinter.h>
|
||||
#include <hidl/MQDescriptor.h>
|
||||
#include <hidl/ServiceManagement.h>
|
||||
#include <inttypes.h>
|
||||
|
||||
#include <algorithm>
|
||||
#include <random>
|
||||
#include <thread>
|
||||
|
@ -49,23 +51,11 @@ using android::hardware::power::stats::V1_0::Status;
|
|||
} // namespace
|
||||
|
||||
typedef hardware::MessageQueue<EnergyData, kSynchronizedReadWrite> MessageQueueSync;
|
||||
// Test environment for Power HIDL HAL.
|
||||
class PowerStatsHidlEnv : public ::testing::VtsHalHidlTargetTestEnvBase {
|
||||
public:
|
||||
// get the test environment singleton
|
||||
static PowerStatsHidlEnv* Instance() {
|
||||
static PowerStatsHidlEnv* instance = new PowerStatsHidlEnv;
|
||||
return instance;
|
||||
}
|
||||
|
||||
virtual void registerTestServices() override { registerTestService<IPowerStats>(); }
|
||||
};
|
||||
|
||||
class PowerStatsHidlTest : public ::testing::VtsHalHidlTargetTestBase {
|
||||
class PowerStatsHidlTest : public ::testing::TestWithParam<std::string> {
|
||||
public:
|
||||
virtual void SetUp() override {
|
||||
service_ = ::testing::VtsHalHidlTargetTestBase::getService<IPowerStats>(
|
||||
PowerStatsHidlEnv::Instance()->getServiceName<IPowerStats>());
|
||||
service_ = IPowerStats::getService(GetParam());
|
||||
ASSERT_NE(service_, nullptr);
|
||||
}
|
||||
|
||||
|
@ -157,7 +147,7 @@ void PowerStatsHidlTest::getRandomIds(std::vector<uint32_t>& ids) {
|
|||
}
|
||||
|
||||
// Each PowerEntity must have a valid name
|
||||
TEST_F(PowerStatsHidlTest, ValidatePowerEntityNames) {
|
||||
TEST_P(PowerStatsHidlTest, ValidatePowerEntityNames) {
|
||||
hidl_vec<PowerEntityInfo> infos;
|
||||
getInfos(infos);
|
||||
for (auto info : infos) {
|
||||
|
@ -166,18 +156,18 @@ TEST_F(PowerStatsHidlTest, ValidatePowerEntityNames) {
|
|||
}
|
||||
|
||||
// Each PowerEntity must have a unique ID
|
||||
TEST_F(PowerStatsHidlTest, ValidatePowerEntityIds) {
|
||||
TEST_P(PowerStatsHidlTest, ValidatePowerEntityIds) {
|
||||
hidl_vec<PowerEntityInfo> infos;
|
||||
getInfos(infos);
|
||||
|
||||
set<uint32_t> ids;
|
||||
std::set<uint32_t> ids;
|
||||
for (auto info : infos) {
|
||||
ASSERT_TRUE(ids.insert(info.powerEntityId).second);
|
||||
}
|
||||
}
|
||||
|
||||
// Each PowerEntityStateSpace must have an associated PowerEntityInfo
|
||||
TEST_F(PowerStatsHidlTest, ValidateStateInfoAssociation) {
|
||||
TEST_P(PowerStatsHidlTest, ValidateStateInfoAssociation) {
|
||||
hidl_vec<PowerEntityInfo> infos;
|
||||
getInfos(infos);
|
||||
|
||||
|
@ -195,7 +185,7 @@ TEST_F(PowerStatsHidlTest, ValidateStateInfoAssociation) {
|
|||
}
|
||||
|
||||
// Each state must have a valid name
|
||||
TEST_F(PowerStatsHidlTest, ValidateStateNames) {
|
||||
TEST_P(PowerStatsHidlTest, ValidateStateNames) {
|
||||
hidl_vec<PowerEntityStateSpace> stateSpaces;
|
||||
getStateSpaces(stateSpaces);
|
||||
|
||||
|
@ -207,12 +197,12 @@ TEST_F(PowerStatsHidlTest, ValidateStateNames) {
|
|||
}
|
||||
|
||||
// Each state must have an ID that is unique to the PowerEntityStateSpace
|
||||
TEST_F(PowerStatsHidlTest, ValidateStateUniqueIds) {
|
||||
TEST_P(PowerStatsHidlTest, ValidateStateUniqueIds) {
|
||||
hidl_vec<PowerEntityStateSpace> stateSpaces;
|
||||
getStateSpaces(stateSpaces);
|
||||
|
||||
for (auto stateSpace : stateSpaces) {
|
||||
set<uint32_t> stateIds;
|
||||
std::set<uint32_t> stateIds;
|
||||
for (auto state : stateSpace.states) {
|
||||
ASSERT_TRUE(stateIds.insert(state.powerEntityStateId).second);
|
||||
}
|
||||
|
@ -221,7 +211,7 @@ TEST_F(PowerStatsHidlTest, ValidateStateUniqueIds) {
|
|||
|
||||
// getPowerEntityStateInfo must support passing in requested IDs
|
||||
// Results must contain state space information for all requested IDs
|
||||
TEST_F(PowerStatsHidlTest, ValidateStateInfoAssociationSelect) {
|
||||
TEST_P(PowerStatsHidlTest, ValidateStateInfoAssociationSelect) {
|
||||
std::vector<uint32_t> randomIds;
|
||||
getRandomIds(randomIds);
|
||||
|
||||
|
@ -244,7 +234,7 @@ TEST_F(PowerStatsHidlTest, ValidateStateInfoAssociationSelect) {
|
|||
}
|
||||
|
||||
// Requested state space info must match initially obtained stateinfos
|
||||
TEST_F(PowerStatsHidlTest, ValidateStateInfoSelect) {
|
||||
TEST_P(PowerStatsHidlTest, ValidateStateInfoSelect) {
|
||||
hidl_vec<PowerEntityStateSpace> stateSpaces;
|
||||
getStateSpaces(stateSpaces);
|
||||
if (stateSpaces.size() == 0) {
|
||||
|
@ -279,7 +269,7 @@ TEST_F(PowerStatsHidlTest, ValidateStateInfoSelect) {
|
|||
|
||||
// stateResidencyResults must contain results for every PowerEntityStateSpace
|
||||
// returned by getPowerEntityStateInfo
|
||||
TEST_F(PowerStatsHidlTest, ValidateResidencyResultsAssociation) {
|
||||
TEST_P(PowerStatsHidlTest, ValidateResidencyResultsAssociation) {
|
||||
hidl_vec<PowerEntityStateSpace> stateSpaces;
|
||||
getStateSpaces(stateSpaces);
|
||||
|
||||
|
@ -311,7 +301,7 @@ TEST_F(PowerStatsHidlTest, ValidateResidencyResultsAssociation) {
|
|||
// getPowerEntityStateResidencyData must support passing in requested IDs
|
||||
// stateResidencyResults must contain results for each PowerEntityStateSpace
|
||||
// returned by getPowerEntityStateInfo
|
||||
TEST_F(PowerStatsHidlTest, ValidateResidencyResultsAssociationSelect) {
|
||||
TEST_P(PowerStatsHidlTest, ValidateResidencyResultsAssociationSelect) {
|
||||
std::vector<uint32_t> randomIds;
|
||||
getRandomIds(randomIds);
|
||||
if (randomIds.empty()) {
|
||||
|
@ -346,7 +336,7 @@ TEST_F(PowerStatsHidlTest, ValidateResidencyResultsAssociationSelect) {
|
|||
}
|
||||
}
|
||||
|
||||
TEST_F(PowerStatsHidlTest, ValidateRailInfo) {
|
||||
TEST_P(PowerStatsHidlTest, ValidateRailInfo) {
|
||||
hidl_vec<RailInfo> rails[2];
|
||||
Status s;
|
||||
auto cb = [&rails, &s](hidl_vec<RailInfo> rail_subsys, Status status) {
|
||||
|
@ -359,7 +349,7 @@ TEST_F(PowerStatsHidlTest, ValidateRailInfo) {
|
|||
/* Rails size should be non-zero on SUCCESS*/
|
||||
ASSERT_NE(rails[0].size(), 0);
|
||||
/* check if indices returned are unique*/
|
||||
set<uint32_t> ids;
|
||||
std::set<uint32_t> ids;
|
||||
for (auto rail : rails[0]) {
|
||||
ASSERT_TRUE(ids.insert(rail.index).second);
|
||||
}
|
||||
|
@ -402,7 +392,7 @@ TEST_F(PowerStatsHidlTest, ValidateRailInfo) {
|
|||
}
|
||||
}
|
||||
|
||||
TEST_F(PowerStatsHidlTest, ValidateAllPowerData) {
|
||||
TEST_P(PowerStatsHidlTest, ValidateAllPowerData) {
|
||||
hidl_vec<EnergyData> measurements[2];
|
||||
Status s;
|
||||
auto cb = [&measurements, &s](hidl_vec<EnergyData> measure, Status status) {
|
||||
|
@ -451,7 +441,7 @@ TEST_F(PowerStatsHidlTest, ValidateAllPowerData) {
|
|||
}
|
||||
}
|
||||
|
||||
TEST_F(PowerStatsHidlTest, ValidateFilteredPowerData) {
|
||||
TEST_P(PowerStatsHidlTest, ValidateFilteredPowerData) {
|
||||
hidl_vec<RailInfo> rails;
|
||||
hidl_vec<EnergyData> measurements;
|
||||
hidl_vec<uint32_t> indices;
|
||||
|
@ -559,23 +549,19 @@ void readEnergy(sp<IPowerStats> service_, uint32_t timeMs) {
|
|||
}
|
||||
}
|
||||
|
||||
TEST_F(PowerStatsHidlTest, StreamEnergyData) {
|
||||
TEST_P(PowerStatsHidlTest, StreamEnergyData) {
|
||||
std::time_t seed = std::time(nullptr);
|
||||
std::srand(seed);
|
||||
std::thread thread1 = std::thread(readEnergy, service_, std::rand() % 5000);
|
||||
thread1.join();
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_SUITE_P(
|
||||
PerInstance, PowerStatsHidlTest,
|
||||
testing::ValuesIn(android::hardware::getAllHalInstanceNames(IPowerStats::descriptor)),
|
||||
android::hardware::PrintInstanceNameToString);
|
||||
|
||||
} // namespace vts
|
||||
} // namespace stats
|
||||
} // namespace power
|
||||
} // namespace android
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
::testing::AddGlobalTestEnvironment(android::power::stats::vts::PowerStatsHidlEnv::Instance());
|
||||
::testing::InitGoogleTest(&argc, argv);
|
||||
android::power::stats::vts::PowerStatsHidlEnv::Instance()->init(&argc, argv);
|
||||
int status = RUN_ALL_TESTS();
|
||||
LOG(INFO) << "Test result = " << status;
|
||||
return status;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue