Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f0047a84 authored by android-build-team Robot's avatar android-build-team Robot
Browse files

Snap for 5369966 from b77950c8 to pi-qpr3-b-release

Change-Id: I820cbb35ab661e983ac3305bdd38c28346c9514b
parents c6c2a0d2 b77950c8
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ cc_test {
    defaults: ["VtsHalTargetTestDefaults"],
    srcs: ["VtsHalHealthV2_0TargetTest.cpp"],
    static_libs: [
        "libgflags",
        "android.hardware.health@1.0",
        "android.hardware.health@2.0",
    ],
+50 −0
Original line number Diff line number Diff line
@@ -17,11 +17,14 @@
#define LOG_TAG "health_hidl_hal_test"

#include <mutex>
#include <set>
#include <string>

#include <VtsHalHidlTargetTestBase.h>
#include <android-base/logging.h>
#include <android/hardware/health/2.0/IHealth.h>
#include <android/hardware/health/2.0/types.h>
#include <gflags/gflags.h>

using ::testing::AssertionFailure;
using ::testing::AssertionResult;
@@ -29,6 +32,41 @@ using ::testing::AssertionSuccess;
using ::testing::VtsHalHidlTargetTestBase;
using ::testing::VtsHalHidlTargetTestEnvBase;

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 {
@@ -57,6 +95,14 @@ class HealthHidlTest : public ::testing::VtsHalHidlTargetTestBase {
   public:
    virtual void SetUp() override {
        std::string serviceName = HealthHidlEnvironment::Instance()->getServiceName<IHealth>();

        if (serviceName == "backup" && !FLAGS_force &&
            ::testing::VtsHalHidlTargetTestBase::getService<IHealth>() != nullptr) {
            LOG(INFO) << "Skipping tests on healthd because the default instance is present. "
                      << "Use --force if you really want to test healthd.";
            GTEST_SKIP();
        }

        LOG(INFO) << "get service with name:" << serviceName;
        ASSERT_FALSE(serviceName.empty());
        mHealth = ::testing::VtsHalHidlTargetTestBase::getService<IHealth>(serviceName);
@@ -111,6 +157,7 @@ AssertionResult isAllOk(const Return<Result>& r) {
 * unregisterCallback, and update.
 */
TEST_F(HealthHidlTest, Callbacks) {
    SKIP_IF_SKIPPED();
    using namespace std::chrono_literals;
    sp<Callback> firstCallback = new Callback();
    sp<Callback> secondCallback = new Callback();
@@ -147,6 +194,7 @@ TEST_F(HealthHidlTest, Callbacks) {
}

TEST_F(HealthHidlTest, UnregisterNonExistentCallback) {
    SKIP_IF_SKIPPED();
    sp<Callback> callback = new Callback();
    auto ret = mHealth->unregisterCallback(callback);
    ASSERT_OK(ret);
@@ -228,6 +276,7 @@ bool verifyHealthInfo(const HealthInfo& health_info) {
 * interface IHealth.
 */
TEST_F(HealthHidlTest, Properties) {
    SKIP_IF_SKIPPED();
    EXPECT_OK(mHealth->getChargeCounter([](auto result, auto value) {
        EXPECT_VALID_OR_UNSUPPORTED_PROP(result, std::to_string(value), value > 0);
    }));
@@ -269,6 +318,7 @@ int main(int argc, char** argv) {
    ::testing::AddGlobalTestEnvironment(HealthHidlEnvironment::Instance());
    ::testing::InitGoogleTest(&argc, argv);
    HealthHidlEnvironment::Instance()->init(&argc, argv);
    gflags::ParseCommandLineFlags(&argc, &argv, true /* remove flags */);
    int status = RUN_ALL_TESTS();
    LOG(INFO) << "Test result = " << status;
    return status;
+30 −8
Original line number Diff line number Diff line
@@ -387,17 +387,28 @@ void changeStateLoadedtoIdle(sp<IOmxNode> omxNode, sp<CodecObserver> observer,
                                  OMX_StateIdle);
    ASSERT_EQ(status, android::hardware::media::omx::V1_0::Status::OK);

    OMX_PARAM_PORTDEFINITIONTYPE portDefInput;
    OMX_PARAM_PORTDEFINITIONTYPE portDefOutput;
    status = getPortParam(omxNode, OMX_IndexParamPortDefinition, kPortIndexInput, &portDefInput);
    EXPECT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK);
    status = getPortParam(omxNode, OMX_IndexParamPortDefinition, kPortIndexOutput, &portDefOutput);
    EXPECT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK);

    // Dont switch states until the ports are populated
    if (portDefInput.nBufferCountActual || portDefOutput.nBufferCountActual) {
        status = observer->dequeueMessage(&msg, DEFAULT_TIMEOUT, iBuffer, oBuffer);
        ASSERT_EQ(status, android::hardware::media::omx::V1_0::Status::TIMED_OUT);
    }

    // allocate buffers on input port
    ASSERT_NO_FATAL_FAILURE(allocatePortBuffers(
        omxNode, iBuffer, kPortIndexInput, pm[0], allocGrap));

    // Dont switch states until the ports are populated
    if (portDefOutput.nBufferCountActual) {
        status = observer->dequeueMessage(&msg, DEFAULT_TIMEOUT, iBuffer, oBuffer);
        ASSERT_EQ(status, android::hardware::media::omx::V1_0::Status::TIMED_OUT);
    }

    // allocate buffers on output port
    ASSERT_NO_FATAL_FAILURE(allocatePortBuffers(
@@ -430,9 +441,18 @@ void changeStateIdletoLoaded(sp<IOmxNode> omxNode, sp<CodecObserver> observer,
                                  OMX_StateLoaded);
    ASSERT_EQ(status, android::hardware::media::omx::V1_0::Status::OK);

    OMX_PARAM_PORTDEFINITIONTYPE portDefInput;
    OMX_PARAM_PORTDEFINITIONTYPE portDefOutput;
    status = getPortParam(omxNode, OMX_IndexParamPortDefinition, kPortIndexInput, &portDefInput);
    EXPECT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK);
    status = getPortParam(omxNode, OMX_IndexParamPortDefinition, kPortIndexOutput, &portDefOutput);
    EXPECT_EQ(status, ::android::hardware::media::omx::V1_0::Status::OK);

    // dont change state until all buffers are freed
    if (portDefInput.nBufferCountActual || portDefOutput.nBufferCountActual) {
        status = observer->dequeueMessage(&msg, DEFAULT_TIMEOUT, iBuffer, oBuffer);
        ASSERT_EQ(status, android::hardware::media::omx::V1_0::Status::TIMED_OUT);
    }

    for (size_t i = 0; i < iBuffer->size(); ++i) {
        status = omxNode->freeBuffer(kPortIndexInput, (*iBuffer)[i].id);
@@ -440,8 +460,10 @@ void changeStateIdletoLoaded(sp<IOmxNode> omxNode, sp<CodecObserver> observer,
    }

    // dont change state until all buffers are freed
    if (portDefOutput.nBufferCountActual) {
        status = observer->dequeueMessage(&msg, DEFAULT_TIMEOUT, iBuffer, oBuffer);
        ASSERT_EQ(status, android::hardware::media::omx::V1_0::Status::TIMED_OUT);
    }

    for (size_t i = 0; i < oBuffer->size(); ++i) {
        status = omxNode->freeBuffer(kPortIndexOutput, (*oBuffer)[i].id);
+18 −2
Original line number Diff line number Diff line
@@ -115,6 +115,7 @@ class ComponentHidlTest : public ::testing::VtsHalHidlTargetTestBase {
        }
        if (compClass == unknown_class) disableTest = true;
        isSecure = false;
        mTunnel = false;
        size_t suffixLen = strlen(".secure");
        if (strlen(gEnv->getComponent().c_str()) >= suffixLen) {
            isSecure =
@@ -122,6 +123,18 @@ class ComponentHidlTest : public ::testing::VtsHalHidlTargetTestBase {
                            strlen(gEnv->getComponent().c_str()) - suffixLen,
                        ".secure");
        }
        if (compClass == video_decoder) {
            omxNode->configureVideoTunnelMode(
                1, OMX_TRUE, 0,
                [&](android::hardware::media::omx::V1_0::Status _s,
                    const ::android::hardware::hidl_handle& sidebandHandle) {
                    (void)sidebandHandle;
                    if (_s == android::hardware::media::omx::V1_0::Status::OK)
                        this->mTunnel = true;
                });
        }
        // NOTES: secure components are not covered in these tests.
        // we are disabling tests for them
        if (disableTest) std::cout << "[   WARN   ] Test Disabled \n";
    }

@@ -149,6 +162,7 @@ class ComponentHidlTest : public ::testing::VtsHalHidlTargetTestBase {
    sp<CodecObserver> observer;
    sp<IOmxNode> omxNode;
    standardCompClass compClass;
    bool mTunnel;
    bool isSecure;
    bool disableTest;

@@ -991,7 +1005,8 @@ TEST_F(ComponentHidlTest, PortEnableDisable_Idle) {
    ASSERT_NO_FATAL_FAILURE(
        changeStateLoadedtoIdle(omxNode, observer, &pBuffer[0], &pBuffer[1],
                                kPortIndexInput, kPortIndexOutput, portMode));
    for (size_t i = portBase; i < portBase + 2; i++) {
    int range = mTunnel ? 1 : 2;
    for (size_t i = portBase; i < portBase + range; i++) {
        status =
            omxNode->sendCommand(toRawCommandType(OMX_CommandPortDisable), i);
        ASSERT_EQ(status, android::hardware::media::omx::V1_0::Status::OK);
@@ -1104,7 +1119,8 @@ TEST_F(ComponentHidlTest, PortEnableDisable_Execute) {
            dispatchOutputBuffer(omxNode, &pBuffer[1], i, portMode[1]));
    }

    for (size_t i = portBase; i < portBase + 2; i++) {
    int range = mTunnel ? 1 : 2;
    for (size_t i = portBase; i < portBase + range; i++) {
        status =
            omxNode->sendCommand(toRawCommandType(OMX_CommandPortDisable), i);
        ASSERT_EQ(status, android::hardware::media::omx::V1_0::Status::OK);
+10 −0
Original line number Diff line number Diff line
@@ -153,7 +153,17 @@ class VideoDecHidlTest : public ::testing::VtsHalHidlTargetTestBase {
                        ".secure");
        }
        if (isSecure) disableTest = true;
        omxNode->configureVideoTunnelMode(
            1, OMX_TRUE, 0,
            [&](android::hardware::media::omx::V1_0::Status _s,
                const ::android::hardware::hidl_handle& sidebandHandle) {
                (void)sidebandHandle;
                if (_s == android::hardware::media::omx::V1_0::Status::OK)
                    this->disableTest = true;
            });
        if (disableTest) std::cout << "[   WARN   ] Test Disabled \n";
        // NOTES: secure and tunneled components are not covered in these tests.
        // we are disabling tests for them
    }

    virtual void TearDown() override {