]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - 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
CommitLineData
aefd8b33
SDJ
1# This testcase is part of GDB, the GNU debugger.
2
213516ef 3# Copyright 2017-2023 Free Software Foundation, Inc.
aefd8b33
SDJ
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.
19if { [use_gdb_stub] } {
20 untested "not supported"
21 return
22}
23
24# There's no easy way to set environment variables on remote targets
25# (via dejagnu) yet.
26if { [is_remote target] } {
27 untested "remote board"
28 return
29}
30
31standard_testfile
32
98bf5c02 33if { [build_executable "failed to prepare" $testfile $srcfile debug] } {
aefd8b33
SDJ
34 return -1
35}
36
37set unique_file [standard_output_file "unique-file.unique-extension"]
38set unique_file_dir [standard_output_file ""]
39
10389c2c
PA
40run_on_host \
41 "touch OUTPUT_DIR/unique-file.unique-extension" \
42 "touch" "$unique_file"
aefd8b33
SDJ
43
44# Initial setup for simple test (wildcard expansion, variable substitution).
45
46proc initial_setup_simple { startup_with_shell run_args } {
47 global hex decimal binfile unique_file
48
49 clean_restart $binfile
50
51 gdb_test_no_output "set startup-with-shell $startup_with_shell"
52
10389c2c
PA
53 gdb_test_no_output "set args $run_args" \
54 "set args \$run_args"
aefd8b33
SDJ
55
56 set test "inferior started"
57 if { [runto_main] } {
58 pass $test
59 } else {
60 fail $test
61 }
62}
63
64## Run the actual tests
65
66with_test_prefix "startup_with_shell = on; run_args = *.unique-extension" {
67 initial_setup_simple "on" "$unique_file_dir/*.unique-extension"
68 gdb_test "print argv\[1\]" "\\\$$decimal = $hex \"$unique_file\"" \
69 "first argument expanded"
70}
71
72with_test_prefix "startup_with_shell = off; run_args = *.unique-extension" {
73 initial_setup_simple "off" "$unique_file_dir/*.unique-extension"
74 gdb_test "print argv\[1\]" "\\\$$decimal = $hex \"$unique_file_dir/\\\*\.unique-extension\"" \
75 "first argument not expanded"
76}
77
78with_test_prefix "startup_with_shell = on; run_args = \$TEST" {
79 set env(TEST) "1234"
80 initial_setup_simple "on" "\$TEST"
81 gdb_test "print argv\[1\]" "\\\$$decimal = $hex \"1234\"" \
82 "testing first argument"
83 unset env(TEST)
84}
85
86with_test_prefix "startup_with_shell = off; run_args = \$TEST" {
87 set env(TEST) "1234"
88 initial_setup_simple "off" "\$TEST"
89 gdb_test "print argv\[1\]" "\\\$$decimal = $hex \"\\\$TEST\"" \
90 "testing first argument"
91 unset env(TEST)
92}