]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/testsuite/gdb.base/ui-redirect.exp
Update copyright year range in header of all files managed by GDB
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.base / ui-redirect.exp
CommitLineData
1d506c26 1# Copyright (C) 2010-2024 Free Software Foundation, Inc.
14dba4b4
JK
2
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.
7#
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.
12#
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/>.
15
81f47ac2 16# Do not run if gdb debug is enabled as it will interfere with log redirect.
e5bf39c5 17require !gdb_debug_enabled
81f47ac2 18
5b362f04 19if { [prepare_for_testing "failed to prepare" ui-redirect start.c] } {
14dba4b4
JK
20 return -1
21}
22
30331a6c 23if ![runto_main] {
30331a6c
TV
24 return -1
25}
14dba4b4
JK
26
27set test "commands"
28gdb_test_multiple $test $test {
29 -re "End with a line saying just \"end\"\\.\r\n>$" {
30 pass $test
31 }
32}
33
34set test "print 1"
35gdb_test_multiple $test $test {
36 -re "\r\n>$" {
37 pass $test
38 }
39}
40gdb_test_no_output "end"
41
ca1285d1
AH
42gdb_breakpoint "foo"
43gdb_breakpoint "bar"
44
30331a6c 45set cmds [multi_line_input \
8abd8ee8 46 "break -qualified main" \
30331a6c
TV
47 " commands" \
48 " print 1" \
49 " end" \
50 "break foo" \
51 "break bar"]
52set cmds "$cmds\n"
53set outdir [standard_output_file {}]
54set cmds_file "$outdir/cmds.txt"
55
65d1cd5f
TV
56with_test_prefix "userdefined" {
57 set test "define userdefined"
58 gdb_test_multiple $test $test {
59 -re "End with a line saying just \"end\"\\.\r\n>$" {
60 pass $test
61 }
62 }
63
64 set test "bt"
65 gdb_test_multiple $test $test {
66 -re "\r\n>$" {
67 pass $test
68 }
69 }
70
71 gdb_test_no_output "end"
72}
73
f3a09c80
AH
74with_test_prefix "logging" {
75 gdb_test_no_output "set logging file /dev/null"
6ff96754 76 gdb_test "set logging enabled on" \
ca1285d1 77 "Copying output to /dev/null.*Copying debug output to /dev/null\\."
30331a6c
TV
78 gdb_test "save breakpoints $cmds_file" "Saved to file '$cmds_file'\\." \
79 "save breakpoints cmds.txt"
80 cmp_file_string "$cmds_file" "$cmds" "cmds.txt"
65d1cd5f 81 gdb_test "userdefined" "#0 main ().*"
6ff96754 82 gdb_test "set logging enabled off" "Done logging to /dev/null\\."
f3a09c80
AH
83 gdb_test "help" "List of classes of commands:.*"
84}
85
86with_test_prefix "redirect" {
87 gdb_test "set logging redirect on"
6ff96754 88 gdb_test "set logging enabled on" \
ca1285d1 89 "Redirecting output to /dev/null.*Copying debug output to /dev/null\\."
30331a6c
TV
90 gdb_test_no_output "save breakpoints $cmds_file" "save breakpoints cmds.txt"
91 cmp_file_string "$cmds_file" "$cmds" "cmds.txt"
65d1cd5f 92 gdb_test_no_output "userdefined"
6ff96754 93 gdb_test "set logging enabled off" "Done logging to /dev/null\\."
f3a09c80 94 gdb_test "help" "List of classes of commands:.*"
fdc3b978 95 gdb_test_no_output "set logging redirect off"
f3a09c80
AH
96}
97
98with_test_prefix "redirect while already logging" {
6ff96754 99 gdb_test "set logging enabled on" \
ca1285d1 100 "Copying output to /dev/null.*Copying debug output to /dev/null\\."
f3a09c80
AH
101 gdb_test "set logging redirect on" \
102 ".*warning: Currently logging .*Turn the logging off and on to make the new setting effective.*"
30331a6c
TV
103 gdb_test "save breakpoints $cmds_file" "Saved to file '$cmds_file'\\." \
104 "save breakpoints cmds.txt"
105 cmp_file_string "$cmds_file" "$cmds" "cmds.txt"
65d1cd5f 106 gdb_test "userdefined" "#0 main ().*"
6ff96754 107 gdb_test "set logging enabled off" "Done logging to /dev/null\\."
f3a09c80 108 gdb_test "help" "List of classes of commands:.*"
ca1285d1
AH
109 gdb_test_no_output "set logging redirect off"
110}
111
112with_test_prefix "debugging" {
113 gdb_test "set debug infrun 1"
6ff96754 114 gdb_test "set logging enabled on" \
ca1285d1 115 "Copying output to /dev/null.*Copying debug output to /dev/null\\."
3ec3145c 116
c76d61da
PA
117 gdb_test \
118 -prompt "$gdb_prompt \\\[infrun\\\] fetch_inferior_event: exit\r\n$" \
119 "continue" \
120 "Continuing.*\\\[infrun\\\] .*\\\[infrun\\\] .*Breakpoint \[0-9\]+, foo.*"
3ec3145c 121
ca1285d1 122 gdb_test "set debug infrun 0"
6ff96754 123 gdb_test "set logging enabled off" "Done logging to /dev/null\\."
ca1285d1
AH
124 gdb_test "help" "List of classes of commands:.*"
125}
126
127with_test_prefix "redirect debugging" {
128 gdb_test_no_output "set logging debugredirect on"
129 gdb_test "set debug infrun 1"
6ff96754 130 gdb_test "set logging enabled on" \
ca1285d1
AH
131 "Copying output to /dev/null.*Redirecting debug output to /dev/null\\."
132 gdb_test "continue" "Continuing.*((?!infrun).).*Breakpoint \[0-9\]+, bar.*"
133 gdb_test "set debug infrun 0"
6ff96754 134 gdb_test "set logging enabled off" "Done logging to /dev/null\\."
ca1285d1 135 gdb_test "help" "List of classes of commands:.*"
f3a09c80 136}
59b59f08
LS
137
138with_test_prefix "redirect logging and debuging" {
139 gdb_test_no_output "set logging redirect on"
140 gdb_test_no_output "set logging debugredirect on"
6ff96754 141 gdb_test "set logging enabled on" \
59b59f08 142 "Redirecting output to /dev/null.*Redirecting debug output to /dev/null\\."
6ff96754 143 gdb_test "set logging enabled off" "Done logging to /dev/null\\."
59b59f08 144}