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