]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/testsuite/gdb.base/startup-with-shell.exp
Update copyright year range in header of all files managed by GDB
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.base / startup-with-shell.exp
1 # This testcase is part of GDB, the GNU debugger.
2
3 # Copyright 2017-2024 Free Software Foundation, Inc.
4
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 3 of the License, or
8 # (at your option) any later version.
9 #
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public License
16 # along with this program. If not, see <http://www.gnu.org/licenses/>.
17
18 # This test doesn't make sense on native-gdbserver.
19 require !use_gdb_stub
20
21 # There's no easy way to set environment variables on remote targets
22 # (via dejagnu) yet.
23 require {!is_remote target}
24
25 standard_testfile
26
27 if { [build_executable "failed to prepare" $testfile $srcfile debug] } {
28 return -1
29 }
30
31 set unique_file [standard_output_file "unique-file.unique-extension"]
32 set unique_file_dir [standard_output_file ""]
33
34 run_on_host \
35 "touch OUTPUT_DIR/unique-file.unique-extension" \
36 "touch" "$unique_file"
37
38 # Initial setup for simple test (wildcard expansion, variable substitution).
39
40 proc initial_setup_simple { startup_with_shell run_args } {
41 global hex decimal binfile unique_file
42
43 clean_restart $binfile
44
45 gdb_test_no_output "set startup-with-shell $startup_with_shell"
46
47 gdb_test_no_output "set args $run_args" \
48 "set args \$run_args"
49
50 set test "inferior started"
51 if { [runto_main] } {
52 pass $test
53 } else {
54 fail $test
55 }
56 }
57
58 ## Run the actual tests
59
60 with_test_prefix "startup_with_shell = on; run_args = *.unique-extension" {
61 initial_setup_simple "on" "$unique_file_dir/*.unique-extension"
62 gdb_test "print argv\[1\]" "\\\$$decimal = $hex \"$unique_file\"" \
63 "first argument expanded"
64 }
65
66 with_test_prefix "startup_with_shell = off; run_args = *.unique-extension" {
67 initial_setup_simple "off" "$unique_file_dir/*.unique-extension"
68 gdb_test "print argv\[1\]" "\\\$$decimal = $hex \"$unique_file_dir/\\\*\.unique-extension\"" \
69 "first argument not expanded"
70 }
71
72 with_test_prefix "startup_with_shell = on; run_args = \$TEST" {
73 set env(TEST) "1234"
74 initial_setup_simple "on" "\$TEST"
75 gdb_test "print argv\[1\]" "\\\$$decimal = $hex \"1234\"" \
76 "testing first argument"
77 unset env(TEST)
78 }
79
80 with_test_prefix "startup_with_shell = off; run_args = \$TEST" {
81 set env(TEST) "1234"
82 initial_setup_simple "off" "\$TEST"
83 gdb_test "print argv\[1\]" "\\\$$decimal = $hex \"\\\$TEST\"" \
84 "testing first argument"
85 unset env(TEST)
86 }