diff options
author | Tom de Vries <tdevries@suse.de> | 2025-08-27 10:37:45 +0200 |
---|---|---|
committer | Tom de Vries <tdevries@suse.de> | 2025-08-27 10:37:45 +0200 |
commit | 793534c26924c986069b03ab1bd6659aead5065b (patch) | |
tree | 1dc4dc5dab5e5aa0294c2275fa32bc6f18c156fd | |
parent | d59c2b35c07805a0cd3146b018808732e61adae3 (diff) | |
download | binutils-793534c26924c986069b03ab1bd6659aead5065b.zip binutils-793534c26924c986069b03ab1bd6659aead5065b.tar.gz binutils-793534c26924c986069b03ab1bd6659aead5065b.tar.bz2 |
[gdb/testsuite] Add have_startup_shell
Say we disable startup-with-shell, we get:
...
(gdb) run `echo 8`^M
Starting program: a2-run `echo 8`^M
[Thread debugging using libthread_db enabled]^M
Using host libthread_db library "/lib64/libthread_db.so.1".^M
usage: factorial <number>^M
[Inferior 1 (process 10787) exited with code 01]^M
(gdb) FAIL: gdb.base/a2-run.exp: run "a2-run" with shell (timeout)
...
Fix this by only doing this test if startup-with-shell is supported.
This fixes the test-case on msys2-ucrt64, where startup-with-shell is not
supported.
Likewise in other test-cases.
Tested on x86_64-linux.
-rw-r--r-- | gdb/testsuite/gdb.base/a2-run.exp | 7 | ||||
-rw-r--r-- | gdb/testsuite/gdb.base/args.exp | 1 | ||||
-rw-r--r-- | gdb/testsuite/gdb.base/inferior-args.exp | 1 | ||||
-rw-r--r-- | gdb/testsuite/gdb.base/startup-with-shell.exp | 2 | ||||
-rw-r--r-- | gdb/testsuite/gdb.mi/mi-exec-run.exp | 5 | ||||
-rw-r--r-- | gdb/testsuite/lib/gdb.exp | 41 |
6 files changed, 54 insertions, 3 deletions
diff --git a/gdb/testsuite/gdb.base/a2-run.exp b/gdb/testsuite/gdb.base/a2-run.exp index 4e95e56..966e12a 100644 --- a/gdb/testsuite/gdb.base/a2-run.exp +++ b/gdb/testsuite/gdb.base/a2-run.exp @@ -18,6 +18,8 @@ # Can't do this test without stdio support. require {!gdb_skip_stdio_test "a2run.exp"} +set have_startup_shell [have_startup_shell] + # # test running programs # @@ -166,9 +168,8 @@ gdb_run_cmd setup_xfail "arm-*-coff" gdb_test_stdio "" "720" "" "run \"$testfile\" again after setting args" -# GOAL: Test that shell is being used with "run". For remote debugging -# targets, there is no guarantee that a "shell" (whatever that is) is used. -if {![is_remote target]} { +# GOAL: Test that shell is being used with "run". +if { $have_startup_shell == 1 } { gdb_test_stdio "run `echo 8`" \ "40320" "" "run \"$testfile\" with shell" } diff --git a/gdb/testsuite/gdb.base/args.exp b/gdb/testsuite/gdb.base/args.exp index 33952e4..7b62a75 100644 --- a/gdb/testsuite/gdb.base/args.exp +++ b/gdb/testsuite/gdb.base/args.exp @@ -21,6 +21,7 @@ require {!target_info exists noargs} # This test requires starting new inferior processes, skip it if the target # board is a stub. require !use_gdb_stub +require {expr [have_startup_shell] != -1} standard_testfile diff --git a/gdb/testsuite/gdb.base/inferior-args.exp b/gdb/testsuite/gdb.base/inferior-args.exp index 9406c78..dfa1215 100644 --- a/gdb/testsuite/gdb.base/inferior-args.exp +++ b/gdb/testsuite/gdb.base/inferior-args.exp @@ -17,6 +17,7 @@ # This does not work on boards that don't support inferior arguments. require {!target_info exists noargs} +require {expr [have_startup_shell] != -1} standard_testfile .c diff --git a/gdb/testsuite/gdb.base/startup-with-shell.exp b/gdb/testsuite/gdb.base/startup-with-shell.exp index 80dfdf3..9c016b4 100644 --- a/gdb/testsuite/gdb.base/startup-with-shell.exp +++ b/gdb/testsuite/gdb.base/startup-with-shell.exp @@ -22,6 +22,8 @@ require !use_gdb_stub # (via dejagnu) yet. require {!is_remote target} +require {expr [have_startup_shell] != -1} + standard_testfile if { [build_executable "failed to prepare" $testfile $srcfile debug] } { diff --git a/gdb/testsuite/gdb.mi/mi-exec-run.exp b/gdb/testsuite/gdb.mi/mi-exec-run.exp index a7a61b8..43406cf 100644 --- a/gdb/testsuite/gdb.mi/mi-exec-run.exp +++ b/gdb/testsuite/gdb.mi/mi-exec-run.exp @@ -30,6 +30,8 @@ set MIFLAGS "-i=mi" # cannot use it, then there is no point in running this testcase. require !use_gdb_stub +set have_startup_shell [have_startup_shell] + standard_testfile mi-start.c if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } { @@ -172,6 +174,9 @@ remote_exec target "chmod \"a-x\" $binfile.nox" foreach_with_prefix inferior-tty {"main" "separate"} { foreach_with_prefix mi {"main" "separate"} { foreach_with_prefix force-fail {0 1} { + if { ${force-fail} && $have_startup_shell == -1 } { + continue + } test ${inferior-tty} ${mi} ${force-fail} } } diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp index 041650a..d3e2a45 100644 --- a/gdb/testsuite/lib/gdb.exp +++ b/gdb/testsuite/lib/gdb.exp @@ -11490,5 +11490,46 @@ gdb_caching_proc have_builtin_trap {} { } executable] } +# Return 1 if there is a startup shell. Return -1 if there's no startup shell. +# Return -1 otherwise. + +gdb_caching_proc have_startup_shell {} { + if { [is_remote target] } { + # For remote debugging targets, there is no guarantee that a "shell" + # is used. + return -1 + } + + + gdb_exit + gdb_start + + set re_on \ + [string_to_regexp "Use of shell to start subprocesses is on."] + set re_off \ + [string_to_regexp "Use of shell to start subprocesses is off."] + set re_cmd_unsupported \ + [string_to_regexp \ + {Undefined show command: "startup-with-shell". Try "help show".}] + + set supported -1 + gdb_test_multiple "show startup-with-shell" "" { + -re -wrap $re_on { + set supported 1 + } + -re -wrap $re_off { + set supported 0 + } + -re -wrap $re_cmd_unsupported { + } + -re -wrap "" { + } + } + + gdb_exit + + return $supported +} + # Always load compatibility stuff. load_lib future.exp |