1 /*
2 * Copyright (C) 2020 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17 /**
18 * Instantiate the set of test cases for each vendor module
19 */
20
21 #define LOG_TAG "drm_hal_test@1.3"
22
23 #include <android/hardware/drm/1.3/ICryptoFactory.h>
24 #include <android/hardware/drm/1.3/IDrmFactory.h>
25 #include <gtest/gtest.h>
26 #include <hidl/HidlSupport.h>
27 #include <hidl/ServiceManagement.h>
28 #include <log/log.h>
29
30 #include <algorithm>
31 #include <iterator>
32 #include <string>
33 #include <utility>
34 #include <vector>
35
36 #include "android/hardware/drm/1.0/vts/drm_hal_clearkey_test.h" // V1_0 tests
37 #include "android/hardware/drm/1.0/vts/drm_hal_vendor_test.h" // V1_0 tests
38 #include "android/hardware/drm/1.1/vts/drm_hal_clearkey_test.h" // V1_1 tests
39 #include "android/hardware/drm/1.2/vts/drm_hal_common.h" // V1_2 tests
40 #include "android/hardware/drm/1.3/vts/drm_hal_test.h" // V1_3 tests
41
42 using drm_vts::DrmHalTestParam;
43 using drm_vts::PrintParamInstanceToString;
44
45 using android::hardware::drm::V1_0::vts::DrmHalVendorFactoryTest;
46 using android::hardware::drm::V1_0::vts::DrmHalVendorPluginTest;
47 using android::hardware::drm::V1_0::vts::DrmHalVendorDecryptTest;
48 using android::hardware::drm::V1_0::vts::DrmHalClearkeyFactoryTest;
49 using android::hardware::drm::V1_0::vts::DrmHalClearkeyPluginTest;
50 using android::hardware::drm::V1_0::vts::DrmHalClearkeyDecryptTest;
51 using android::hardware::drm::V1_1::vts::DrmHalClearkeyTest;
52 using android::hardware::drm::V1_2::vts::DrmHalTest;
53 using android::hardware::drm::V1_2::vts::DrmHalClearkeyTestV1_2;
54 using android::hardware::drm::V1_3::vts::DrmHalTestV1_3;
55
__anon04d2805b0102null56 static const std::vector<DrmHalTestParam> kAllInstances = [] {
57 using ::android::hardware::drm::V1_3::ICryptoFactory;
58 using ::android::hardware::drm::V1_3::IDrmFactory;
59
60 std::vector<std::string> drmInstances =
61 android::hardware::getAllHalInstanceNames(IDrmFactory::descriptor);
62 std::vector<std::string> cryptoInstances =
63 android::hardware::getAllHalInstanceNames(ICryptoFactory::descriptor);
64 std::set<std::string> allInstances;
65 allInstances.insert(drmInstances.begin(), drmInstances.end());
66 allInstances.insert(cryptoInstances.begin(), cryptoInstances.end());
67
68 std::vector<DrmHalTestParam> allInstanceUuidCombos;
69 for (const auto &instance : allInstances) {
70 auto drmFactory = IDrmFactory::getService(instance);
71 if (drmFactory == nullptr) {
72 continue;
73 }
74 drmFactory->getSupportedCryptoSchemes(
75 [&](const hidl_vec<hidl_array<uint8_t, 16>>& schemes) {
76 for (const auto &scheme : schemes) {
77 allInstanceUuidCombos.push_back(DrmHalTestParam(instance, scheme));
78 }
79 });
80 }
81 return allInstanceUuidCombos;
82 }();
83
84 GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(DrmHalVendorFactoryTest);
85 INSTANTIATE_TEST_CASE_P(PerInstanceUuidV1_0, DrmHalVendorFactoryTest,
86 testing::ValuesIn(kAllInstances),
87 drm_vts::PrintParamInstanceToString);
88 GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(DrmHalVendorPluginTest);
89 INSTANTIATE_TEST_CASE_P(PerInstanceUuidV1_0, DrmHalVendorPluginTest,
90 testing::ValuesIn(kAllInstances),
91 drm_vts::PrintParamInstanceToString);
92 GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(DrmHalVendorDecryptTest);
93 INSTANTIATE_TEST_CASE_P(PerInstanceUuidV1_0, DrmHalVendorDecryptTest,
94 testing::ValuesIn(kAllInstances),
95 drm_vts::PrintParamInstanceToString);
96
97 GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(DrmHalClearkeyFactoryTest);
98 INSTANTIATE_TEST_SUITE_P(PerInstanceUuidV1_0, DrmHalClearkeyFactoryTest,
99 testing::ValuesIn(kAllInstances),
100 drm_vts::PrintParamInstanceToString);
101 GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(DrmHalClearkeyPluginTest);
102 INSTANTIATE_TEST_SUITE_P(PerInstanceUuidV1_0, DrmHalClearkeyPluginTest,
103 testing::ValuesIn(kAllInstances),
104 drm_vts::PrintParamInstanceToString);
105 GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(DrmHalClearkeyDecryptTest);
106 INSTANTIATE_TEST_SUITE_P(PerInstanceUuidV1_0, DrmHalClearkeyDecryptTest,
107 testing::ValuesIn(kAllInstances),
108 drm_vts::PrintParamInstanceToString);
109
110 GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(DrmHalClearkeyTest);
111 INSTANTIATE_TEST_SUITE_P(PerInstanceUuidV1_1, DrmHalClearkeyTest,
112 testing::ValuesIn(kAllInstances),
113 PrintParamInstanceToString);
114
115 GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(DrmHalTest);
116 INSTANTIATE_TEST_SUITE_P(PerInstanceUuidV1_2, DrmHalTest,
117 testing::ValuesIn(kAllInstances),
118 PrintParamInstanceToString);
119 GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(DrmHalClearkeyTestV1_2);
120 INSTANTIATE_TEST_SUITE_P(PerInstanceUuidV1_2, DrmHalClearkeyTestV1_2,
121 testing::ValuesIn(kAllInstances),
122 PrintParamInstanceToString);
123
124 GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(DrmHalTestV1_3);
125 INSTANTIATE_TEST_SUITE_P(PerInstanceUuidV1_3, DrmHalTestV1_3,
126 testing::ValuesIn(kAllInstances),
127 PrintParamInstanceToString);
128
main(int argc,char ** argv)129 int main(int argc, char** argv) {
130 #if defined(__LP64__)
131 const char* kModulePath = "/data/local/tmp/64/lib";
132 #else
133 const char* kModulePath = "/data/local/tmp/32/lib";
134 #endif
135 DrmHalTest::gVendorModules = new drm_vts::VendorModules(kModulePath);
136 if (DrmHalTest::gVendorModules->getPathList().size() == 0) {
137 std::cerr << "WARNING: No vendor modules found in " << kModulePath <<
138 ", all vendor tests will be skipped" << std::endl;
139 }
140 ::testing::InitGoogleTest(&argc, argv);
141 int status = RUN_ALL_TESTS();
142 ALOGI("Test result = %d", status);
143 return status;
144 }
145