]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/testsuite/lib/dg-add-core-file-count.sh
Update copyright year range in header of all files managed by GDB
[thirdparty/binutils-gdb.git] / gdb / testsuite / lib / dg-add-core-file-count.sh
1 #!/bin/sh
2
3 # Copyright (C) 2022-2024 Free Software Foundation, Inc.
4
5 # This file is part of GDB.
6
7 # This program is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 3 of the License, or
10 # (at your option) any later version.
11 #
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
16 #
17 # You should have received a copy of the GNU General Public License
18 # along with this program. If not, see <http://www.gnu.org/licenses/>.
19
20 # Count number of core files in the current directory and if non-zero,
21 # add a line to the gdb.sum file. This scripts assumes it is run from
22 # the build/gdb/testsuite/ directory. It is normally invoked by the
23 # Makefile.
24
25 # Count core files portably, using POSIX compliant shell, avoiding ls,
26 # find, wc, etc. Spawning a subshell isn't strictly needed, but it's
27 # clearer. The "*core*" pattern is this lax in order to find all of
28 # "core", "core.PID", "core.<program>.PID", "<program>.core", etc.
29 cores=$(set -- *core*; [ $# -eq 1 -a ! -e "$1" ] && shift; echo $#)
30
31 # If no cores found, then don't add our summary line.
32 if [ "$cores" -eq "0" ]; then
33 exit
34 fi
35
36 # Add our line to the summary.
37 sed -i'' -e "/=== gdb Summary ===/{
38 n
39 a\\
40 # of unexpected core files $cores
41 }" gdb.sum