]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
[gdb/testsuite] Add have_startup_shell
authorTom de Vries <tdevries@suse.de>
Wed, 27 Aug 2025 08:37:45 +0000 (10:37 +0200)
committerTom de Vries <tdevries@suse.de>
Wed, 27 Aug 2025 08:37:45 +0000 (10:37 +0200)
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.

gdb/testsuite/gdb.base/a2-run.exp
gdb/testsuite/gdb.base/args.exp
gdb/testsuite/gdb.base/inferior-args.exp
gdb/testsuite/gdb.base/startup-with-shell.exp
gdb/testsuite/gdb.mi/mi-exec-run.exp
gdb/testsuite/lib/gdb.exp

index 4e95e56ed894d2238ad583cebbd67e5915e5aadf..966e12a6f0583744f43d661579ad3aedb90b0a93 100644 (file)
@@ -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"
 }
index 33952e4bd7696c0874aaa0f14788bdcd2bf1a178..7b62a750bf4abc7f88e16e6c8d8550a6cbbdb06f 100644 (file)
@@ -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
 
index 9406c7882f043bdb8982dc3ca387bb4c1bf1092b..dfa1215c504431529b9e3dd915e84fa86eb9198f 100644 (file)
@@ -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
 
index 80dfdf3db83c524a74a8b1b736044cf363633636..9c016b47c1f1f1ef4bd6e9cc21dd2ebc4e195dca 100644 (file)
@@ -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] } {
index a7a61b80fd2ccba3fabb13f6afffd506d0756e2b..43406cf6ab4fc431ab490143b30aad3cf6497995 100644 (file)
@@ -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}
        }
     }
index 041650ac33a559ea0305da0560f074e87e78d594..d3e2a454902cdabffae5073adc7c10a9e7af904e 100644 (file)
@@ -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