Automatic Copyright Year update after running gdb/copyright.py
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.base / ui-redirect.exp
CommitLineData
88b9d363 1# Copyright (C) 2010-2022 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
TV
26if ![runto_main] {
27 fail "can't run to main"
28 return -1
29}
14dba4b4
JK
30
31set test "commands"
32gdb_test_multiple $test $test {
33 -re "End with a line saying just \"end\"\\.\r\n>$" {
34 pass $test
35 }
36}
37
38set test "print 1"
39gdb_test_multiple $test $test {
40 -re "\r\n>$" {
41 pass $test
42 }
43}
44gdb_test_no_output "end"
45
ca1285d1
AH
46gdb_breakpoint "foo"
47gdb_breakpoint "bar"
48
30331a6c 49set cmds [multi_line_input \
8abd8ee8 50 "break -qualified main" \
30331a6c
TV
51 " commands" \
52 " print 1" \
53 " end" \
54 "break foo" \
55 "break bar"]
56set cmds "$cmds\n"
57set outdir [standard_output_file {}]
58set cmds_file "$outdir/cmds.txt"
59
65d1cd5f
TV
60with_test_prefix "userdefined" {
61 set test "define userdefined"
62 gdb_test_multiple $test $test {
63 -re "End with a line saying just \"end\"\\.\r\n>$" {
64 pass $test
65 }
66 }
67
68 set test "bt"
69 gdb_test_multiple $test $test {
70 -re "\r\n>$" {
71 pass $test
72 }
73 }
74
75 gdb_test_no_output "end"
76}
77
f3a09c80
AH
78with_test_prefix "logging" {
79 gdb_test_no_output "set logging file /dev/null"
ca1285d1
AH
80 gdb_test "set logging on" \
81 "Copying output to /dev/null.*Copying debug output to /dev/null\\."
30331a6c
TV
82 gdb_test "save breakpoints $cmds_file" "Saved to file '$cmds_file'\\." \
83 "save breakpoints cmds.txt"
84 cmp_file_string "$cmds_file" "$cmds" "cmds.txt"
65d1cd5f 85 gdb_test "userdefined" "#0 main ().*"
f3a09c80
AH
86 gdb_test "set logging off" "Done logging to /dev/null\\."
87 gdb_test "help" "List of classes of commands:.*"
88}
89
90with_test_prefix "redirect" {
91 gdb_test "set logging redirect on"
ca1285d1
AH
92 gdb_test "set logging on" \
93 "Redirecting output to /dev/null.*Copying debug output to /dev/null\\."
30331a6c
TV
94 gdb_test_no_output "save breakpoints $cmds_file" "save breakpoints cmds.txt"
95 cmp_file_string "$cmds_file" "$cmds" "cmds.txt"
65d1cd5f 96 gdb_test_no_output "userdefined"
f3a09c80
AH
97 gdb_test "set logging off" "Done logging to /dev/null\\."
98 gdb_test "help" "List of classes of commands:.*"
99}
100
101with_test_prefix "redirect while already logging" {
102 gdb_test_no_output "set logging redirect off"
ca1285d1
AH
103 gdb_test "set logging on" \
104 "Copying output to /dev/null.*Copying debug output to /dev/null\\."
f3a09c80
AH
105 gdb_test "set logging redirect on" \
106 ".*warning: Currently logging .*Turn the logging off and on to make the new setting effective.*"
30331a6c
TV
107 gdb_test "save breakpoints $cmds_file" "Saved to file '$cmds_file'\\." \
108 "save breakpoints cmds.txt"
109 cmp_file_string "$cmds_file" "$cmds" "cmds.txt"
65d1cd5f 110 gdb_test "userdefined" "#0 main ().*"
f3a09c80
AH
111 gdb_test "set logging off" "Done logging to /dev/null\\."
112 gdb_test "help" "List of classes of commands:.*"
ca1285d1
AH
113 gdb_test_no_output "set logging redirect off"
114}
115
116with_test_prefix "debugging" {
117 gdb_test "set debug infrun 1"
118 gdb_test "set logging on" \
119 "Copying output to /dev/null.*Copying debug output to /dev/null\\."
3ec3145c
SM
120
121 set prompt "$gdb_prompt \\\[infrun\\\] fetch_inferior_event: exit\r\n$"
122 gdb_test_multiple "continue" "continue" -prompt $prompt {
123 -re "Continuing.*\\\[infrun\\\] .*\\\[infrun\\\] .*Breakpoint \[0-9\]+, foo.*$prompt$" {
124 pass $gdb_test_name
125 }
126 }
127
ca1285d1
AH
128 gdb_test "set debug infrun 0"
129 gdb_test "set logging off" "Done logging to /dev/null\\."
130 gdb_test "help" "List of classes of commands:.*"
131}
132
133with_test_prefix "redirect debugging" {
134 gdb_test_no_output "set logging debugredirect on"
135 gdb_test "set debug infrun 1"
136 gdb_test "set logging on" \
137 "Copying output to /dev/null.*Redirecting debug output to /dev/null\\."
138 gdb_test "continue" "Continuing.*((?!infrun).).*Breakpoint \[0-9\]+, bar.*"
139 gdb_test "set debug infrun 0"
140 gdb_test "set logging off" "Done logging to /dev/null\\."
141 gdb_test "help" "List of classes of commands:.*"
f3a09c80 142}
59b59f08
LS
143
144with_test_prefix "redirect logging and debuging" {
145 gdb_test_no_output "set logging redirect on"
146 gdb_test_no_output "set logging debugredirect on"
147 gdb_test "set logging on" \
148 "Redirecting output to /dev/null.*Redirecting debug output to /dev/null\\."
149 gdb_test "set logging off" "Done logging to /dev/null\\."
150}
This page took 1.548068 seconds and 4 git commands to generate.