Loading drm/1.0/vts/functional/Android.bp +16 −1 Original line number Diff line number Diff line Loading @@ -14,13 +14,27 @@ // 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 { name: "VtsHalDrmV1_0TargetTest", defaults: ["VtsHalTargetTestDefaults"], srcs: [ "drm_hal_clearkey_test.cpp", "drm_hal_vendor_test.cpp", "vendor_modules.cpp", ], static_libs: [ "android.hardware.drm@1.0", Loading @@ -31,6 +45,7 @@ cc_test { "libnativehelper", "libssl", "libcrypto_static", "libdrmvtshelper", ], test_suites: [ "general-tests", Loading drm/1.0/vts/functional/include/drm_vts_helper.h 0 → 100644 +58 −0 Original line number 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 drm/1.0/vts/functional/vendor_modules.h→drm/1.0/vts/functional/include/vendor_modules.h +5 −0 Original line number Diff line number Diff line Loading @@ -51,6 +51,11 @@ class VendorModules { */ std::vector<std::string> getPathList() const {return mPathList;} /** * Retrieve a DrmHalVTSVendorModule given a service name. */ DrmHalVTSVendorModule* getModuleByName(const std::string& name); private: std::vector<std::string> mPathList; std::map<std::string, std::unique_ptr<SharedLibrary>> mOpenLibraries; Loading drm/1.0/vts/functional/vendor_modules.cpp +12 −0 Original line number Diff line number Diff line Loading @@ -23,6 +23,7 @@ #include <utils/String8.h> #include <SharedLibrary.h> #include "drm_hal_vendor_module_api.h" #include "vendor_modules.h" using std::string; Loading Loading @@ -69,4 +70,15 @@ DrmHalVTSVendorModule* VendorModules::getModule(const string& path) { ModuleFactory moduleFactory = reinterpret_cast<ModuleFactory>(symbol); 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; } }; Loading
drm/1.0/vts/functional/Android.bp +16 −1 Original line number Diff line number Diff line Loading @@ -14,13 +14,27 @@ // 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 { name: "VtsHalDrmV1_0TargetTest", defaults: ["VtsHalTargetTestDefaults"], srcs: [ "drm_hal_clearkey_test.cpp", "drm_hal_vendor_test.cpp", "vendor_modules.cpp", ], static_libs: [ "android.hardware.drm@1.0", Loading @@ -31,6 +45,7 @@ cc_test { "libnativehelper", "libssl", "libcrypto_static", "libdrmvtshelper", ], test_suites: [ "general-tests", Loading
drm/1.0/vts/functional/include/drm_vts_helper.h 0 → 100644 +58 −0 Original line number 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
drm/1.0/vts/functional/vendor_modules.h→drm/1.0/vts/functional/include/vendor_modules.h +5 −0 Original line number Diff line number Diff line Loading @@ -51,6 +51,11 @@ class VendorModules { */ std::vector<std::string> getPathList() const {return mPathList;} /** * Retrieve a DrmHalVTSVendorModule given a service name. */ DrmHalVTSVendorModule* getModuleByName(const std::string& name); private: std::vector<std::string> mPathList; std::map<std::string, std::unique_ptr<SharedLibrary>> mOpenLibraries; Loading
drm/1.0/vts/functional/vendor_modules.cpp +12 −0 Original line number Diff line number Diff line Loading @@ -23,6 +23,7 @@ #include <utils/String8.h> #include <SharedLibrary.h> #include "drm_hal_vendor_module_api.h" #include "vendor_modules.h" using std::string; Loading Loading @@ -69,4 +70,15 @@ DrmHalVTSVendorModule* VendorModules::getModule(const string& path) { ModuleFactory moduleFactory = reinterpret_cast<ModuleFactory>(symbol); 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; } };