Fix null pointer dereference in process_debug_info()
[binutils-gdb.git] / gdb / testsuite / make-check-all.sh
blob33a50d708c6d703b75b3aabaf0951594be6c4a97
1 #!/bin/bash
3 # Copyright (C) 2023-2024 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-index-cache
70 cc-with-debug-names
71 cc-with-dwz
72 cc-with-dwz-m
73 cc-with-gnu-debuglink
74 debug-types
75 dwarf4-gdb-index
76 dwarf64
77 fission
78 fission-dwp
79 gold
80 gold-gdb-index
81 readnow
82 stabs
85 # Get RUNTESTFLAGS needed for specific boards.
86 rtf_for_board ()
88 local b
89 b="$1"
91 case $b in
92 local-remote-host-native)
93 mkdir -p "$tmpdir/$b"
94 rtf=(
95 "${rtf[@]}"
96 "HOST_DIR=$tmpdir/$b"
99 remote-stdio-gdbserver)
100 rtf=(
101 "${rtf[@]}"
102 "REMOTE_HOSTNAME=localhost"
104 if [ "$target_user" != "" ]; then
105 rtf=(
106 "${rtf[@]}"
107 "REMOTE_USERNAME=$target_user"
109 else
110 rtf=(
111 "${rtf[@]}"
112 "REMOTE_USERNAME=$USER"
116 remote-gdbserver-on-localhost)
117 if [ "$target_user" != "" ]; then
118 rtf=(
119 "${rtf[@]}"
120 "REMOTE_TARGET_USERNAME=$target_user"
124 local-remote-host|local-remote-host-notty)
125 if [ "$host_user" != "" ]; then
126 rtf=(
127 "${rtf[@]}"
128 "REMOTE_HOST_USERNAME=$host_user"
130 else
131 rtf=(
132 "${rtf[@]}"
133 "REMOTE_HOST_USERNAME=$USER"
139 esac
142 # Summarize make check output.
143 summary ()
145 if $verbose; then
147 else
148 # We need the sort -u, because some items, for instance "# of expected
149 # passes" are output twice.
150 grep -E "^(#|FAIL:|ERROR:|WARNING:)" \
151 | sort -u
155 # Run make check, and possibly save test results.
156 do_tests ()
158 if $debug; then
159 echo "RTF: ${rtf[*]}"
162 if $dry_run; then
163 return
166 # Run make check.
167 make check \
168 RUNTESTFLAGS="${rtf[*]} ${tests[*]}" \
169 2>&1 \
170 | summary
172 # Save test results.
173 if $keep_results; then
174 # Set cfg to identifier unique to host/target board combination.
175 if [ "$h" = "" ]; then
176 if [ "$b" = "" ]; then
177 cfg=local
178 else
179 cfg=$b
181 else
182 cfg=$h-$b
185 local dir
186 dir="check-all/$cfg"
188 mkdir -p "$dir"
189 cp gdb.sum gdb.log "$dir"
191 # Record the 'make check' command to enable easy re-running.
192 echo "make check RUNTESTFLAGS=\"${rtf[*]} ${tests[*]}\"" \
193 > "$dir/make-check.sh"
197 # Set default values for global vars and modify according to command line
198 # arguments.
199 parse_args ()
201 # Default values.
202 debug=false
203 keep_results=false
204 keep_tmp=false
205 verbose=false
206 dry_run=false
208 host_user=""
209 target_user=""
211 # Parse command line arguments.
212 while [ $# -gt 0 ]; do
213 case "$1" in
214 --debug)
215 debug=true
217 --keep-results)
218 keep_results=true
220 --keep-tmp)
221 keep_tmp=true
223 --verbose)
224 verbose=true
226 --dry-run)
227 dry_run=true
229 --host-user)
230 shift
231 host_user="$1"
233 --target-user)
234 shift
235 target_user="$1"
238 break
240 esac
241 shift
242 done
244 tests=("$@")
247 # Cleanup function, scheduled to run on exit.
248 cleanup ()
250 if [ "$tmpdir" != "" ]; then
251 if $keep_tmp; then
252 echo "keeping tmp dir $tmpdir"
253 else
254 rm -Rf "$tmpdir"
259 # Top-level function, called with command line arguments of the script.
260 main ()
262 # Parse command line arguments.
263 parse_args "$@"
265 # Create tmpdir and schedule cleanup.
266 tmpdir=""
267 trap cleanup EXIT
268 tmpdir=$(mktemp -d)
270 if $debug; then
271 echo "TESTS: ${tests[*]}"
274 # Variables that point to current host (h) and target board (b) when
275 # executing do_tests.
276 h=""
277 b=""
279 # For reference, run the tests without any explicit host or target board.
280 echo "LOCAL:"
281 rtf=()
282 do_tests
284 # Run the boards for local host and local target.
285 for b in "${target_boards[@]}"; do
286 echo "TARGET BOARD: $b"
287 rtf=(
288 --target_board="$b"
290 rtf_for_board "$b"
291 do_tests
292 done
294 # Run the boards that use gdbserver, for local host, and for both local and
295 # remote target.
296 for b in "${gdbserver_boards[@]}" "${remote_gdbserver_boards[@]}"; do
297 echo "TARGET BOARD: $b"
298 rtf=(
299 --target_board="$b"
301 rtf_for_board "$b"
302 do_tests
303 done
305 # Run the boards that use remote host, in combination with boards that use
306 # gdbserver on remote target.
307 for h in "${remote_host_boards[@]}"; do
308 for b in "${remote_gdbserver_boards[@]}"; do
309 echo "HOST BOARD: $h, TARGET BOARD: $b"
310 rtf=(
311 --host_board="$h"
312 --target_board="$b"
314 rtf_for_board "$h"
315 rtf_for_board "$b"
316 do_tests
317 done
318 done
319 h=""
321 # Run the boards that function as both remote host and remote target.
322 for b in "${host_target_boards[@]}"; do
323 echo "HOST/TARGET BOARD: $b"
324 rtf=(
325 --host_board="$b"
326 --target_board="$b"
328 rtf_for_board "$b"
329 do_tests
330 done
333 # Call top-level function with command line arguments.
334 main "$@"