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