diff options
author | Wei Wang <wvw@google.com> | 2021-06-12 18:26:38 -0700 |
---|---|---|
committer | Wei Wang <wvw@google.com> | 2021-06-12 18:27:59 -0700 |
commit | 9df909dba11b753d651e3c7bdc6fdd94714cfb69 (patch) | |
tree | 92d28e601a90742395e14c7f479dd7c054801ec7 /power | |
parent | 5fe68156d50a30391b008c76355f7ae99357e775 (diff) |
Power: allow vts to pass with earlier version of server
Bug: 189976527
Test: Build
Signed-off-by: Wei Wang <wvw@google.com>
Change-Id: I3e1ce05e62e9581c9a66f65e82e1599d77de7a85
Diffstat (limited to 'power')
-rw-r--r-- | power/aidl/vts/VtsHalPowerTargetTest.cpp | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/power/aidl/vts/VtsHalPowerTargetTest.cpp b/power/aidl/vts/VtsHalPowerTargetTest.cpp index 5bb088a121..ffab66c312 100644 --- a/power/aidl/vts/VtsHalPowerTargetTest.cpp +++ b/power/aidl/vts/VtsHalPowerTargetTest.cpp @@ -22,6 +22,7 @@ #include <android/binder_ibinder.h> #include <android/binder_manager.h> #include <android/binder_process.h> +#include <android/binder_status.h> #include <unistd.h> @@ -82,6 +83,11 @@ const std::vector<WorkDuration> kDurations = { DurationWrapper(1000000000L, 4L), }; +inline bool isUnknownOrUnsupported(const ndk::ScopedAStatus& status) { + return status.getStatus() == STATUS_UNKNOWN_TRANSACTION || + status.getExceptionCode() == EX_UNSUPPORTED_OPERATION; +} + class PowerAidl : public testing::TestWithParam<std::string> { public: virtual void SetUp() override { @@ -147,7 +153,7 @@ TEST_P(PowerAidl, getHintSessionPreferredRate) { int64_t rate = -1; auto status = power->getHintSessionPreferredRate(&rate); if (!status.isOk()) { - ASSERT_EQ(EX_UNSUPPORTED_OPERATION, status.getExceptionCode()); + EXPECT_TRUE(isUnknownOrUnsupported(status)); return; } @@ -159,7 +165,7 @@ TEST_P(PowerAidl, createAndCloseHintSession) { std::shared_ptr<IPowerHintSession> session; auto status = power->createHintSession(getpid(), getuid(), kSelfTids, 16666666L, &session); if (!status.isOk()) { - ASSERT_EQ(EX_UNSUPPORTED_OPERATION, status.getExceptionCode()); + EXPECT_TRUE(isUnknownOrUnsupported(status)); return; } ASSERT_NE(nullptr, session); @@ -173,10 +179,9 @@ TEST_P(PowerAidl, createHintSessionFailed) { std::shared_ptr<IPowerHintSession> session; auto status = power->createHintSession(getpid(), getuid(), kEmptyTids, 16666666L, &session); ASSERT_FALSE(status.isOk()); - if (EX_UNSUPPORTED_OPERATION == status.getExceptionCode()) { + if (isUnknownOrUnsupported(status)) { return; } - // Test with empty tid list ASSERT_EQ(EX_ILLEGAL_ARGUMENT, status.getExceptionCode()); } @@ -184,7 +189,7 @@ TEST_P(PowerAidl, updateAndReportDurations) { std::shared_ptr<IPowerHintSession> session; auto status = power->createHintSession(getpid(), getuid(), kSelfTids, 16666666L, &session); if (!status.isOk()) { - ASSERT_EQ(EX_UNSUPPORTED_OPERATION, status.getExceptionCode()); + EXPECT_TRUE(isUnknownOrUnsupported(status)); return; } ASSERT_NE(nullptr, session); |