1 # Copyright
(C
) 2021-2023 Free Software Foundation
, Inc.
3 # This
program is free software
; you can redistribute it and
/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation
; either version
3 of the License
, or
6 #
(at your option
) any later version.
8 # This
program is distributed in the hope that it will be useful
,
9 # but WITHOUT
ANY WARRANTY
; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License
for more details.
13 # You should have received a copy of the GNU General Public License
14 # along with this
program.
If not
, see
<http
://www.gnu.org
/licenses
/>.
16 # This testcase checks that the clone
-inferior command copies important
17 # properties from the original to the new inferior such CWD
, args and env.
19 # Add an environment
variable that can be modified later
for each inferior
23 # This test does not need a binfile.
26 #
Set custom properties
for Inferior
1
27 with_test_prefix
"setup inferior 1" {
28 gdb_test_no_output
"set args foo bar 'b a z'"
29 gdb_test_no_output
"set cwd /any/where"
30 gdb_test_no_output
"set environment FOO foo"
31 gdb_test_no_output
"set environment BAR bar"
32 gdb_test_no_output
"set inferior-tty some_tty"
33 gdb_test
{print $_gdb_setting_str
("inferior-tty")} \
37 # Check that properties of inferior
1 have been copied
38 with_test_prefix
"inferior 2" {
39 gdb_test
"clone-inferior" "Added inferior 2.*"
40 gdb_test
"inferior 2" "\[Switching to inferior 2 \[<null>\] (.*)\]" "change inferior"
41 gdb_test
"show args" \
42 "Argument list to give program being debugged when it is started is \"foo bar 'b a z'\"\."
44 "Current working directory that will be used when starting the inferior is \"/any/where\"\."
45 gdb_test
"show environment FOO" "FOO = foo"
46 gdb_test
"show environment BAR" "BAR = bar"
47 gdb_test
"show environment ENVVAR" "ENVVAR = var"
48 gdb_test
"show inferior-tty" \
49 "Terminal for future runs of program being debugged is \"some_tty\"\."
50 gdb_test
{print $_gdb_setting_str
("inferior-tty")} \
54 # Change this second inferior
, to check that the next clone
-inferior
55 # clones from the active inferior
, and changing the
values for inferior
2
56 # does not interfere with
values on inferior
1.
57 with_test_prefix
"update inferior 2" {
58 gdb_test_no_output
"set args foo"
59 gdb_test_no_output
"set cwd /somewhere/else"
60 gdb_test_no_output
"set environment FOO oof"
61 gdb_test_no_output
"set inferior-tty another_tty"
62 gdb_test
{print $_gdb_setting_str
("inferior-tty")} \
66 with_test_prefix
"inferior 1" {
67 gdb_test
"inferior 1" "\[Switching to inferior 1 \[<null>\] (.*)\]" "change inferior"
68 gdb_test
"show args" \
69 "Argument list to give program being debugged when it is started is \"foo bar 'b a z'\"\."
71 "Current working directory that will be used when starting the inferior is \"/any/where\"\."
72 gdb_test
"show environment FOO" "FOO = foo"
73 gdb_test
"show environment BAR" "BAR = bar"
74 gdb_test
"show environment ENVVAR" "ENVVAR = var"
75 gdb_test
"show inferior-tty" \
76 "Terminal for future runs of program being debugged is \"some_tty\"\."
77 gdb_test
{print $_gdb_setting_str
("inferior-tty")} \
81 # Tweak inferior
1 a bit more.
82 with_test_prefix
"update inferior 1" {
83 gdb_test_no_output
"unset environment FOO"
84 gdb_test_no_output
"unset environment ENVVAR"
88 # Check that the
values observed
on inferior
3 are those copied from
90 with_test_prefix
"inferior 3" {
91 gdb_test
"clone-inferior" "Added inferior 3.*"
92 gdb_test
"inferior 3" "\[Switching to inferior 3 \[<null>\] (.*)\]" "change inferior"
93 gdb_test
"show args" \
94 "Argument list to give program being debugged when it is started is \"foo bar 'b a z'\"\."
96 "Current working directory that will be used when starting the inferior is \"/any/where\"\."
97 gdb_test
"show environment FOO" "Environment variable \"FOO\" not defined\."
98 gdb_test
"show environment BAR" "BAR = bar"
99 gdb_test
"show environment ENVVAR" "Environment variable \"ENVVAR\" not defined\."
100 gdb_test
"show inferior-tty" \
101 "Terminal for future runs of program being debugged is \"some_tty\"\."