xref: /aosp_15_r20/tools/asuite/atest/atest_enum.py (revision c2e18aaa1096c836b086f94603d04f4eb9cf37f5)
1# Copyright 2018, The Android Open Source Project
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7#     http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14
15"""Atest custom enum class."""
16
17from enum import Enum, IntEnum, unique
18
19
20@unique
21class DetectType(IntEnum):
22  """An Enum class for local_detect_event."""
23
24  # Detect type for local_detect_event; next expansion: 60
25  BUG_DETECTED = 0
26  ACLOUD_CREATE = 1
27  FIND_BUILD = 2
28  NO_FLAKE = 3  # Deprecated.
29  HAS_FLAKE = 4  # Deprecated.
30  TF_TEARDOWN_LOGCAT = 5
31  REBUILD_MODULE_INFO = 6
32  NOT_REBUILD_MODULE_INFO = 7
33  ONLY_BUILD_MODULE_INFO = 8
34  FUZZY_SEARCH_TIME = 9
35  PERMISSION_INCONSISTENT = 10
36  SMART_REBUILD_MODULE_INFO = 11
37  CLEAN_BUILD = 12
38  TESTABLE_MODULES = 13
39  # Tradefed exit codes v.s. exit conditions
40  # 0: NO_ERROR             1: CONFIG_EXCEPTION
41  # 2: NO_BUILD             3: DEVICE_UNRESPONSIVE
42  # 4: DEVICE_UNAVAILABLE   5: FATAL_HOST_ERROR
43  # 6: THROWABLE_EXCEPTION  7: NO_DEVICE_ALLOCATED
44  # 8: WRONG_JAVA_VERSION
45  TF_EXIT_CODE = 14
46  ATEST_CONFIG = 15
47  TEST_WITH_ARGS = 16
48  TEST_NULL_ARGS = 17
49  MODULE_MERGE = 18  # Deprecated. Use MODULE_MERGE_MS instead.
50  MODULE_INFO_INIT_TIME = 19  # Deprecated. Use MODULE_INFO_INIT_MS instead.
51  MODULE_MERGE_MS = 20
52  NATIVE_TEST_NOT_FOUND = 21
53  BAZEL_WORKSPACE_GENERATE_TIME = 22
54  MODULE_LOAD_MS = 23
55  MODULE_INFO_INIT_MS = 24
56  INIT_AND_FIND_MS = 25
57  FOUND_INSTRUMENTATION_TEST = 26
58  FOUND_TARGET_ARTIFACTS = 27
59  FIND_TEST_IN_DEPS = 28
60  FULL_GENERATE_BAZEL_WORKSPACE_TIME = 29
61  # Below detect types are used for determine build conditions:
62  # 1. *_CLEAN_OUT: when out/ dir is empty or does not exist.
63  # 2. *_BPMK_CHANGE: when any Android.bp/Android.mk has changed.
64  # 3. *_ENV_CHANGE: when build-related variable has changed.
65  # 4. *_SRC_CHANGE: when source code has changed.
66  # 5. *_OTHER: none of above reasons that triggers renewal of ninja file.
67  # 6. *_INCREMENTAL: the build doesn't need to renew ninja file.
68  MODULE_INFO_CLEAN_OUT = 30
69  MODULE_INFO_BPMK_CHANGE = 31
70  MODULE_INFO_ENV_CHANGE = 32
71  MODULE_INFO_SRC_CHANGE = 33
72  MODULE_INFO_OTHER = 34
73  MODULE_INFO_INCREMENTAL = 35
74  BUILD_CLEAN_OUT = 36
75  BUILD_BPMK_CHANGE = 37
76  BUILD_ENV_CHANGE = 38
77  BUILD_SRC_CHANGE = 39
78  BUILD_OTHER = 40
79  BUILD_INCREMENTAL = 41
80  BUILD_TIME_PER_TARGET = 42
81  MODULE_INFO_GEN_NINJA = 43
82  BUILD_GEN_NINJA = 44
83  # To indicate if the invocation is using test-mapping, send non-zero value
84  # if the invocation is test-mapping mode.
85  IS_TEST_MAPPING = 45
86  # The RBE_STATE indicates the combined state of the RBE and customized out.
87  RBE_STATE = 46
88  # Prompt the user to select multiple tests.
89  INTERACTIVE_SELECTION = 47
90  # Upload results to storage.
91  # - UPLOAD_FLOW_MS is the total of upload preparation time, includes:
92  # -- FETCH_CRED_MS: fetch credential.
93  # -- UPLOAD_PREPARE_MS: insert a new record to server.
94  UPLOAD_FLOW_MS = 48
95  FETCH_CRED_MS = 49
96  UPLOAD_PREPARE_MS = 50
97  # Time of join the index.
98  IDX_JOIN_MS = 51  # Deprecated. Use INDEX_TARGETS_MS instead.
99  IS_MINIMAL_BUILD = 52
100  # Elapsed time of the Tradefed runner.
101  TF_PREPARATION_MS = 53
102  TF_TEST_MS = 54
103  TF_TEARDOWN_MS = 55
104  TF_TOTAL_RUN_MS = 56
105  ROBOLEAF_NON_MODULE_FINDER = 57  # Deprecated.
106  ROBOLEAF_UNSUPPORTED_FLAG = 58  # Deprecated.
107  INDEX_TARGETS_MS = 59
108  # An int representing the negotiated speed (in Mbits per seconds) the
109  # device is operating at.
110  USB_NEGOTIATED_SPEED = 60
111  # An int representing the maximum speed (in Mbits per seconds) of which the
112  # device is capable.
113  USB_MAX_SPEED = 61
114  # Time spent on waiting indexing to complete.
115  WAIT_FOR_INDEXING_MS = 62
116  # Whether procate db is locked. Value 1 means True, otherwise is False.
117  IS_PLOCATEDB_LOCKED = 63
118  # Device update duration
119  DEVICE_UPDATE_MS = 64
120  # The ID of the feature that is controlled by rollout control. Positive value
121  # means the feature is enabled, negative value means disabled.
122  ROLLOUT_CONTROLLED_FEATURE_ID = 65
123  ROLLOUT_CONTROLLED_FEATURE_ID_OVERRIDE = 66
124
125
126@unique
127class ExitCode(IntEnum):
128  """An Enum class for sys.exit()"""
129
130  SUCCESS = 0
131  ENV_NOT_SETUP = 1
132  BUILD_FAILURE = 2
133  ERROR = 3
134  TEST_NOT_FOUND = 4
135  TEST_FAILURE = 5
136  VERIFY_FAILURE = 6
137  OUTSIDE_ROOT = 7
138  AVD_CREATE_FAILURE = 8
139  AVD_INVALID_ARGS = 9
140  EXIT_BEFORE_MAIN = 10
141  DEVICE_NOT_FOUND = 11
142  MIXED_TYPE_FILTER = 12
143  INPUT_TEST_REFERENCE_ERROR = 13
144  CONFIG_INVALID_FORMAT = 14
145  INVALID_SMART_TESTING_PATH = 15  # deprecated.
146  INVALID_EXEC_MODE = 16
147  INVALID_OBSOLETE_BASELINE_ARGS = 17  # deprecated.
148  INVALID_REGRESSION_ARGS = 18  # deprecated.
149  INVALID_TM_ARGS = 19
150  INVALID_TM_FORMAT = 20
151  INSUFFICIENT_DEVICES = 21
152  # The code > 100 are reserved for collecting data only, actually the run
153  # doesn't finish at the point.
154  COLLECT_ONLY_FILE_NOT_FOUND = 101
155
156
157@unique
158class FilterType(Enum):
159  """An Enum class for filter types"""
160
161  WILDCARD_FILTER = 'wildcard class_method'
162  REGULAR_FILTER = 'regular class_method'
163