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 "[email protected]"
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 INSTANTIATE_TEST_CASE_P(PerInstanceUuidV1_0, DrmHalVendorFactoryTest,
85 testing::ValuesIn(kAllInstances),
86 drm_vts::PrintParamInstanceToString);
87 INSTANTIATE_TEST_CASE_P(PerInstanceUuidV1_0, DrmHalVendorPluginTest,
88 testing::ValuesIn(kAllInstances),
89 drm_vts::PrintParamInstanceToString);
90 INSTANTIATE_TEST_CASE_P(PerInstanceUuidV1_0, DrmHalVendorDecryptTest,
91 testing::ValuesIn(kAllInstances),
92 drm_vts::PrintParamInstanceToString);
93
94 INSTANTIATE_TEST_SUITE_P(PerInstanceUuidV1_0, DrmHalClearkeyFactoryTest,
95 testing::ValuesIn(kAllInstances),
96 drm_vts::PrintParamInstanceToString);
97 INSTANTIATE_TEST_SUITE_P(PerInstanceUuidV1_0, DrmHalClearkeyPluginTest,
98 testing::ValuesIn(kAllInstances),
99 drm_vts::PrintParamInstanceToString);
100 INSTANTIATE_TEST_SUITE_P(PerInstanceUuidV1_0, DrmHalClearkeyDecryptTest,
101 testing::ValuesIn(kAllInstances),
102 drm_vts::PrintParamInstanceToString);
103
104 INSTANTIATE_TEST_SUITE_P(PerInstanceUuidV1_1, DrmHalClearkeyTest,
105 testing::ValuesIn(kAllInstances),
106 PrintParamInstanceToString);
107
108 INSTANTIATE_TEST_SUITE_P(PerInstanceUuidV1_2, DrmHalTest,
109 testing::ValuesIn(kAllInstances),
110 PrintParamInstanceToString);
111 INSTANTIATE_TEST_SUITE_P(PerInstanceUuidV1_2, DrmHalClearkeyTestV1_2,
112 testing::ValuesIn(kAllInstances),
113 PrintParamInstanceToString);
114
115 INSTANTIATE_TEST_SUITE_P(PerInstanceUuidV1_3, DrmHalTestV1_3,
116 testing::ValuesIn(kAllInstances),
117 PrintParamInstanceToString);
118
main(int argc,char ** argv)119 int main(int argc, char** argv) {
120 #if defined(__LP64__)
121 const char* kModulePath = "/data/local/tmp/64/lib";
122 #else
123 const char* kModulePath = "/data/local/tmp/32/lib";
124 #endif
125 DrmHalTest::gVendorModules = new drm_vts::VendorModules(kModulePath);
126 if (DrmHalTest::gVendorModules->getPathList().size() == 0) {
127 std::cerr << "WARNING: No vendor modules found in " << kModulePath <<
128 ", all vendor tests will be skipped" << std::endl;
129 }
130 ::testing::InitGoogleTest(&argc, argv);
131 int status = RUN_ALL_TESTS();
132 ALOGI("Test result = %d", status);
133 return status;
134 }
135