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