]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/testsuite/gdb.base/ui-redirect.exp
Update copyright year range in all GDB files.
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.base / ui-redirect.exp
1 # Copyright (C) 2010-2020 Free Software Foundation, Inc.
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
16 # Do not run if gdb debug is enabled as it will interfere with log redirect.
17 if [gdb_debug_enabled] {
18 untested "debug is enabled"
19 return 0
20 }
21
22 if { [prepare_for_testing "failed to prepare" ui-redirect start.c] } {
23 return -1
24 }
25
26 if ![runto_main] {
27 fail "can't run to main"
28 return -1
29 }
30
31 set test "commands"
32 gdb_test_multiple $test $test {
33 -re "End with a line saying just \"end\"\\.\r\n>$" {
34 pass $test
35 }
36 }
37
38 set test "print 1"
39 gdb_test_multiple $test $test {
40 -re "\r\n>$" {
41 pass $test
42 }
43 }
44 gdb_test_no_output "end"
45
46 gdb_breakpoint "foo"
47 gdb_breakpoint "bar"
48
49 set cmds [multi_line_input \
50 "break main" \
51 " commands" \
52 " print 1" \
53 " end" \
54 "break foo" \
55 "break bar"]
56 set cmds "$cmds\n"
57 set outdir [standard_output_file {}]
58 set cmds_file "$outdir/cmds.txt"
59
60 with_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
78 with_test_prefix "logging" {
79 gdb_test_no_output "set logging file /dev/null"
80 gdb_test "set logging on" \
81 "Copying output to /dev/null.*Copying debug output to /dev/null\\."
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"
85 gdb_test "userdefined" "#0 main ().*"
86 gdb_test "set logging off" "Done logging to /dev/null\\."
87 gdb_test "help" "List of classes of commands:.*"
88 }
89
90 with_test_prefix "redirect" {
91 gdb_test "set logging redirect on"
92 gdb_test "set logging on" \
93 "Redirecting output to /dev/null.*Copying debug output to /dev/null\\."
94 gdb_test_no_output "save breakpoints $cmds_file" "save breakpoints cmds.txt"
95 cmp_file_string "$cmds_file" "$cmds" "cmds.txt"
96 gdb_test_no_output "userdefined"
97 gdb_test "set logging off" "Done logging to /dev/null\\."
98 gdb_test "help" "List of classes of commands:.*"
99 }
100
101 with_test_prefix "redirect while already logging" {
102 gdb_test_no_output "set logging redirect off"
103 gdb_test "set logging on" \
104 "Copying output to /dev/null.*Copying debug output to /dev/null\\."
105 gdb_test "set logging redirect on" \
106 ".*warning: Currently logging .*Turn the logging off and on to make the new setting effective.*"
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"
110 gdb_test "userdefined" "#0 main ().*"
111 gdb_test "set logging off" "Done logging to /dev/null\\."
112 gdb_test "help" "List of classes of commands:.*"
113 gdb_test_no_output "set logging redirect off"
114 }
115
116 with_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\\."
120 gdb_test "continue" "Continuing.*infrun:.*infrun:.*Breakpoint \[0-9\]+, foo.*"
121 gdb_test "set debug infrun 0"
122 gdb_test "set logging off" "Done logging to /dev/null\\."
123 gdb_test "help" "List of classes of commands:.*"
124 }
125
126 with_test_prefix "redirect debugging" {
127 gdb_test_no_output "set logging debugredirect on"
128 gdb_test "set debug infrun 1"
129 gdb_test "set logging on" \
130 "Copying output to /dev/null.*Redirecting debug output to /dev/null\\."
131 gdb_test "continue" "Continuing.*((?!infrun).).*Breakpoint \[0-9\]+, bar.*"
132 gdb_test "set debug infrun 0"
133 gdb_test "set logging off" "Done logging to /dev/null\\."
134 gdb_test "help" "List of classes of commands:.*"
135 }