• 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", "DeviceProperties", "ReportConst",
28           "LifeStage", "Platform"]
29
30
31@dataclass
32class DeviceOsType(object):
33    """
34    DeviceOsType enumeration
35    """
36    default = "default"
37    lite = "lite"
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    _2in1 = '2in1'
51
52
53@dataclass
54class TestType(object):
55    """
56    TestType enumeration
57    """
58    unittest = "unittest"
59    mst = "moduletest"
60    systemtest = "systemtest"
61    perf = "performance"
62    sec = "security"
63    reli = "reliability"
64    dst = "distributedtest"
65    benchmark = "benchmark"
66    all = "ALL"
67
68
69@dataclass
70class DeviceLabelType(object):
71    """
72    DeviceLabelType enumeration
73    """
74    wifiiot = "wifiiot"
75    ipcamera = "ipcamera"
76    watch_gt = "watchGT"
77    phone = "phone"
78    watch = "watch"
79
80
81TEST_TYPE_DICT = {
82    "UT": TestType.unittest,
83    "MST": TestType.mst,
84    "ST": TestType.systemtest,
85    "PERF": TestType.perf,
86    "SEC": TestType.sec,
87    "RELI": TestType.reli,
88    "DST": TestType.dst,
89    "ALL": TestType.all,
90}
91
92
93@dataclass
94class TestExecType(object):
95    """
96    TestExecType enumeration according to test execution method
97    """
98    # A test running on the device
99    device_test = "device"
100    # A test running on the host (pc)
101    host_test = "host"
102    # A test running on the host that interacts with one or more devices.
103    host_driven_test = "hostdriven"
104
105
106@dataclass
107class DeviceTestType(object):
108    """
109    DeviceTestType enumeration
110    """
111    cpp_test = "CppTest"
112    dex_test = "DexTest"
113    dex_junit_test = "DexJUnitTest"
114    hap_test = "HapTest"
115    junit_test = "JUnitTest"
116    jsunit_test = "JSUnitTest"
117    jsunit_test_lite = "JSUnitTestLite"
118    ctest_lite = "CTestLite"
119    cpp_test_lite = "CppTestLite"
120    lite_cpp_test = "LiteUnitTest"
121    open_source_test = "OpenSourceTest"
122    build_only_test = "BuildOnlyTestLite"
123    ltp_posix_test = "LtpPosixTest"
124    oh_kernel_test = "OHKernelTest"
125    oh_jsunit_test = "OHJSUnitTest"
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    module_config = "module_config"
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    common_module_kits = "common_module_kits"
284    spt = "spt"
285    version = "version"
286    component_mapper = "_component_mapper"
287    component_base_kit = "component_base_kit"
288    support_component = "support_component"
289
290    # Device log
291    device_log = "device_log"
292    device_log_on = "ON"
293    device_log_off = "OFF"
294    tag_dir = "dir"
295    tag_enable = "enable"
296    tag_loglevel = "loglevel"
297    tag_clear = "clear"
298    env_pool_cache = "env_pool_cache"
299
300    web_resource = "web_resource"
301    enable_web_resource = "enable_web_resource"
302
303    tag_url = "url"
304
305
306@dataclass
307class ReportConst(object):
308    session_id = "session_id"
309    command = "command"
310    report_path = "report_path"
311    unsuccessful_params = "unsuccessful_params"
312    data_reports = "data_reports"
313
314
315class FilePermission(object):
316    mode_777 = 0o777
317    mode_755 = 0o755
318    mode_644 = 0o644
319
320
321@dataclass
322class DeviceConnectorType:
323    hdc = "usb-hdc"
324
325
326@dataclass
327class DeviceProperties(object):
328    sn = "sn"
329    model = "model"
330    type_ = "type"
331    platform = "platform"
332    version = "version"
333    others = "others"
334
335
336@dataclass
337class AdvanceDeviceOption(object):
338    """
339    Advance Device Option
340    """
341    advance = "advance"
342    type = "type"
343    command = "command"
344    product = "product"
345    version = "version"
346    product_cmd = "product_cmd"
347    version_cmd = "version_cmd"
348    label = "label"
349
350
351@dataclass
352class Platform(object):
353    """
354    Platform enumeration
355    """
356    ohos = "OpenHarmony"
357
358
359@dataclass
360class LifeStage(object):
361    """
362    LifeStage enumeration
363    """
364    task_start = "TaskStart"
365    task_end = "TaskEnd"
366    case_start = "CaseStart"
367    case_end = "CaseEnd"
368
369