Revert "[gdb/testsuite] Clean standard_output_file dir in gdb_init"
[binutils-gdb.git] / gdb / testsuite / make-check-all.sh
blob7d8adb58e878ac65a3c3e8c758e3bf89dde5a1ed
1 #!/bin/bash
3 # Copyright (C) 2023 Free Software Foundation, Inc.
4 # This program is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 3 of the License, or
7 # (at your option) any later version.
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License
15 # along with this program. If not, see <http://www.gnu.org/licenses/>.
17 # Run make check with all boards from gdb/testsuite/boards.
19 # It is recommended to create users on the local system that will act as
20 # "remote host" and "remote target", for the boards that use them.
21 # Pass their usernames to --host-user and --target-user. This helps
22 # because:
24 # - remote host/target boards will use $HOME and leave (potentially
25 # lots of) files behind,
26 # - it enables more strict checking of build/host/target file
27 # manipulations,
28 # - it prevents a command running on one "machine" to kill or send a
29 # signal to a process on another machine.
31 # Recommended usage example:
33 # bash$ cd $objdir/gdb/testsuite
34 # bash$ $srcdir/testsuite/gdb/make-check-all.sh \
35 # --host-user remote-host \
36 # --target-user remote-target \
37 # gdb.base/advance.exp
39 set -e
41 # Boards that run the host tools (compiler, gdb) on a remote host.
42 remote_host_boards=(
43 local-remote-host
44 local-remote-host-notty
47 # Boards that use gdbserver to launch target executables on local target.
48 gdbserver_boards=(
49 native-extended-gdbserver
50 native-gdbserver
51 native-stdio-gdbserver
54 # Boards that use gdbserver to launch target executables on a remote target.
55 remote_gdbserver_boards=(
56 remote-gdbserver-on-localhost
57 remote-stdio-gdbserver
60 # Boards that run compiler, gdb and target executables on a remote machine
61 # that serves both as host and target.
62 host_target_boards=(
63 local-remote-host-native
66 # Boards that run everything on local target and local host.
67 target_boards=(
68 cc-with-gdb-index
69 cc-with-debug-names
70 cc-with-dwz
71 cc-with-dwz-m
72 cc-with-gnu-debuglink
73 debug-types
74 dwarf4-gdb-index
75 dwarf64
76 fission
77 fission-dwp
78 gold
79 gold-gdb-index
80 readnow
81 stabs
84 # Get RUNTESTFLAGS needed for specific boards.
85 rtf_for_board ()
87 local b
88 b="$1"
90 case $b in
91 local-remote-host-native)
92 mkdir -p "$tmpdir/$b"
93 rtf=(
94 "${rtf[@]}"
95 "HOST_DIR=$tmpdir/$b"
98 remote-stdio-gdbserver)
99 rtf=(
100 "${rtf[@]}"
101 "REMOTE_HOSTNAME=localhost"
103 if [ "$target_user" != "" ]; then
104 rtf=(
105 "${rtf[@]}"
106 "REMOTE_USERNAME=$target_user"
108 else
109 rtf=(
110 "${rtf[@]}"
111 "REMOTE_USERNAME=$USER"
115 remote-gdbserver-on-localhost)
116 if [ "$target_user" != "" ]; then
117 rtf=(
118 "${rtf[@]}"
119 "REMOTE_TARGET_USERNAME=$target_user"
123 local-remote-host|local-remote-host-notty)
124 if [ "$host_user" != "" ]; then
125 rtf=(
126 "${rtf[@]}"
127 "REMOTE_HOST_USERNAME=$host_user"
129 else
130 rtf=(
131 "${rtf[@]}"
132 "REMOTE_HOST_USERNAME=$USER"
138 esac
141 # Summarize make check output.
142 summary ()
144 if $verbose; then
146 else
147 # We need the sort -u, because some items, for instance "# of expected
148 # passes" are output twice.
149 grep -E "^(#|FAIL:|ERROR:|WARNING:)" \
150 | sort -u
154 # Run make check, and possibly save test results.
155 do_tests ()
157 if $debug; then
158 echo "RTF: ${rtf[*]}"
161 if $dry_run; then
162 return
165 # Run make check.
166 make check \
167 RUNTESTFLAGS="${rtf[*]} ${tests[*]}" \
168 2>&1 \
169 | summary
171 # Save test results.
172 if $keep_results; then
173 # Set cfg to identifier unique to host/target board combination.
174 if [ "$h" = "" ]; then
175 if [ "$b" = "" ]; then
176 cfg=local
177 else
178 cfg=$b
180 else
181 cfg=$h-$b
184 local dir
185 dir="check-all/$cfg"
187 mkdir -p "$dir"
188 cp gdb.sum gdb.log "$dir"
192 # Set default values for global vars and modify according to command line
193 # arguments.
194 parse_args ()
196 # Default values.
197 debug=false
198 keep_results=false
199 keep_tmp=false
200 verbose=false
201 dry_run=false
203 host_user=""
204 target_user=""
206 # Parse command line arguments.
207 while [ $# -gt 0 ]; do
208 case "$1" in
209 --debug)
210 debug=true
212 --keep-results)
213 keep_results=true
215 --keep-tmp)
216 keep_tmp=true
218 --verbose)
219 verbose=true
221 --dry-run)
222 dry_run=true
224 --host-user)
225 shift
226 host_user="$1"
228 --target-user)
229 shift
230 target_user="$1"
233 break
235 esac
236 shift
237 done
239 tests=("$@")
242 # Cleanup function, scheduled to run on exit.
243 cleanup ()
245 if [ "$tmpdir" != "" ]; then
246 if $keep_tmp; then
247 echo "keeping tmp dir $tmpdir"
248 else
249 rm -Rf "$tmpdir"
254 # Top-level function, called with command line arguments of the script.
255 main ()
257 # Parse command line arguments.
258 parse_args "$@"
260 # Create tmpdir and schedule cleanup.
261 tmpdir=""
262 trap cleanup EXIT
263 tmpdir=$(mktemp -d)
265 if $debug; then
266 echo "TESTS: ${tests[*]}"
269 # Variables that point to current host (h) and target board (b) when
270 # executing do_tests.
271 h=""
272 b=""
274 # For reference, run the tests without any explicit host or target board.
275 echo "LOCAL:"
276 rtf=()
277 do_tests
279 # Run the boards for local host and local target.
280 for b in "${target_boards[@]}"; do
281 echo "TARGET BOARD: $b"
282 rtf=(
283 --target_board="$b"
285 rtf_for_board "$b"
286 do_tests
287 done
289 # Run the boards that use gdbserver, for local host, and for both local and
290 # remote target.
291 for b in "${gdbserver_boards[@]}" "${remote_gdbserver_boards[@]}"; do
292 echo "TARGET BOARD: $b"
293 rtf=(
294 --target_board="$b"
296 rtf_for_board "$b"
297 do_tests
298 done
300 # Run the boards that use remote host, in combination with boards that use
301 # gdbserver on remote target.
302 for h in "${remote_host_boards[@]}"; do
303 for b in "${remote_gdbserver_boards[@]}"; do
304 echo "HOST BOARD: $h, TARGET BOARD: $b"
305 rtf=(
306 --host_board="$h"
307 --target_board="$b"
309 rtf_for_board "$h"
310 rtf_for_board "$b"
311 do_tests
312 done
313 done
314 h=""
316 # Run the boards that function as both remote host and remote target.
317 for b in "${host_target_boards[@]}"; do
318 echo "HOST/TARGET BOARD: $b"
319 rtf=(
320 --host_board="$b"
321 --target_board="$b"
323 rtf_for_board "$b"
324 do_tests
325 done
328 # Call top-level function with command line arguments.
329 main "$@"