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.2"
22
23 #include <gtest/gtest.h>
24 #include <hidl/HidlSupport.h>
25 #include <hidl/ServiceManagement.h>
26 #include <log/log.h>
27
28 #include <algorithm>
29 #include <iterator>
30 #include <string>
31 #include <utility>
32 #include <vector>
33
34 #include "android/hardware/drm/1.2/vts/drm_hal_common.h"
35
36 using android::hardware::drm::V1_2::vts::DrmHalTest;
37 using android::hardware::drm::V1_2::vts::DrmHalClearkeyTestV1_2;
38 using drm_vts::DrmHalTestParam;
39 using drm_vts::PrintParamInstanceToString;
40
__anone70394450102null41 static const std::vector<DrmHalTestParam> kAllInstances = [] {
42 using ::android::hardware::drm::V1_2::ICryptoFactory;
43 using ::android::hardware::drm::V1_2::IDrmFactory;
44
45 std::vector<std::string> drmInstances =
46 android::hardware::getAllHalInstanceNames(IDrmFactory::descriptor);
47 std::vector<std::string> cryptoInstances =
48 android::hardware::getAllHalInstanceNames(ICryptoFactory::descriptor);
49 std::set<std::string> allInstances;
50 allInstances.insert(drmInstances.begin(), drmInstances.end());
51 allInstances.insert(cryptoInstances.begin(), cryptoInstances.end());
52
53 std::vector<DrmHalTestParam> allInstanceUuidCombos;
54 auto noUUID = [](std::string s) { return DrmHalTestParam(s); };
55 std::transform(allInstances.begin(), allInstances.end(),
56 std::back_inserter(allInstanceUuidCombos), noUUID);
57 return allInstanceUuidCombos;
58 }();
59
60 INSTANTIATE_TEST_SUITE_P(PerInstance, DrmHalTest, testing::ValuesIn(kAllInstances),
61 PrintParamInstanceToString);
62 INSTANTIATE_TEST_SUITE_P(PerInstance, DrmHalClearkeyTestV1_2, testing::ValuesIn(kAllInstances),
63 PrintParamInstanceToString);
64
main(int argc,char ** argv)65 int main(int argc, char** argv) {
66 #if defined(__LP64__)
67 const char* kModulePath = "/data/local/tmp/64/lib";
68 #else
69 const char* kModulePath = "/data/local/tmp/32/lib";
70 #endif
71 DrmHalTest::gVendorModules = new drm_vts::VendorModules(kModulePath);
72 if (DrmHalTest::gVendorModules->getPathList().size() == 0) {
73 std::cerr << "WARNING: No vendor modules found in " << kModulePath <<
74 ", all vendor tests will be skipped" << std::endl;
75 }
76 ::testing::InitGoogleTest(&argc, argv);
77 int status = RUN_ALL_TESTS();
78 ALOGI("Test result = %d", status);
79 return status;
80 }
81