1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
|
#!/bin/bash
#
# Copyright (c) 2019, Linaro Ltd.
# All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Run the ART tests on the VIXL Simulator
readonly local_path=$(dirname "$0")
source "${local_path}/../utils/utils.sh"
source "${local_path}/../utils/utils_test.sh"
source "${local_path}/../utils/utils_android.sh"
source "${local_path}/../utils/utils_android_root.sh"
source "${local_path}/../utils/utils_run.sh"
readonly timer_name="Simulator Test"
readonly lunch_target="armv8"
readonly sim_patch_change_id="I3be88806135f6e4110650ec3233fedc6cf4a7a1e"
readonly sim_patch_change_number="5071"
readonly -a sve_patch_change_ids=(
"I346423f7a5ab11be1e9ec3178a9e1e5f69f114ad" # SIMD checker tests
"I47f018d228f46607e68ea7273ed983c7577cb784" # SVE in VIXL
"If757e7a6c7f6fe0e907a5ed2faf0b0b538132ab0" # enable SVE
)
readonly -a sve_patch_change_numbers=(
"4303" # SIMD checker tests
"5203" # SVE in VIXL
"5204" # enable SVE
)
if [[ "${!sve_patch_change_ids[@]}" != "${!sve_patch_change_numbers[@]}" ]]; then
log E "The number of patches does not match in sve_patch_change_ids and sve_patch_change_numbers"
abort
fi
usage() {
log I "$0"
log I "This script is used to run the ART simulator test on host."
log I " -h|--help Show this help."
log I " -t|--build-target Build arm64 target images, e.g. core.art"
log I " -s|--sve Enable SVE2 Arm extension"
log I "-------------------------------------------"
log I "Test Options:"
log I " --jobs - a number of jobs on a target. Defaults to CPU count."
log I " --keep-failures - keep failing tests around (useful for debugging)."
log I " --keep-going - don't stop at the first failing test."
log I " --gcstress - use gc stress testing for run-tests."
log I " --isa-features - specify isa features to be used.
Possible values: default, runtime, a list of comma-separated
feature names. When the list is used, '-' before a feature name
means the ART compiler must not use the feature for code
generation."
log I " --dump-cfg <path> - dump .cfg to the specified host full path. Only runs for a"
log I " single test"
log I " --gdb - Run dalvikvm under gdb. Only runs for a single test."
log I " --gdb-dex2oat - Run dex2oat under lldb. Only runs for a single test."
log I " --gdb-dex2oat-args - Use LLDB with arguments to debug the compiler (dex2oat)
Each argument needs to be separated by a semicolon."
log I "-------------------------------------------"
log I "Tests:"
log I " --single-test <test> - run specified test only"
exit 0
}
# shellcheck disable=SC2034
declare -A options_format=(
["help"]="p:usage()"
["h"]="r:&help"
["build-target"]="false"
["t"]="r:&build-target"
["sve"]="false"
["s"]="r:&sve"
["dump-cfg"]=""
["gdb"]="false"
["gdb-dex2oat"]="false"
["gdb-dex2oat-args"]=""
["gcstress"]="false"
["isa-features"]=""
["jobs"]=""
["keep-failures"]="false"
["keep-going"]="false"
["single-test"]=""
)
declare -A options=()
validate_options() {
if [[ -n "${options["jobs"]}" ]] && [[ ! ${options["jobs"]} =~ ^[0-9]+$ ]]; then
log E "The --jobs option must be followed by an integer."
exit 1
fi
if [[ -n "${options["dump-cfg"]}" ]] && [[ -z "${options["single-test"]}" ]]; then
log E "Can only dump .cfg for a single test."
exit 1
fi
if [[ "${options["gdb"]}" == "true" || "${options["gdb-dex2oat"]}" == "true" ]]; then
if [[ -z "${options["single-test"]}" ]]; then
log E "Can only run the debugger for a single test."
exit 1
fi
local -r test_name="${options["single-test"]}"
if is_single_test_gtest "${test_name}"; then
log E "Can't run the debugger for a gtest."
exit 1
fi
fi
}
prepare_workspace() {
local -ar patch_change_ids=(
"${sim_patch_change_id}"
$([[ "${options[sve]}" == "true" ]] && echo "${sve_patch_change_ids[@]}")
)
local -ar patch_change_numbers=(
"${sim_patch_change_number}"
$([[ "${options[sve]}" == "true" ]] && echo "${sve_patch_change_numbers[@]}")
)
local any_patch_downloaded="false"
local idx
for idx in "${!patch_change_ids[@]}"; do
local patch_hash=$(git --no-pager -C art log --format=format:%H -1 \
--grep "Change-Id: ${patch_change_ids[idx]}")
if [[ "${patch_hash}" == "" ]]; then
log I "WARNING: Cherry picking the required patch, this will appear on your branch history"
log I "Use repo sync --local-only --detach art to remove it, uncommitted changes will be
kept in the working directory but local commits will be unlinked"
safe repo download --cherry-pick "art" "${patch_change_numbers[idx]}"
any_patch_downloaded="true"
fi
done
if ${options["keep-failures"]}; then
set_environment_keep_test_failures
fi
# According to art/test/README.chroot.md, the test script needs to set this
# env variable when building ART minimal tree.
export SOONG_ALLOW_MISSING_DEPENDENCIES=true
source_android_environment_default
# If downloading the patch then we need to rebuild the target
# regardless of if the build_target option is given
if [[ "${options[build-target]}" == "true" ]] ||
[[ "${any_patch_downloaded}" == "true" ]]; then
log I "Building target"
select_android_target "arm" "${lunch_target}"
build_target "64"
fi
setup_android_target "${lunch_target}"
set_environment_host
build_host
}
test_simulator() {
if [[ -n ${options["single-test"]} ]]; then
test_single "64" "simulator" "${job_count}" "$(declare -p options)"
else
section_starter "simulator" "host"
run_test_unwrapped "run-test" "optimizing" "" "64" "simulator" "${job_count}" \
"$(declare -p options)"
local -r return_code=$?
section_ender "simulator" "host" "${return_code}" "${options["keep-going"]}"
fi
}
set_job_count() {
job_count=${JCPU_COUNT}
if [[ -n "${options["jobs"]}" ]]; then
job_count="${options["jobs"]}"
fi
}
main() {
exit_on_failure arguments_parser options_format options -- "$@"
readonly options
validate_options
dump_options
set_job_count
start_test "${timer_name}"
prepare_workspace
test_simulator
end_test "${timer_name}"
}
main "$@"
|