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

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

release-request-ed8626b9-4479-4c76-9207-5f511f136606-for-git_pi-release-435475...

release-request-ed8626b9-4479-4c76-9207-5f511f136606-for-git_pi-release-4354758 snap-temp-L65900000105223161

Change-Id: I4bbfd3be50488775375033705955a79dd873608e
parents 410b4c50 9bd69497
Loading
Loading
Loading
Loading
+23 −0
Original line number Diff line number Diff line
//
// Copyright (C) 2017 The Android Open Source Project
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//      http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//

cc_test {
    name: "VtsHalCasV1_0TargetTest",
    defaults: ["VtsHalTargetTestDefaults"],
    srcs: ["VtsHalCasV1_0TargetTest.cpp"],
    static_libs: ["android.hardware.cas@1.0"],
}
+147 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2017 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#define LOG_TAG "mediacas_hidl_hal_test"

#include <VtsHalHidlTargetTestBase.h>
#include <android-base/logging.h>
#include <android/hardware/cas/1.0/ICas.h>
#include <android/hardware/cas/1.0/ICasListener.h>
#include <android/hardware/cas/1.0/IDescramblerBase.h>
#include <android/hardware/cas/1.0/IMediaCasService.h>
#include <hidl/HidlSupport.h>
#include <hidl/HidlTransportSupport.h>

#include <cinttypes>
#include <utility>

// CA System Ids used for testing
#define CLEAR_KEY_SYSTEM_ID 0xF6D8
#define INVALID_SYSTEM_ID 0

using android::Condition;
using android::hardware::cas::V1_0::ICas;
using android::hardware::cas::V1_0::ICasListener;
using android::hardware::cas::V1_0::IDescramblerBase;
using android::hardware::cas::V1_0::IMediaCasService;
using android::hardware::cas::V1_0::HidlCasPluginDescriptor;
using android::hardware::Void;
using android::hardware::hidl_vec;
using android::hardware::Return;
using android::Mutex;
using android::sp;

namespace {

class MediaCasHidlTest : public ::testing::VtsHalHidlTargetTestBase {
   public:
    virtual void SetUp() override {
        mService = ::testing::VtsHalHidlTargetTestBase::getService<IMediaCasService>();
        ASSERT_NE(mService, nullptr);
    }

    sp<IMediaCasService> mService;

   protected:
    static void description(const std::string& description) {
        RecordProperty("description", description);
    }
};

class MediaCasListener : public ICasListener {
   public:
    virtual ::android::hardware::Return<void> onEvent(
        int32_t event, int32_t arg, const ::android::hardware::hidl_vec<uint8_t>& data) override {
        ALOGI("Info: received event: %d, arg: %d, size: %zu", event, arg, data.size());

        return Void();
    }
};

TEST_F(MediaCasHidlTest, EnumeratePlugins) {
    description("Test enumerate plugins");
    hidl_vec<HidlCasPluginDescriptor> descriptors;
    EXPECT_TRUE(mService
                    ->enumeratePlugins([&descriptors](
                        hidl_vec<HidlCasPluginDescriptor> const& desc) { descriptors = desc; })
                    .isOk());

    if (descriptors.size() == 0) {
        ALOGW("[   WARN   ] enumeratePlugins list empty");
        return;
    }

    sp<MediaCasListener> casListener = new MediaCasListener();
    for (size_t i = 0; i < descriptors.size(); i++) {
        int32_t caSystemId = descriptors[i].caSystemId;
        bool status = mService->isSystemIdSupported(caSystemId);
        ASSERT_EQ(status, true);

        status = mService->isDescramblerSupported(caSystemId);
        ASSERT_EQ(status, true);

        sp<ICas> mediaCas = mService->createPlugin(caSystemId, casListener);
        ASSERT_NE(mediaCas, nullptr);

        sp<IDescramblerBase> descramblerBase = mService->createDescrambler(caSystemId);
        ASSERT_NE(descramblerBase, nullptr);
    }
}

TEST_F(MediaCasHidlTest, TestInvalidSystemIdFails) {
    description("Test failure for invalid system ID");
    sp<MediaCasListener> casListener = new MediaCasListener();

    ASSERT_FALSE(mService->isSystemIdSupported(INVALID_SYSTEM_ID));
    ASSERT_FALSE(mService->isDescramblerSupported(INVALID_SYSTEM_ID));

    sp<ICas> mediaCas = mService->createPlugin(INVALID_SYSTEM_ID, casListener);
    EXPECT_EQ(mediaCas, nullptr);

    sp<IDescramblerBase> descramblerBase = mService->createDescrambler(INVALID_SYSTEM_ID);
    EXPECT_EQ(descramblerBase, nullptr);
}

TEST_F(MediaCasHidlTest, TestClearKeyPluginInstalled) {
    description("Test if ClearKey plugin is installed");
    hidl_vec<HidlCasPluginDescriptor> descriptors;
    EXPECT_TRUE(mService
                    ->enumeratePlugins([&descriptors](
                        hidl_vec<HidlCasPluginDescriptor> const& _desc) { descriptors = _desc; })
                    .isOk());

    if (descriptors.size() == 0) {
        ALOGW("[   WARN   ] enumeratePlugins list empty");
    }

    for (size_t i = 0; i < descriptors.size(); i++) {
        int32_t caSystemId = descriptors[i].caSystemId;
        if (CLEAR_KEY_SYSTEM_ID == caSystemId) {
            return;
        }
    }

    ASSERT_TRUE(false) << "ClearKey plugin not installed";
}

}  // anonymous namespace

int main(int argc, char** argv) {
    ::testing::InitGoogleTest(&argc, argv);
    int status = RUN_ALL_TESTS();
    LOG(INFO) << "Test result = " << status;
    return status;
}
+1 −0
Original line number Diff line number Diff line
// This is an autogenerated file, do not edit.
subdirs = [
    "1.0",
    "1.0/vts/functional",
    "1.0/default",
    "native/1.0",
]
+30 −37
Original line number Diff line number Diff line
@@ -171,7 +171,7 @@ class AudioDecHidlTest : public ::testing::VtsHalHidlTargetTestBase {
            {"mp3", mp3}, {"amrnb", amrnb},       {"amrwb", amrwb},
            {"aac", aac}, {"vorbis", vorbis},     {"opus", opus},
            {"pcm", pcm}, {"g711alaw", g711alaw}, {"g711mlaw", g711mlaw},
            {"gsm", gsm}, {"raw", raw},
            {"gsm", gsm}, {"raw", raw},           {"flac", flac},
        };
        const size_t kNumStringToName =
            sizeof(kStringToName) / sizeof(kStringToName[0]);
@@ -204,6 +204,7 @@ class AudioDecHidlTest : public ::testing::VtsHalHidlTargetTestBase {
            {g711mlaw, OMX_AUDIO_CodingG711},
            {gsm, OMX_AUDIO_CodingGSMFR},
            {raw, OMX_AUDIO_CodingPCM},
            {flac, OMX_AUDIO_CodingFLAC},
        };
        static const size_t kNumCompToCoding =
            sizeof(kCompToCoding) / sizeof(kCompToCoding[0]);
@@ -219,7 +220,7 @@ class AudioDecHidlTest : public ::testing::VtsHalHidlTargetTestBase {
        framesReceived = 0;
        timestampUs = 0;
        timestampDevTest = false;
        if (disableTest) std::cerr << "[          ] Warning !  Test Disabled\n";
        if (disableTest) std::cout << "[   WARN   ] Test Disabled \n";
    }

    virtual void TearDown() override {
@@ -263,8 +264,7 @@ class AudioDecHidlTest : public ::testing::VtsHalHidlTargetTestBase {
                            EXPECT_EQ(tsHit, true)
                                << "TimeStamp not recognized";
                        } else {
                            std::cerr
                                << "[          ] Warning ! Received non-zero "
                            std::cout << "[   INFO   ] Received non-zero "
                                         "output / TimeStamp not recognized \n";
                        }
                    }
@@ -301,6 +301,7 @@ class AudioDecHidlTest : public ::testing::VtsHalHidlTargetTestBase {
        g711mlaw,
        gsm,
        raw,
        flac,
        unknown_comp,
    };

@@ -431,6 +432,16 @@ void getInputChannelInfo(sp<IOmxNode> omxNode, OMX_U32 kPortIndexInput,
            *nSampleRate = param.nSampleRate;
            break;
        }
        case OMX_AUDIO_CodingFLAC: {
            OMX_AUDIO_PARAM_FLACTYPE param;
            status = getPortParam(omxNode, OMX_IndexParamAudioFlac,
                                  kPortIndexInput, &param);
            ASSERT_EQ(status,
                      ::android::hardware::media::omx::V1_0::Status::OK);
            *nChannels = param.nChannels;
            *nSampleRate = param.nSampleRate;
            break;
        }
        default:
            ASSERT_TRUE(false);
            break;
@@ -472,6 +483,9 @@ void GetURLForComponent(AudioDecHidlTest::standardComp comp, char* mURL,
         "bbb_gsm_1ch_8khz_13kbps.info"},
        {AudioDecHidlTest::standardComp::raw, "bbb_raw_1ch_8khz_s32le.raw",
         "bbb_raw_1ch_8khz_s32le.info"},
        {AudioDecHidlTest::standardComp::flac,
         "bbb_flac_stereo_680kbps_48000hz.flac",
         "bbb_flac_stereo_680kbps_48000hz.info"},
    };

    for (size_t i = 0; i < sizeof(kCompToURL) / sizeof(kCompToURL[0]); ++i) {
@@ -628,39 +642,16 @@ void decodeNFrames(sp<IOmxNode> omxNode, sp<CodecObserver> observer,
                   AudioDecHidlTest::standardComp comp, bool signalEOS = true) {
    android::hardware::media::omx::V1_0::Status status;
    Message msg;

    // dispatch output buffers
    for (size_t i = 0; i < oBuffer->size(); i++) {
        dispatchOutputBuffer(omxNode, oBuffer, i);
    }
    // dispatch input buffers
    size_t index;
    uint32_t flags = 0;
    int frameID = offset;
    for (size_t i = 0; (i < iBuffer->size()) && (frameID < (int)Info->size()) &&
                       (frameID < (offset + range));
         i++) {
        char* ipBuffer = static_cast<char*>(
            static_cast<void*>((*iBuffer)[i].mMemory->getPointer()));
        ASSERT_LE((*Info)[frameID].bytesCount,
                  static_cast<int>((*iBuffer)[i].mMemory->getSize()));
        eleStream.read(ipBuffer, (*Info)[frameID].bytesCount);
        ASSERT_EQ(eleStream.gcount(), (*Info)[frameID].bytesCount);
        flags = (*Info)[frameID].flags;
        if (signalEOS && ((frameID == (int)Info->size() - 1) ||
                          (frameID == (offset + range - 1))))
            flags |= OMX_BUFFERFLAG_EOS;
        dispatchInputBuffer(omxNode, iBuffer, i, (*Info)[frameID].bytesCount,
                            flags, (*Info)[frameID].timestamp);
        frameID++;
    }

    int timeOut = TIMEOUT_COUNTER_Q;
    bool iQueued, oQueued;

    while (1) {
        iQueued = oQueued = false;
        status =
            observer->dequeueMessage(&msg, DEFAULT_TIMEOUT_Q, iBuffer, oBuffer);

        // Port Reconfiguration
        if (status == android::hardware::media::omx::V1_0::Status::OK &&
            msg.type == Message::Type::EVENT) {
@@ -673,7 +664,6 @@ void decodeNFrames(sp<IOmxNode> omxNode, sp<CodecObserver> observer,
        if (frameID == (int)Info->size() || frameID == (offset + range)) break;

        // Dispatch input buffer
        size_t index = 0;
        if ((index = getEmptyBufferID(iBuffer)) < iBuffer->size()) {
            char* ipBuffer = static_cast<char*>(
                static_cast<void*>((*iBuffer)[index].mMemory->getPointer()));
@@ -682,6 +672,11 @@ void decodeNFrames(sp<IOmxNode> omxNode, sp<CodecObserver> observer,
            eleStream.read(ipBuffer, (*Info)[frameID].bytesCount);
            ASSERT_EQ(eleStream.gcount(), (*Info)[frameID].bytesCount);
            flags = (*Info)[frameID].flags;
            // Indicate to omx core that the buffer contains a full frame worth
            // of data
            flags |= OMX_BUFFERFLAG_ENDOFFRAME;
            // Indicate the omx core that this is the last buffer it needs to
            // process
            if (signalEOS && ((frameID == (int)Info->size() - 1) ||
                              (frameID == (offset + range - 1))))
                flags |= OMX_BUFFERFLAG_EOS;
@@ -691,10 +686,12 @@ void decodeNFrames(sp<IOmxNode> omxNode, sp<CodecObserver> observer,
            frameID++;
            iQueued = true;
        }
        // Dispatch output buffer
        if ((index = getEmptyBufferID(oBuffer)) < oBuffer->size()) {
            dispatchOutputBuffer(omxNode, oBuffer, index);
            oQueued = true;
        }
        // Reset Counters when either input or output buffer is dispatched
        if (iQueued || oQueued)
            timeOut = TIMEOUT_COUNTER_Q;
        else
@@ -716,7 +713,7 @@ TEST_F(AudioDecHidlTest, SetRole) {
}

// port format enumeration
TEST_F(AudioDecHidlTest, DISABLED_EnumeratePortFormat) {
TEST_F(AudioDecHidlTest, EnumeratePortFormat) {
    description("Test Component on Mandatory Port Parameters (Port Format)");
    if (disableTest) return;
    android::hardware::media::omx::V1_0::Status status;
@@ -822,11 +819,7 @@ TEST_F(AudioDecHidlTest, DecodeTest) {
}

// end of sequence test
// SPECIAL CASE; Sending Empty input EOS buffer is not supported across all
// components. For instance soft vorbis and soft opus expects CSD buffers at
// the start. Disabling this test for now. We shall revisit this at a later
// stage
TEST_F(AudioDecHidlTest, DISABLED_EOSTest_M) {
TEST_F(AudioDecHidlTest, EOSTest_M) {
    description("Test end of stream monkeying");
    if (disableTest) return;
    android::hardware::media::omx::V1_0::Status status;
+7 −24
Original line number Diff line number Diff line
@@ -206,7 +206,7 @@ class AudioEncHidlTest : public ::testing::VtsHalHidlTargetTestBase {
        }
        if (i == kNumCompToCoding) disableTest = true;
        eosFlag = false;
        if (disableTest) std::cerr << "[          ] Warning !  Test Disabled\n";
        if (disableTest) std::cout << "[   WARN   ] Test Disabled \n";
    }

    virtual void TearDown() override {
@@ -376,44 +376,25 @@ void encodeNFrames(sp<IOmxNode> omxNode, sp<CodecObserver> observer,
                   bool signalEOS = true) {
    android::hardware::media::omx::V1_0::Status status;
    Message msg;

    // dispatch output buffers
    for (size_t i = 0; i < oBuffer->size(); i++) {
        dispatchOutputBuffer(omxNode, oBuffer, i);
    }
    // dispatch input buffers
    size_t index;
    int bytesCount = samplesPerFrame * nChannels * 2;
    int32_t timestampIncr =
        (int)(((float)samplesPerFrame / nSampleRate) * 1000000);
    uint64_t timestamp = 0;
    uint32_t flags = 0;
    for (size_t i = 0; i < iBuffer->size() && nFrames != 0; i++) {
        char* ipBuffer = static_cast<char*>(
            static_cast<void*>((*iBuffer)[i].mMemory->getPointer()));
        ASSERT_LE(bytesCount,
                  static_cast<int>((*iBuffer)[i].mMemory->getSize()));
        eleStream.read(ipBuffer, bytesCount);
        if (eleStream.gcount() != bytesCount) break;
        if (signalEOS && (nFrames == 1)) flags = OMX_BUFFERFLAG_EOS;
        dispatchInputBuffer(omxNode, iBuffer, i, bytesCount, flags, timestamp);
        timestamp += timestampIncr;
        nFrames--;
    }

    int timeOut = TIMEOUT_COUNTER_Q;
    bool iQueued, oQueued;

    while (1) {
        iQueued = oQueued = false;
        status =
            observer->dequeueMessage(&msg, DEFAULT_TIMEOUT_Q, iBuffer, oBuffer);

        if (status == android::hardware::media::omx::V1_0::Status::OK)
            ASSERT_TRUE(false);

        if (nFrames == 0) break;

        // Dispatch input buffer
        size_t index = 0;
        if ((index = getEmptyBufferID(iBuffer)) < iBuffer->size()) {
            char* ipBuffer = static_cast<char*>(
                static_cast<void*>((*iBuffer)[index].mMemory->getPointer()));
@@ -421,7 +402,8 @@ void encodeNFrames(sp<IOmxNode> omxNode, sp<CodecObserver> observer,
                      static_cast<int>((*iBuffer)[index].mMemory->getSize()));
            eleStream.read(ipBuffer, bytesCount);
            if (eleStream.gcount() != bytesCount) break;
            if (signalEOS && (nFrames == 1)) flags = OMX_BUFFERFLAG_EOS;
            flags = OMX_BUFFERFLAG_ENDOFFRAME;
            if (signalEOS && (nFrames == 1)) flags |= OMX_BUFFERFLAG_EOS;
            dispatchInputBuffer(omxNode, iBuffer, index, bytesCount, flags,
                                timestamp);
            timestamp += timestampIncr;
@@ -433,6 +415,7 @@ void encodeNFrames(sp<IOmxNode> omxNode, sp<CodecObserver> observer,
            dispatchOutputBuffer(omxNode, oBuffer, index);
            oQueued = true;
        }
        // Reset Counters when either input or output buffer is dispatched
        if (iQueued || oQueued)
            timeOut = TIMEOUT_COUNTER_Q;
        else
@@ -454,7 +437,7 @@ TEST_F(AudioEncHidlTest, SetRole) {
}

// port format enumeration
TEST_F(AudioEncHidlTest, DISABLED_EnumeratePortFormat) {
TEST_F(AudioEncHidlTest, EnumeratePortFormat) {
    description("Test Component on Mandatory Port Parameters (Port Format)");
    if (disableTest) return;
    android::hardware::media::omx::V1_0::Status status;
Loading