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 19import platform 20from dataclasses import dataclass 21 22__all__ = ["DeviceOsType", "ProductForm", "TestType", "TestExecType", 23 "DeviceTestType", "HostTestType", "HostDrivenTestType", 24 "SchedulerType", "ListenerType", "ToolCommandType", 25 "TEST_DRIVER_SET", "LogMode", "LogType", "CKit", 26 "DeviceLabelType", "GTestConst", "ManagerType", 27 "ModeType", "ConfigConst", "FilePermission", "CommonParserType", 28 "DeviceConnectorType", "ReportConst", "DeviceProperties", "AdvanceDeviceOption", 29 "LoggerMethod", "LifeStage", "Platform", "HcpTestMode", "DeviceResult", 30 "AgentMode", "CaseResult", "Cluster", "State"] 31 32 33@dataclass 34class DeviceOsType(object): 35 """ 36 DeviceOsType enumeration 37 """ 38 default = "default" 39 lite = "lite" 40 41 42@dataclass 43class ProductForm(object): 44 """ 45 ProductForm enumeration 46 """ 47 phone = "phone" 48 car = "car" 49 television = "tv" 50 watch = "watch" 51 tablet = 'tablet' 52 wearable = 'wearable' 53 _2in1 = '2in1' 54 55 56@dataclass 57class TestType(object): 58 """ 59 TestType enumeration 60 """ 61 unittest = "unittest" 62 mst = "moduletest" 63 systemtest = "systemtest" 64 perf = "performance" 65 sec = "security" 66 reli = "reliability" 67 dst = "distributedtest" 68 benchmark = "benchmark" 69 all = "ALL" 70 71 72@dataclass 73class DeviceLabelType(object): 74 """ 75 DeviceLabelType enumeration 76 """ 77 wifiiot = "wifiiot" 78 ipcamera = "ipcamera" 79 watch_gt = "watchGT" 80 phone = "phone" 81 watch = "watch" 82 83 84TEST_TYPE_DICT = { 85 "UT": TestType.unittest, 86 "MST": TestType.mst, 87 "ST": TestType.systemtest, 88 "PERF": TestType.perf, 89 "SEC": TestType.sec, 90 "RELI": TestType.reli, 91 "DST": TestType.dst, 92 "ALL": TestType.all, 93} 94 95 96@dataclass 97class TestExecType(object): 98 """ 99 TestExecType enumeration according to test execution method 100 """ 101 # A test running on the device 102 device_test = "device" 103 # A test running on the host (pc) 104 host_test = "host" 105 # A test running on the host that interacts with one or more devices. 106 host_driven_test = "hostdriven" 107 108 109@dataclass 110class DeviceTestType(object): 111 """ 112 DeviceTestType enumeration 113 """ 114 cpp_test = "CppTest" 115 dex_test = "DexTest" 116 dex_junit_test = "DexJUnitTest" 117 hap_test = "HapTest" 118 junit_test = "JUnitTest" 119 jsunit_test = "JSUnitTest" 120 jsunit_test_lite = "JSUnitTestLite" 121 ctest_lite = "CTestLite" 122 cpp_test_lite = "CppTestLite" 123 lite_cpp_test = "LiteUnitTest" 124 open_source_test = "OpenSourceTest" 125 build_only_test = "BuildOnlyTestLite" 126 ltp_posix_test = "LtpPosixTest" 127 oh_kernel_test = "OHKernelTest" 128 oh_jsunit_test = "OHJSUnitTest" 129 hm_os_jsunit_test = "HMOSJSUnitTest" 130 hcp_test_lite = "HcpTestLite" 131 oh_rust_test = "OHRustTest" 132 oh_yara_test = "OHYaraTest" 133 hcp_test = "HcpTest" 134 ValidatorTest = "ValidatorTest" 135 arkuix_jsunit_test = "ARKUIXJSUnitTest" 136 oh_jslocal_test = "OHJSLocalTestDriver" 137 stability_test = "StabilityTest" 138 ux_test = "UXTest" 139 ark_web_test = "ArkWebTest" 140 141 142@dataclass 143class HostTestType(object): 144 """ 145 HostTestType enumeration 146 """ 147 host_gtest = "HostGTest" 148 host_junit_test = "HostJUnitTest" 149 150 151@dataclass 152class HostDrivenTestType(object): 153 """ 154 HostDrivenType enumeration 155 """ 156 device_test = "DeviceTest" 157 device_testsuite = "DeviceTestSuite" 158 windows_test = "WindowsTest" 159 app_test = "AppTest" 160 161 162TEST_DRIVER_SET = { 163 DeviceTestType.cpp_test, 164 DeviceTestType.dex_test, 165 DeviceTestType.hap_test, 166 DeviceTestType.junit_test, 167 DeviceTestType.dex_junit_test, 168 DeviceTestType.jsunit_test, 169 DeviceTestType.jsunit_test_lite, 170 DeviceTestType.cpp_test_lite, 171 DeviceTestType.ctest_lite, 172 DeviceTestType.lite_cpp_test, 173 DeviceTestType.ltp_posix_test, 174 DeviceTestType.oh_kernel_test, 175 DeviceTestType.oh_jsunit_test, 176 HostDrivenTestType.device_test, 177 DeviceTestType.ux_test, 178 DeviceTestType.stability_test 179} 180 181 182@dataclass 183class SchedulerType(object): 184 """ 185 SchedulerType enumeration 186 """ 187 # default scheduler 188 scheduler = "Scheduler" 189 # module 190 module = "module" 191 # synchronize 192 synchronize = "synchronize" 193 194 195@dataclass 196class LogMode: 197 name = "log_mode" 198 default = "default" 199 no_console = "no_console" 200 201 202@dataclass 203class LogType: 204 tool = "Tool" 205 device = "Device" 206 207 208@dataclass 209class ListenerType: 210 log = "Log" 211 report = "Report" 212 stack_report = "StackReport" 213 upload = "Upload" 214 collect = "Collect" 215 collect_lite = "CollectLite" 216 collect_pass = "CollectPass" 217 218 219@dataclass 220class CommonParserType: 221 jsunit = "JSUnit" 222 cpptest = "CppTest" 223 cpptest_list = "CppTestList" 224 junit = "JUnit" 225 oh_kernel_test = "OHKernel" 226 oh_jsunit = "OHJSUnit" 227 oh_jsunit_list = "OHJSUnitList" 228 oh_rust = "OHRust" 229 oh_yara = "OHYara" 230 worker = "Worker" 231 232 233@dataclass 234class ManagerType: 235 device = "device" 236 lite_device = "device_lite" 237 238 239@dataclass 240class ToolCommandType(object): 241 toolcmd_key_help = "help" 242 toolcmd_key_show = "show" 243 toolcmd_key_run = "run" 244 toolcmd_key_quit = "quit" 245 toolcmd_key_list = "list" 246 toolcmd_key_tool = "tool" 247 248 249@dataclass 250class CKit: 251 query = "QueryKit" 252 component = "ComponentKit" 253 254 255@dataclass 256class GTestConst(object): 257 exec_para_filter = "--gtest_filter" 258 exec_para_level = "--gtest_testsize" 259 260 261@dataclass 262class ModeType(object): 263 decc = "decc" 264 factory = "factory" 265 developer = "developer" 266 controller = "controller" 267 268 269@dataclass 270class ConfigConst(object): 271 action = "action" 272 task = "task" 273 testlist = "testlist" 274 testfile = "testfile" 275 testcase = "testcase" 276 testdict = "testdict" 277 device_sn = "device_sn" 278 report_path = "report_path" 279 resource_path = "resource_path" 280 testcases_path = "testcases_path" 281 testargs = "testargs" 282 pass_through = "pass_through" 283 test_environment = "test_environment" 284 exectype = "exectype" 285 testtype = "testtype" 286 testdriver = "testdriver" 287 retry = "retry" 288 session = "session" 289 dry_run = "dry_run" 290 reboot_per_module = "reboot_per_module" 291 check_device = "check_device" 292 configfile = "config" 293 repeat = "repeat" 294 subsystems = "subsystems" 295 parts = "parts" 296 export_report = "export_report" 297 renew_report = "renew_report" 298 device_info = "device_info" 299 kits_in_module = "kits_in_module" 300 kits_params = "kits_params" 301 auto_retry = "auto_retry" 302 enable_unicode = "enable_unicode" 303 module_config = "module_config" 304 scheduler = "scheduler" 305 common_kits = "common_kits" 306 307 # Runtime Constant 308 history_report_path = "history_report_path" 309 product_info = "product_info" 310 task_state = "task_state" 311 recover_state = "recover_state" 312 need_kit_setup = "need_kit_setup" 313 task_kits = "task_kits" 314 module_kits = "module_kits" 315 common_module_kits = "common_module_kits" 316 spt = "spt" 317 version = "version" 318 component_mapper = "_component_mapper" 319 component_base_kit = "component_base_kit" 320 support_component = "support_component" 321 322 # Device log 323 device_log = "device_log" 324 device_log_on = "ON" 325 device_log_off = "OFF" 326 app_test = "app_test" 327 tag_dir = "dir" 328 tag_enable = "enable" 329 tag_clear = "clear" 330 tag_loglevel = "loglevel" 331 tag_hdc = "hdc" 332 333 # Ignore testcase path 334 ignore_testcases_path = "__pycache__|.git|.svn|.idea|.test" 335 336 screenshot_on_failure = "screenshot_on_failure" 337 report_plus = "report_plus" 338 silence_install = "silence_install" 339 env_pool_cache = "env_pool_cache" 340 341 web_resource = "web_resource" 342 enable_web_resource = "enable_web_resource" 343 344 tag_url = "url" 345 346 # if upload track data 347 tag_uploadtrack = "uploadtrack" 348 349 # cluster 350 cluster = "cluster" 351 service_mode = "service_mode" 352 service_port = "service_port" 353 control_service_url = "control_service_url" 354 355 356@dataclass 357class ReportConst(object): 358 session_id = "session_id" 359 command = "command" 360 report_path = "report_path" 361 unsuccessful_params = "unsuccessful_params" 362 data_reports = "data_reports" 363 364 365class FilePermission(object): 366 mode_777 = 0o777 367 mode_755 = 0o755 368 mode_644 = 0o644 369 370 371@dataclass 372class DeviceConnectorType: 373 hdc = "usb-hdc" 374 375 376@dataclass 377class DeviceResult(object): 378 """ 379 DeviceResult enumeration 380 """ 381 code = "code" 382 date = "date" 383 msg = "msg" 384 result = "result" 385 data = 'data' 386 387 388@dataclass 389class DeviceProperties(object): 390 """ 391 DeviceProperties enumeration 392 """ 393 system_sdk = "system_sdk" 394 system_version = "system_version" 395 build_number = "buildNumber" 396 cpu_abi = "cpuAbi" 397 device_form = "deviceForm" 398 software_version = "software_version" 399 fault_code = "faultCode" 400 fold_screen = "foldScreen" 401 hardware = "hardware" 402 is_ark = "isArk" 403 mac = "mac" 404 mobile_service = "mobileService" 405 model = "model" 406 rom = "rom" 407 rooted = "rooted" 408 sn = "sn" 409 xres = "xres" 410 yres = "yres" 411 manufacturer = "manufacturer" 412 kind = "kind" 413 platform = "platform" 414 type_ = "type" 415 version = "version" 416 others = "others" 417 alias = "alias" 418 419 420@dataclass 421class LoggerMethod: 422 """ 423 method name in logger 424 """ 425 426 info = "info" 427 debug = "debug" 428 error = "error" 429 warning = "warning" 430 exception = "exception" 431 432 433@dataclass 434class AdvanceDeviceOption(object): 435 """ 436 method name in logger 437 """ 438 advance = "advance" 439 type = "type" 440 command = "command" 441 product = "product" 442 version = "version" 443 product_cmd = "product_cmd" 444 version_cmd = "version_cmd" 445 label = "label" 446 447 448@dataclass 449class Platform(object): 450 """ 451 Platform enumeration 452 """ 453 ohos = "OpenHarmony" 454 455 456@dataclass 457class HcpTestMode(object): 458 """ 459 HcpTestMode enumeration 460 """ 461 hcp_mode = False 462 463 464@dataclass 465class LifeStage(object): 466 """ 467 LifeStage enumeration 468 """ 469 task_start = "TaskStart" 470 task_end = "TaskEnd" 471 case_start = "CaseStart" 472 case_end = "CaseEnd" 473 474 475@dataclass 476class AgentMode(object): 477 """ 478 Agent mode 479 """ 480 hap = "hap" 481 abc = "abc" 482 bin = "bin" 483 484 485@dataclass 486class CaseResult: 487 passed = "Passed" 488 failed = "Failed" 489 blocked = "Blocked" 490 ignored = "Ignored" 491 unavailable = "Unavailable" 492 493 494class Cluster: 495 if platform.system() == "Windows": 496 local_path = "D:\\Local" 497 project_root_path = "D:\\Local\\Projects" 498 report_root_path = "D:\\Local\\Reports" 499 else: 500 local_path = "/data/Local" 501 project_root_path = "/data/Local/Projects" 502 report_root_path = "/data/Local/Reports" 503 service_port = "8000" 504 stars = "***" 505 controller = "controller" 506 worker = "worker" 507 worker_logs = "worker_logs" 508 509 510class State: 511 Waiting = "Waiting" 512 Running = "Running" 513 Completed = "Completed" 514 Stopped = "Stopped" 515 Stopping = "Stopping" 516