mirror of
https://github.com/Evolution-X/hardware_interfaces
synced 2026-02-01 11:36:00 +00:00
health 2.0 VTS: require GTEST_SKIP to be defined
This is a hack to support the test in Android P. Now that gtest
has been updated, we no longer need this hack.
Test: run it
Bug: 118852225
Bug: 136717180
Change-Id: I81802b6fae0dc7839aa9fd1dd40cb881ff4eefdb
(cherry picked from commit 9fb96fa4b0)
Merged-In: I81802b6fae0dc7839aa9fd1dd40cb881ff4eefdb
This commit is contained in:
@@ -35,39 +35,6 @@ using ::testing::AssertionSuccess;
|
||||
|
||||
DEFINE_bool(force, false, "Force test healthd even when the default instance is present.");
|
||||
|
||||
// If GTEST_SKIP is not implemented, use our own skipping mechanism
|
||||
#ifndef GTEST_SKIP
|
||||
static std::mutex gSkippedTestsMutex;
|
||||
static std::set<std::string> gSkippedTests;
|
||||
static std::string GetCurrentTestName() {
|
||||
const auto& info = ::testing::UnitTest::GetInstance()->current_test_info();
|
||||
#ifdef GTEST_REMOVE_LEGACY_TEST_CASEAPI_
|
||||
std::string test_suite = info->test_suite_name();
|
||||
#else
|
||||
std::string test_suite = info->test_case_name();
|
||||
#endif
|
||||
return test_suite + "." + info->name();
|
||||
}
|
||||
|
||||
#define GTEST_SKIP() \
|
||||
do { \
|
||||
std::unique_lock<std::mutex> lock(gSkippedTestsMutex); \
|
||||
gSkippedTests.insert(GetCurrentTestName()); \
|
||||
return; \
|
||||
} while (0)
|
||||
|
||||
#define SKIP_IF_SKIPPED() \
|
||||
do { \
|
||||
std::unique_lock<std::mutex> lock(gSkippedTestsMutex); \
|
||||
if (gSkippedTests.find(GetCurrentTestName()) != gSkippedTests.end()) { \
|
||||
std::cerr << "[ SKIPPED ] " << GetCurrentTestName() << std::endl; \
|
||||
return; \
|
||||
} \
|
||||
} while (0)
|
||||
#else
|
||||
#define SKIP_IF_SKIPPED()
|
||||
#endif
|
||||
|
||||
namespace android {
|
||||
namespace hardware {
|
||||
namespace health {
|
||||
@@ -141,7 +108,6 @@ AssertionResult isAllOk(const Return<Result>& r) {
|
||||
* unregisterCallback, and update.
|
||||
*/
|
||||
TEST_P(HealthHidlTest, Callbacks) {
|
||||
SKIP_IF_SKIPPED();
|
||||
using namespace std::chrono_literals;
|
||||
sp<Callback> firstCallback = new Callback();
|
||||
sp<Callback> secondCallback = new Callback();
|
||||
@@ -178,7 +144,6 @@ TEST_P(HealthHidlTest, Callbacks) {
|
||||
}
|
||||
|
||||
TEST_P(HealthHidlTest, UnregisterNonExistentCallback) {
|
||||
SKIP_IF_SKIPPED();
|
||||
sp<Callback> callback = new Callback();
|
||||
auto ret = mHealth->unregisterCallback(callback);
|
||||
ASSERT_OK(ret);
|
||||
@@ -263,7 +228,6 @@ bool verifyHealthInfo(const HealthInfo& health_info) {
|
||||
* Tests the values returned by getChargeCounter() from interface IHealth.
|
||||
*/
|
||||
TEST_P(HealthHidlTest, getChargeCounter) {
|
||||
SKIP_IF_SKIPPED();
|
||||
EXPECT_OK(mHealth->getChargeCounter([](auto result, auto value) {
|
||||
EXPECT_VALID_OR_UNSUPPORTED_PROP(result, std::to_string(value), value > 0);
|
||||
}));
|
||||
@@ -273,7 +237,6 @@ TEST_P(HealthHidlTest, getChargeCounter) {
|
||||
* Tests the values returned by getCurrentNow() from interface IHealth.
|
||||
*/
|
||||
TEST_P(HealthHidlTest, getCurrentNow) {
|
||||
SKIP_IF_SKIPPED();
|
||||
EXPECT_OK(mHealth->getCurrentNow([](auto result, auto value) {
|
||||
EXPECT_VALID_OR_UNSUPPORTED_PROP(result, std::to_string(value), value != INT32_MIN);
|
||||
}));
|
||||
@@ -283,7 +246,6 @@ TEST_P(HealthHidlTest, getCurrentNow) {
|
||||
* Tests the values returned by getCurrentAverage() from interface IHealth.
|
||||
*/
|
||||
TEST_P(HealthHidlTest, getCurrentAverage) {
|
||||
SKIP_IF_SKIPPED();
|
||||
EXPECT_OK(mHealth->getCurrentAverage([](auto result, auto value) {
|
||||
EXPECT_VALID_OR_UNSUPPORTED_PROP(result, std::to_string(value), value != INT32_MIN);
|
||||
}));
|
||||
@@ -293,7 +255,6 @@ TEST_P(HealthHidlTest, getCurrentAverage) {
|
||||
* Tests the values returned by getCapacity() from interface IHealth.
|
||||
*/
|
||||
TEST_P(HealthHidlTest, getCapacity) {
|
||||
SKIP_IF_SKIPPED();
|
||||
EXPECT_OK(mHealth->getCapacity([](auto result, auto value) {
|
||||
EXPECT_VALID_OR_UNSUPPORTED_PROP(result, std::to_string(value), 0 <= value && value <= 100);
|
||||
}));
|
||||
@@ -303,7 +264,6 @@ TEST_P(HealthHidlTest, getCapacity) {
|
||||
* Tests the values returned by getEnergyCounter() from interface IHealth.
|
||||
*/
|
||||
TEST_P(HealthHidlTest, getEnergyCounter) {
|
||||
SKIP_IF_SKIPPED();
|
||||
EXPECT_OK(mHealth->getEnergyCounter([](auto result, auto value) {
|
||||
EXPECT_VALID_OR_UNSUPPORTED_PROP(result, std::to_string(value), value != INT64_MIN);
|
||||
}));
|
||||
@@ -313,7 +273,6 @@ TEST_P(HealthHidlTest, getEnergyCounter) {
|
||||
* Tests the values returned by getChargeStatus() from interface IHealth.
|
||||
*/
|
||||
TEST_P(HealthHidlTest, getChargeStatus) {
|
||||
SKIP_IF_SKIPPED();
|
||||
EXPECT_OK(mHealth->getChargeStatus([](auto result, auto value) {
|
||||
EXPECT_VALID_OR_UNSUPPORTED_PROP(result, toString(value), verifyEnum<BatteryStatus>(value));
|
||||
}));
|
||||
@@ -323,7 +282,6 @@ TEST_P(HealthHidlTest, getChargeStatus) {
|
||||
* Tests the values returned by getStorageInfo() from interface IHealth.
|
||||
*/
|
||||
TEST_P(HealthHidlTest, getStorageInfo) {
|
||||
SKIP_IF_SKIPPED();
|
||||
EXPECT_OK(mHealth->getStorageInfo([](auto result, auto& value) {
|
||||
EXPECT_VALID_OR_UNSUPPORTED_PROP(result, toString(value), verifyStorageInfo(value));
|
||||
}));
|
||||
@@ -333,7 +291,6 @@ TEST_P(HealthHidlTest, getStorageInfo) {
|
||||
* Tests the values returned by getDiskStats() from interface IHealth.
|
||||
*/
|
||||
TEST_P(HealthHidlTest, getDiskStats) {
|
||||
SKIP_IF_SKIPPED();
|
||||
EXPECT_OK(mHealth->getDiskStats([](auto result, auto& value) {
|
||||
EXPECT_VALID_OR_UNSUPPORTED_PROP(result, toString(value), true);
|
||||
}));
|
||||
@@ -343,7 +300,6 @@ TEST_P(HealthHidlTest, getDiskStats) {
|
||||
* Tests the values returned by getHealthInfo() from interface IHealth.
|
||||
*/
|
||||
TEST_P(HealthHidlTest, getHealthInfo) {
|
||||
SKIP_IF_SKIPPED();
|
||||
EXPECT_OK(mHealth->getHealthInfo([](auto result, auto& value) {
|
||||
EXPECT_VALID_OR_UNSUPPORTED_PROP(result, toString(value), verifyHealthInfo(value));
|
||||
}));
|
||||
|
||||
Reference in New Issue
Block a user