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 
__anon63cb13ba0102null41 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 GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(DrmHalTest);
61 INSTANTIATE_TEST_SUITE_P(PerInstance, DrmHalTest, testing::ValuesIn(kAllInstances),
62                          PrintParamInstanceToString);
63 GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(DrmHalClearkeyTestV1_2);
64 INSTANTIATE_TEST_SUITE_P(PerInstance, DrmHalClearkeyTestV1_2, testing::ValuesIn(kAllInstances),
65                          PrintParamInstanceToString);
66 
main(int argc,char ** argv)67 int main(int argc, char** argv) {
68 #if defined(__LP64__)
69     const char* kModulePath = "/data/local/tmp/64/lib";
70 #else
71     const char* kModulePath = "/data/local/tmp/32/lib";
72 #endif
73     DrmHalTest::gVendorModules = new drm_vts::VendorModules(kModulePath);
74     if (DrmHalTest::gVendorModules->getPathList().size() == 0) {
75         std::cerr << "WARNING: No vendor modules found in " << kModulePath <<
76                 ", all vendor tests will be skipped" << std::endl;
77     }
78     ::testing::InitGoogleTest(&argc, argv);
79     int status = RUN_ALL_TESTS();
80     ALOGI("Test result = %d", status);
81     return status;
82 }
83