• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2021 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_main"
22 
23 #include <aidl/Gtest.h>
24 #include <aidl/Vintf.h>
25 #include <android/binder_process.h>
26 #include <log/log.h>
27 
28 #include <gtest/gtest.h>
29 
30 #include <algorithm>
31 #include <iterator>
32 #include <string>
33 #include <utility>
34 #include <vector>
35 
36 #include "drm_hal_common.h"
37 
38 using ::aidl::android::hardware::drm::vts::DrmHalClearkeyTest;
39 using ::aidl::android::hardware::drm::vts::DrmHalTest;
40 using ::aidl::android::hardware::drm::vts::HalBaseName;
41 using drm_vts::DrmHalTestParam;
42 using drm_vts::PrintParamInstanceToString;
43 
getAllInstances()44 static const std::vector<DrmHalTestParam> getAllInstances() {
45     using ::aidl::android::hardware::drm::IDrmFactory;
46 
47     std::vector<std::string> drmInstances =
48             android::getAidlHalInstanceNames(IDrmFactory::descriptor);
49 
50     std::set<std::string> allInstances;
51     for (auto svc : drmInstances) {
52         allInstances.insert(HalBaseName(svc));
53     }
54 
55     std::vector<DrmHalTestParam> allInstanceUuidCombos;
56     auto noUUID = [](std::string s) { return DrmHalTestParam(s); };
57     std::transform(allInstances.begin(), allInstances.end(),
58                    std::back_inserter(allInstanceUuidCombos), noUUID);
59     return allInstanceUuidCombos;
60 };
61 
62 GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(DrmHalTest);
63 INSTANTIATE_TEST_SUITE_P(PerInstance, DrmHalTest, testing::ValuesIn(getAllInstances()),
64                          PrintParamInstanceToString);
65 GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(DrmHalClearkeyTest);
66 INSTANTIATE_TEST_SUITE_P(PerInstance, DrmHalClearkeyTest, testing::ValuesIn(getAllInstances()),
67                          PrintParamInstanceToString);
68 
main(int argc,char ** argv)69 int main(int argc, char** argv) {
70 #if defined(__LP64__)
71     const char* kModulePath = "/data/local/tmp/64/lib";
72 #else
73     const char* kModulePath = "/data/local/tmp/32/lib";
74 #endif
75     DrmHalTest::gVendorModules = new drm_vts::VendorModules(kModulePath);
76     if (DrmHalTest::gVendorModules->getPathList().size() == 0) {
77         std::cerr << "WARNING: No vendor modules found in " << kModulePath
78                   << ", all vendor tests will be skipped" << std::endl;
79     }
80     ABinderProcess_setThreadPoolMaxThreadCount(1);
81     ABinderProcess_startThreadPool();
82     ::testing::InitGoogleTest(&argc, argv);
83     int status = RUN_ALL_TESTS();
84     ALOGI("Test result = %d", status);
85     return status;
86 }
87