Add VTS tests for APIs that return storage info.
Bug: 68388678 Test: vts-tradefed run vts -m VtsHalHealthV2_0 Change-Id: Id1c3bad60ca35cc5c257e35725482ca5b883a3b5
This commit is contained in:
parent
f09d118864
commit
2120ecc3f5
1 changed files with 29 additions and 0 deletions
|
@ -180,6 +180,29 @@ AssertionResult isPropertyOk(Result res, const std::string& valueStr, bool pred,
|
|||
return AssertionFailure() << "Result is not SUCCESS or NOT_SUPPORTED: " << toString(res);
|
||||
}
|
||||
|
||||
bool verifyStorageInfo(const hidl_vec<struct StorageInfo>& info) {
|
||||
for (size_t i = 0; i < info.size(); i++) {
|
||||
if (!(0 <= info[i].eol && info[i].eol <= 3 && 0 <= info[i].lifetimeA &&
|
||||
info[i].lifetimeA <= 0x0B && 0 <= info[i].lifetimeB && info[i].lifetimeB <= 0x0B)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool verifyDiskStats(const hidl_vec<struct DiskStats>& stats) {
|
||||
for (size_t i = 0; i < stats.size(); i++) {
|
||||
if (!(stats[i].reads > 0 && stats[i].readMerges > 0 && stats[i].readSectors > 0 &&
|
||||
stats[i].readTicks > 0 && stats[i].writes > 0 && stats[i].writeMerges > 0 &&
|
||||
stats[i].writeSectors > 0 && stats[i].writeTicks > 0 && stats[i].ioTicks > 0)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
TEST_F(HealthHidlTest, Properties) {
|
||||
EXPECT_OK(mHealth->getChargeCounter([](auto result, auto value) {
|
||||
EXPECT_VALID_OR_UNSUPPORTED_PROP(result, std::to_string(value), value > 0);
|
||||
|
@ -202,6 +225,12 @@ TEST_F(HealthHidlTest, Properties) {
|
|||
value == BatteryStatus::CHARGING || value == BatteryStatus::DISCHARGING ||
|
||||
value == BatteryStatus::NOT_CHARGING || value == BatteryStatus::FULL);
|
||||
}));
|
||||
EXPECT_OK(mHealth->getStorageInfo([](auto result, auto& value) {
|
||||
EXPECT_VALID_OR_UNSUPPORTED_PROP(result, toString(value), (verifyStorageInfo(value)));
|
||||
}));
|
||||
EXPECT_OK(mHealth->getDiskStats([](auto result, auto& value) {
|
||||
EXPECT_VALID_OR_UNSUPPORTED_PROP(result, toString(value), verifyDiskStats(value));
|
||||
}));
|
||||
}
|
||||
|
||||
} // namespace V2_0
|
||||
|
|
Loading…
Reference in a new issue