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"] 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 127 128@dataclass 129class HostTestType(object): 130 """ 131 HostTestType enumeration 132 """ 133 host_gtest = "HostGTest" 134 host_junit_test = "HostJUnitTest" 135 136 137@dataclass 138class HostDrivenTestType(object): 139 """ 140 HostDrivenType enumeration 141 """ 142 device_test = "DeviceTest" 143 windows_test = "WindowsTest" 144 app_test = "AppTest" 145 146 147TEST_DRIVER_SET = { 148 DeviceTestType.cpp_test, 149 DeviceTestType.dex_test, 150 DeviceTestType.hap_test, 151 DeviceTestType.junit_test, 152 DeviceTestType.dex_junit_test, 153 DeviceTestType.jsunit_test, 154 DeviceTestType.jsunit_test_lite, 155 DeviceTestType.cpp_test_lite, 156 DeviceTestType.ctest_lite, 157 DeviceTestType.lite_cpp_test, 158 DeviceTestType.ltp_posix_test, 159 DeviceTestType.oh_kernel_test, 160 DeviceTestType.oh_jsunit_test, 161 HostDrivenTestType.device_test 162} 163 164 165@dataclass 166class SchedulerType(object): 167 """ 168 SchedulerType enumeration 169 """ 170 # default scheduler 171 scheduler = "Scheduler" 172 173 174@dataclass 175class LogType: 176 tool = "Tool" 177 device = "Device" 178 179 180@dataclass 181class ListenerType: 182 log = "Log" 183 report = "Report" 184 upload = "Upload" 185 collect = "Collect" 186 collect_lite = "CollectLite" 187 collect_pass = "CollectPass" 188 189 190@dataclass 191class CommonParserType: 192 jsunit = "JSUnit" 193 cpptest = "CppTest" 194 cpptest_list = "CppTestList" 195 junit = "JUnit" 196 oh_kernel_test = "OHKernel" 197 oh_jsunit = "OHJSUnit" 198 oh_jsunit_list = "OHJSUnitList" 199 200 201@dataclass 202class ManagerType: 203 device = "device" 204 lite_device = "device_lite" 205 aosp_device = "device_aosp" 206 207 208@dataclass 209class ToolCommandType(object): 210 toolcmd_key_help = "help" 211 toolcmd_key_show = "show" 212 toolcmd_key_run = "run" 213 toolcmd_key_quit = "quit" 214 toolcmd_key_list = "list" 215 toolcmd_key_tool = "tool" 216 217 218@dataclass 219class CKit: 220 query = "QueryKit" 221 component = "ComponentKit" 222 223 224@dataclass 225class GTestConst(object): 226 exec_para_filter = "--gtest_filter" 227 exec_para_level = "--gtest_testsize" 228 229 230@dataclass 231class ModeType(object): 232 decc = "decc" 233 factory = "factory" 234 developer = "developer" 235 236 237@dataclass 238class ConfigConst(object): 239 action = "action" 240 task = "task" 241 testlist = "testlist" 242 testfile = "testfile" 243 testcase = "testcase" 244 testdict = "testdict" 245 device_sn = "device_sn" 246 report_path = "report_path" 247 resource_path = "resource_path" 248 testcases_path = "testcases_path" 249 testargs = "testargs" 250 pass_through = "pass_through" 251 test_environment = "test_environment" 252 exectype = "exectype" 253 testtype = "testtype" 254 testdriver = "testdriver" 255 retry = "retry" 256 session = "session" 257 dry_run = "dry_run" 258 reboot_per_module = "reboot_per_module" 259 check_device = "check_device" 260 configfile = "config" 261 repeat = "repeat" 262 subsystems = "subsystems" 263 parts = "parts" 264 renew_report = "renew_report" 265 266 # Runtime Constant 267 history_report_path = "history_report_path" 268 product_info = "product_info" 269 task_state = "task_state" 270 recover_state = "recover_state" 271 need_kit_setup = "need_kit_setup" 272 task_kits = "task_kits" 273 module_kits = "module_kits" 274 spt = "spt" 275 version = "version" 276 component_mapper = "_component_mapper" 277 component_base_kit = "component_base_kit" 278 support_component = "support_component" 279 280 # Device log 281 device_log = "device_log" 282 device_log_on = "ON" 283 device_log_off = "OFF" 284 285 env_pool_cache = "env_pool_cache" 286 287 288@dataclass 289class ReportConst(object): 290 session_id = "session_id" 291 command = "command" 292 report_path = "report_path" 293 unsuccessful_params = "unsuccessful_params" 294 data_reports = "data_reports" 295 296 297class FilePermission(object): 298 mode_777 = 0o777 299 mode_755 = 0o755 300 mode_644 = 0o644 301 302 303@dataclass 304class DeviceConnectorType: 305 hdc = "usb-hdc" 306 307