• 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", "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
38
39@dataclass
40class ProductForm(object):
41    """
42    ProductForm enumeration
43    """
44    phone = "phone"
45    car = "car"
46    television = "tv"
47    watch = "watch"
48    tablet = 'tablet'
49    _2in1 = '2in1'
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
212
213@dataclass
214class ToolCommandType(object):
215    toolcmd_key_help = "help"
216    toolcmd_key_show = "show"
217    toolcmd_key_run = "run"
218    toolcmd_key_quit = "quit"
219    toolcmd_key_list = "list"
220    toolcmd_key_tool = "tool"
221
222
223@dataclass
224class CKit:
225    query = "QueryKit"
226    component = "ComponentKit"
227
228
229@dataclass
230class GTestConst(object):
231    exec_para_filter = "--gtest_filter"
232    exec_para_level = "--gtest_testsize"
233
234
235@dataclass
236class ModeType(object):
237    decc = "decc"
238    factory = "factory"
239    developer = "developer"
240
241
242@dataclass
243class ConfigConst(object):
244    action = "action"
245    task = "task"
246    testlist = "testlist"
247    testfile = "testfile"
248    testcase = "testcase"
249    testdict = "testdict"
250    device_sn = "device_sn"
251    report_path = "report_path"
252    resource_path = "resource_path"
253    testcases_path = "testcases_path"
254    testargs = "testargs"
255    pass_through = "pass_through"
256    test_environment = "test_environment"
257    exectype = "exectype"
258    testtype = "testtype"
259    testdriver = "testdriver"
260    retry = "retry"
261    session = "session"
262    dry_run = "dry_run"
263    reboot_per_module = "reboot_per_module"
264    check_device = "check_device"
265    configfile = "config"
266    repeat = "repeat"
267    subsystems = "subsystems"
268    parts = "parts"
269    renew_report = "renew_report"
270    kits_in_module = "kits_in_module"
271    kits_params = "kits_params"
272    auto_retry = "auto_retry"
273
274    # Runtime Constant
275    history_report_path = "history_report_path"
276    product_info = "product_info"
277    task_state = "task_state"
278    recover_state = "recover_state"
279    need_kit_setup = "need_kit_setup"
280    task_kits = "task_kits"
281    module_kits = "module_kits"
282    spt = "spt"
283    version = "version"
284    component_mapper = "_component_mapper"
285    component_base_kit = "component_base_kit"
286    support_component = "support_component"
287
288    # Device log
289    device_log = "device_log"
290    device_log_on = "ON"
291    device_log_off = "OFF"
292    tag_dir = "dir"
293    tag_enable = "enable"
294    tag_loglevel = "loglevel"
295    tag_clear = "clear"
296    query_resource = "query_resource"
297    env_pool_cache = "env_pool_cache"
298
299
300@dataclass
301class ReportConst(object):
302    session_id = "session_id"
303    command = "command"
304    report_path = "report_path"
305    unsuccessful_params = "unsuccessful_params"
306    data_reports = "data_reports"
307
308
309class FilePermission(object):
310    mode_777 = 0o777
311    mode_755 = 0o755
312    mode_644 = 0o644
313
314
315@dataclass
316class DeviceConnectorType:
317    hdc = "usb-hdc"
318
319
320@dataclass
321class AdvanceDeviceOption(object):
322    """
323    Advance Device Option
324    """
325    advance = "advance"
326    type = "type"
327    command = "command"
328    product = "product"
329    version = "version"
330    product_cmd = "product_cmd"
331    version_cmd = "version_cmd"
332    label = "label"
333
334
335@dataclass
336class Platform(object):
337    """
338    Platform enumeration
339    """
340    ohos = "OpenHarmony"
341
342
343@dataclass
344class LifeStage(object):
345    """
346    LifeStage enumeration
347    """
348    task_start = "TaskStart"
349    task_end = "TaskEnd"
350    case_start = "CaseStart"
351    case_end = "CaseEnd"
352
353