[binutils-gdb] gdb.base/exitsignal.exp: Exit with non-zero
Pedro Alves via Gdb-cvs <[email protected]> Fri, 12 Jun 2026 13:59:10 +0000 (GMT)
| Newsgroups | gmane.comp.gdb.cvs |
|---|---|
| Message-ID | <[email protected]> |
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=b8adb91d42438a861ca0f014a73733b1ebda30af commit b8adb91d42438a861ca0f014a73733b1ebda30af Author: Pedro Alves <[email protected]> Date: Sat May 23 02:01:12 2026 +0100 gdb.base/exitsignal.exp: Exit with non-zero gdb.base/exitsignal.exp currently tests exiting with exit code 0. But, testing for 0 is typically more "dangerous" in the sense that it's easy for some bug in GDB or the target backend to fail to extract the exit code and return 0. Make it test exit code 1 instead. gdb.base/coredump-filter-build-id.exp currently reuses normal.c. It could still use it with this patch, but it seems better to me to remove the coupling. Simply add a new .c file for that testcase, which still returns 0. Change-Id: I49ccfdbbe4be4445172476e7dd4e06142c8a672e Diff: --- gdb/testsuite/gdb.base/coredump-filter-build-id.c | 22 ++++++++++++++++++++++ .../gdb.base/coredump-filter-build-id.exp | 2 +- gdb/testsuite/gdb.base/exitsignal.exp | 8 ++++---- gdb/testsuite/gdb.base/normal.c | 7 +++++-- 4 files changed, 32 insertions(+), 7 deletions(-) diff --git a/gdb/testsuite/gdb.base/coredump-filter-build-id.c b/gdb/testsuite/gdb.base/coredump-filter-build-id.c new file mode 100644 index 00000000000..d78df952cb5 --- /dev/null +++ b/gdb/testsuite/gdb.base/coredump-filter-build-id.c @@ -0,0 +1,22 @@ +/* This testcase is part of GDB, the GNU debugger. + + Copyright 2013-2026 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. */ + +int +main () +{ + return 0; +} diff --git a/gdb/testsuite/gdb.base/coredump-filter-build-id.exp b/gdb/testsuite/gdb.base/coredump-filter-build-id.exp index d267221e1bf..d8251e5c25f 100644 --- a/gdb/testsuite/gdb.base/coredump-filter-build-id.exp +++ b/gdb/testsuite/gdb.base/coredump-filter-build-id.exp @@ -21,7 +21,7 @@ # external tool, eu-unstrip, to verify if the corefile contains # build-ids. -standard_testfile "normal.c" +standard_testfile # This test is Linux x86_64 only. if { ![istarget *-*-linux*] } { diff --git a/gdb/testsuite/gdb.base/exitsignal.exp b/gdb/testsuite/gdb.base/exitsignal.exp index 49e2ed6dcb3..54b0894fe89 100644 --- a/gdb/testsuite/gdb.base/exitsignal.exp +++ b/gdb/testsuite/gdb.base/exitsignal.exp @@ -128,11 +128,11 @@ proc test_normal {} { return } - gdb_continue_to_end + gdb_test "continue" " exited with code 01\\\].*" "continue to exit" - # Check $_exitcode. It should be 0. - gdb_test "print \$_exitcode" " = 0" \ - "\$_exitcode is zero after normal inferior is executed" + # Check $_exitcode. It should be 1. + gdb_test "print \$_exitcode" " = 1" \ + "\$_exitcode is one after normal inferior is executed" # Check $_exitsignal. It should still be void, since the inferior # has not received any signal. diff --git a/gdb/testsuite/gdb.base/normal.c b/gdb/testsuite/gdb.base/normal.c index dd371746235..ba04c861dad 100644 --- a/gdb/testsuite/gdb.base/normal.c +++ b/gdb/testsuite/gdb.base/normal.c @@ -15,10 +15,13 @@ You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. */ -/* This test is just a normal return 0. */ +/* This test is just a normal return 1. */ int main (int argc, char *argv[]) { - return 0; + /* Non-zero specifically, as it would be otherwise easier for a + buggy GDB to report exit code 0 when it shouldn't and that + wouldn't be noticed. */ + return 1; }