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

Commit f2fd4ade authored by Robert Shih's avatar Robert Shih
Browse files

drm vts: introduce helper library

The helper library includes
* gtest parameter structure (hal instance name, drm scheme uuid)
* existing vendor module APIs

Bug: 142397658
Test: VtsHalDrmV1_0TargetTest
Change-Id: Ifbb443fcb1414e45de2a2073ec545ddd422b9a4d
parent 116a7e2e
Loading
Loading
Loading
Loading
+16 −1
Original line number Original line Diff line number Diff line
@@ -14,13 +14,27 @@
// limitations under the License.
// limitations under the License.
//
//


cc_library_static {
    name: "libdrmvtshelper",
    defaults: ["VtsHalTargetTestDefaults"],
    local_include_dirs: [
        "include",
    ],
    srcs: [
        "vendor_modules.cpp",
    ],
    static_libs: [
       "android.hardware.drm@1.0-helper",
    ],
    export_include_dirs: ["include"],
}

cc_test {
cc_test {
    name: "VtsHalDrmV1_0TargetTest",
    name: "VtsHalDrmV1_0TargetTest",
    defaults: ["VtsHalTargetTestDefaults"],
    defaults: ["VtsHalTargetTestDefaults"],
    srcs: [
    srcs: [
        "drm_hal_clearkey_test.cpp",
        "drm_hal_clearkey_test.cpp",
        "drm_hal_vendor_test.cpp",
        "drm_hal_vendor_test.cpp",
        "vendor_modules.cpp",
    ],
    ],
    static_libs: [
    static_libs: [
        "android.hardware.drm@1.0",
        "android.hardware.drm@1.0",
@@ -31,6 +45,7 @@ cc_test {
        "libnativehelper",
        "libnativehelper",
        "libssl",
        "libssl",
        "libcrypto_static",
        "libcrypto_static",
        "libdrmvtshelper",
    ],
    ],
    test_suites: [
    test_suites: [
        "general-tests",
        "general-tests",
+58 −0
Original line number Original line Diff line number Diff line
/*
 * Copyright (C) 2020 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.
 */

#ifndef DRM_VTS_HELPER_H
#define DRM_VTS_HELPER_H

#include <hidl/GtestPrinter.h>
#include <hidl/HidlSupport.h>

#include <array>
#include <chrono>
#include <iostream>
#include <map>
#include <memory>
#include <string>
#include <utility>
#include <vector>

namespace drm_vts {

using ::android::hardware::hidl_array;

struct DrmHalTestParam {
    const std::string instance_;
    const hidl_array<uint8_t, 16> scheme_{};
    DrmHalTestParam(const std::string& instance) : instance_(instance) {}
    DrmHalTestParam(const std::string& instance, const hidl_array<uint8_t, 16>& scheme)
        : instance_(instance), scheme_(scheme) {}
};

inline std::ostream& operator<<(std::ostream& stream, const DrmHalTestParam& val) {
      stream << val.instance_ << ", " << android::hardware::toString(val.scheme_);
      return stream;
}

inline std::string PrintParamInstanceToString(
        const testing::TestParamInfo<DrmHalTestParam>& info) {
    // test names need to be unique -> index prefix
    std::string name = std::to_string(info.index) + "/" + info.param.instance_;
    return android::hardware::Sanitize(name);
};

}  // namespace drm_vts

#endif  // DRM_VTS_HELPER_H
+5 −0
Original line number Original line Diff line number Diff line
@@ -51,6 +51,11 @@ class VendorModules {
     */
     */
    std::vector<std::string> getPathList() const {return mPathList;}
    std::vector<std::string> getPathList() const {return mPathList;}


    /**
     * Retrieve a DrmHalVTSVendorModule given a service name.
     */
    DrmHalVTSVendorModule* getModuleByName(const std::string& name);

   private:
   private:
    std::vector<std::string> mPathList;
    std::vector<std::string> mPathList;
    std::map<std::string, std::unique_ptr<SharedLibrary>> mOpenLibraries;
    std::map<std::string, std::unique_ptr<SharedLibrary>> mOpenLibraries;
+12 −0
Original line number Original line Diff line number Diff line
@@ -23,6 +23,7 @@
#include <utils/String8.h>
#include <utils/String8.h>
#include <SharedLibrary.h>
#include <SharedLibrary.h>


#include "drm_hal_vendor_module_api.h"
#include "vendor_modules.h"
#include "vendor_modules.h"


using std::string;
using std::string;
@@ -69,4 +70,15 @@ DrmHalVTSVendorModule* VendorModules::getModule(const string& path) {
    ModuleFactory moduleFactory = reinterpret_cast<ModuleFactory>(symbol);
    ModuleFactory moduleFactory = reinterpret_cast<ModuleFactory>(symbol);
    return (*moduleFactory)();
    return (*moduleFactory)();
}
}

DrmHalVTSVendorModule* VendorModules::getModuleByName(const string& name) {
    for (const auto &path : mPathList) {
        auto module = getModule(path);
        if (module->getServiceName() == name) {
            return module;
        }

    }
    return NULL;
}
};
};