1#!/usr/bin/env python3 2# coding=utf-8 3 4# 5# Copyright (c) 2020-2022 Huawei Device Co., Ltd. 6# Licensed under the Apache License, Version 2.0 (the "License"); 7# you may not use this file except in compliance with the License. 8# You may obtain a copy of the License at 9# 10# http://www.apache.org/licenses/LICENSE-2.0 11# 12# Unless required by applicable law or agreed to in writing, software 13# distributed under the License is distributed on an "AS IS" BASIS, 14# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15# See the License for the specific language governing permissions and 16# limitations under the License. 17# 18 19from dataclasses import dataclass 20 21__all__ = ["DeviceOsType", "ProductForm", "TestType", "TestExecType", 22 "DeviceTestType", "HostTestType", "HostDrivenTestType", 23 "SchedulerType", "ListenerType", "ToolCommandType", 24 "TEST_DRIVER_SET", "LogType", "CKit", 25 "DeviceLabelType", "GTestConst", "ManagerType", 26 "ModeType", "ConfigConst", "FilePermission", "CommonParserType", 27 "DeviceConnectorType", "AdvanceDeviceOption"] 28 29 30@dataclass 31class DeviceOsType(object): 32 """ 33 DeviceOsType enumeration 34 """ 35 default = "default" 36 lite = "lite" 37 aosp = "aosp" 38 39 40@dataclass 41class ProductForm(object): 42 """ 43 ProductForm enumeration 44 """ 45 phone = "phone" 46 car = "car" 47 television = "tv" 48 watch = "watch" 49 tablet = 'tablet' 50 51 52@dataclass 53class TestType(object): 54 """ 55 TestType enumeration 56 """ 57 unittest = "unittest" 58 mst = "moduletest" 59 systemtest = "systemtest" 60 perf = "performance" 61 sec = "security" 62 reli = "reliability" 63 dst = "distributedtest" 64 benchmark = "benchmark" 65 all = "ALL" 66 67 68@dataclass 69class DeviceLabelType(object): 70 """ 71 DeviceLabelType enumeration 72 """ 73 wifiiot = "wifiiot" 74 ipcamera = "ipcamera" 75 watch_gt = "watchGT" 76 phone = "phone" 77 watch = "watch" 78 79 80TEST_TYPE_DICT = { 81 "UT": TestType.unittest, 82 "MST": TestType.mst, 83 "ST": TestType.systemtest, 84 "PERF": TestType.perf, 85 "SEC": TestType.sec, 86 "RELI": TestType.reli, 87 "DST": TestType.dst, 88 "ALL": TestType.all, 89} 90 91 92@dataclass 93class TestExecType(object): 94 """ 95 TestExecType enumeration according to test execution method 96 """ 97 # A test running on the device 98 device_test = "device" 99 # A test running on the host (pc) 100 host_test = "host" 101 # A test running on the host that interacts with one or more devices. 102 host_driven_test = "hostdriven" 103 104 105@dataclass 106class DeviceTestType(object): 107 """ 108 DeviceTestType enumeration 109 """ 110 cpp_test = "CppTest" 111 dex_test = "DexTest" 112 dex_junit_test = "DexJUnitTest" 113 hap_test = "HapTest" 114 junit_test = "JUnitTest" 115 jsunit_test = "JSUnitTest" 116 jsunit_test_lite = "JSUnitTestLite" 117 ctest_lite = "CTestLite" 118 cpp_test_lite = "CppTestLite" 119 lite_cpp_test = "LiteUnitTest" 120 open_source_test = "OpenSourceTest" 121 build_only_test = "BuildOnlyTestLite" 122 ltp_posix_test = "LtpPosixTest" 123 oh_kernel_test = "OHKernelTest" 124 oh_jsunit_test = "OHJSUnitTest" 125 hm_os_jsunit_test = "HMOSJSUnitTest" 126 oh_rust_test = "OHRustTest" 127 oh_yara_test = "OHYaraTest" 128 validator_test = "ValidatorTest" 129 130 131@dataclass 132class HostTestType(object): 133 """ 134 HostTestType enumeration 135 """ 136 host_gtest = "HostGTest" 137 host_junit_test = "HostJUnitTest" 138 139 140@dataclass 141class HostDrivenTestType(object): 142 """ 143 HostDrivenType enumeration 144 """ 145 device_test = "DeviceTest" 146 device_testsuite = "DeviceTestSuite" 147 windows_test = "WindowsTest" 148 app_test = "AppTest" 149 150 151TEST_DRIVER_SET = { 152 DeviceTestType.cpp_test, 153 DeviceTestType.dex_test, 154 DeviceTestType.hap_test, 155 DeviceTestType.junit_test, 156 DeviceTestType.dex_junit_test, 157 DeviceTestType.jsunit_test, 158 DeviceTestType.jsunit_test_lite, 159 DeviceTestType.cpp_test_lite, 160 DeviceTestType.ctest_lite, 161 DeviceTestType.lite_cpp_test, 162 DeviceTestType.ltp_posix_test, 163 DeviceTestType.oh_kernel_test, 164 DeviceTestType.oh_jsunit_test, 165 HostDrivenTestType.device_test 166} 167 168 169@dataclass 170class SchedulerType(object): 171 """ 172 SchedulerType enumeration 173 """ 174 # default scheduler 175 scheduler = "Scheduler" 176 177 178@dataclass 179class LogType: 180 tool = "Tool" 181 device = "Device" 182 183 184@dataclass 185class ListenerType: 186 log = "Log" 187 report = "Report" 188 upload = "Upload" 189 collect = "Collect" 190 collect_lite = "CollectLite" 191 collect_pass = "CollectPass" 192 193 194@dataclass 195class CommonParserType: 196 jsunit = "JSUnit" 197 cpptest = "CppTest" 198 cpptest_list = "CppTestList" 199 junit = "JUnit" 200 oh_kernel_test = "OHKernel" 201 oh_jsunit = "OHJSUnit" 202 oh_jsunit_list = "OHJSUnitList" 203 oh_rust = "OHRust" 204 oh_yara = "OHYara" 205 206 207@dataclass 208class ManagerType: 209 device = "device" 210 lite_device = "device_lite" 211 aosp_device = "device_aosp" 212 213 214@dataclass 215class ToolCommandType(object): 216 toolcmd_key_help = "help" 217 toolcmd_key_show = "show" 218 toolcmd_key_run = "run" 219 toolcmd_key_quit = "quit" 220 toolcmd_key_list = "list" 221 toolcmd_key_tool = "tool" 222 223 224@dataclass 225class CKit: 226 query = "QueryKit" 227 component = "ComponentKit" 228 229 230@dataclass 231class GTestConst(object): 232 exec_para_filter = "--gtest_filter" 233 exec_para_level = "--gtest_testsize" 234 235 236@dataclass 237class ModeType(object): 238 decc = "decc" 239 factory = "factory" 240 developer = "developer" 241 242 243@dataclass 244class ConfigConst(object): 245 action = "action" 246 task = "task" 247 testlist = "testlist" 248 testfile = "testfile" 249 testcase = "testcase" 250 testdict = "testdict" 251 device_sn = "device_sn" 252 report_path = "report_path" 253 resource_path = "resource_path" 254 testcases_path = "testcases_path" 255 testargs = "testargs" 256 pass_through = "pass_through" 257 test_environment = "test_environment" 258 exectype = "exectype" 259 testtype = "testtype" 260 testdriver = "testdriver" 261 retry = "retry" 262 session = "session" 263 dry_run = "dry_run" 264 reboot_per_module = "reboot_per_module" 265 check_device = "check_device" 266 configfile = "config" 267 repeat = "repeat" 268 subsystems = "subsystems" 269 parts = "parts" 270 renew_report = "renew_report" 271 kits_in_module = "kits_in_module" 272 kits_params = "kits_params" 273 auto_retry = "auto_retry" 274 275 # Runtime Constant 276 history_report_path = "history_report_path" 277 product_info = "product_info" 278 task_state = "task_state" 279 recover_state = "recover_state" 280 need_kit_setup = "need_kit_setup" 281 task_kits = "task_kits" 282 module_kits = "module_kits" 283 spt = "spt" 284 version = "version" 285 component_mapper = "_component_mapper" 286 component_base_kit = "component_base_kit" 287 support_component = "support_component" 288 289 # Device log 290 device_log = "device_log" 291 device_log_on = "ON" 292 device_log_off = "OFF" 293 tag_dir = "dir" 294 tag_enable = "enable" 295 296 env_pool_cache = "env_pool_cache" 297 298 299@dataclass 300class ReportConst(object): 301 session_id = "session_id" 302 command = "command" 303 report_path = "report_path" 304 unsuccessful_params = "unsuccessful_params" 305 data_reports = "data_reports" 306 307 308class FilePermission(object): 309 mode_777 = 0o777 310 mode_755 = 0o755 311 mode_644 = 0o644 312 313 314@dataclass 315class DeviceConnectorType: 316 hdc = "usb-hdc" 317 318 319@dataclass 320class AdvanceDeviceOption(object): 321 """ 322 Advance Device Option 323 """ 324 advance = "advance" 325 type = "type" 326 command = "command" 327 product = "product" 328 version = "version" 329 product_cmd = "product_cmd" 330 version_cmd = "version_cmd" 331 label = "label" 332 333