diff --git a/drm/1.0/vts/functional/Android.bp b/drm/1.0/vts/functional/Android.bp index 4fbd54df50..c7b022f59e 100644 --- a/drm/1.0/vts/functional/Android.bp +++ b/drm/1.0/vts/functional/Android.bp @@ -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", @@ -31,6 +45,7 @@ cc_test { "libnativehelper", "libssl", "libcrypto_static", + "libdrmvtshelper", ], test_suites: [ "general-tests", diff --git a/drm/1.0/vts/functional/include/drm_vts_helper.h b/drm/1.0/vts/functional/include/drm_vts_helper.h new file mode 100644 index 0000000000..1f02af9460 --- /dev/null +++ b/drm/1.0/vts/functional/include/drm_vts_helper.h @@ -0,0 +1,58 @@ +/* + * 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 +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace drm_vts { + +using ::android::hardware::hidl_array; + +struct DrmHalTestParam { + const std::string instance_; + const hidl_array scheme_{}; + DrmHalTestParam(const std::string& instance) : instance_(instance) {} + DrmHalTestParam(const std::string& instance, const hidl_array& 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& 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 diff --git a/drm/1.0/vts/functional/vendor_modules.h b/drm/1.0/vts/functional/include/vendor_modules.h similarity index 93% rename from drm/1.0/vts/functional/vendor_modules.h rename to drm/1.0/vts/functional/include/vendor_modules.h index 8330b0a1ff..3f6fa1573d 100644 --- a/drm/1.0/vts/functional/vendor_modules.h +++ b/drm/1.0/vts/functional/include/vendor_modules.h @@ -51,6 +51,11 @@ class VendorModules { */ std::vector getPathList() const {return mPathList;} + /** + * Retrieve a DrmHalVTSVendorModule given a service name. + */ + DrmHalVTSVendorModule* getModuleByName(const std::string& name); + private: std::vector mPathList; std::map> mOpenLibraries; diff --git a/drm/1.0/vts/functional/vendor_modules.cpp b/drm/1.0/vts/functional/vendor_modules.cpp index 98430f550e..53927bd182 100644 --- a/drm/1.0/vts/functional/vendor_modules.cpp +++ b/drm/1.0/vts/functional/vendor_modules.cpp @@ -23,6 +23,7 @@ #include #include +#include "drm_hal_vendor_module_api.h" #include "vendor_modules.h" using std::string; @@ -69,4 +70,15 @@ DrmHalVTSVendorModule* VendorModules::getModule(const string& path) { ModuleFactory moduleFactory = reinterpret_cast(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; +} };