]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/testsuite/gdb.gdb/complaints.exp
9187d8f148f1e2c46c5bdbd02f2f4794abdd8654
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.gdb / complaints.exp
1 # Copyright 2002-2014 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 # This file was written by Andrew Cagney (cagney at redhat dot com),
17 # derived from xfullpath.exp (written by Joel Brobecker), derived from
18 # selftest.exp (written by Rob Savoye).
19
20 load_lib selftest-support.exp
21
22 if [target_info exists gdb,noinferiorio] {
23 verbose "Skipping because of no inferiorio capabilities."
24 return
25 }
26
27 proc test_initial_complaints { } {
28
29 global gdb_prompt
30
31 # Unsupress complaints
32 gdb_test "set stop_whining = 2"
33
34 # Prime the system
35 gdb_test "call complaint (&symfile_complaints, \"Register a complaint\")" \
36 "During symbol reading, Register a complaint."
37
38 # Check that the complaint was inserted and where
39 gdb_test "print symfile_complaints->root->fmt" \
40 ".\[0-9\]+ =.*\"Register a complaint\""
41
42 # Re-issue the first message #1
43 gdb_test "call complaint (&symfile_complaints, symfile_complaints->root->fmt)" \
44 "During symbol reading, Register a complaint."
45
46 # Check that there is only one thing in the list
47 gdb_test "print symfile_complaints->root->next == &complaint_sentinel" \
48 ".\[0-9\]+ = 1" "list has one entry"
49
50 # Add a second complaint, expect it
51 gdb_test "call complaint (&symfile_complaints, \"Testing! Testing! Testing!\")" \
52 "During symbol reading, Testing. Testing. Testing.."
53
54 return 0
55 }
56
57 proc test_serial_complaints { } {
58
59 global gdb_prompt
60
61 gdb_test_exact "call clear_complaints (&symfile_complaints, 1, 0)" "" "serial start"
62
63 # Prime the system
64 gdb_test_multiple "call complaint (&symfile_complaints, \"serial line 1\")" "serial line 1" {
65 -re "During symbol reading...serial line 1...$gdb_prompt $" {
66 pass "serial line 1"
67 }
68 }
69
70 # Add a second complaint, expect it
71 gdb_test_multiple "call complaint (&symfile_complaints, \"serial line 2\")" "serial line 2" {
72 -re "serial line 2...$gdb_prompt " {
73 pass "serial line 2"
74 }
75 }
76
77 gdb_test_multiple "call clear_complaints (&symfile_complaints, 1, 0)" "serial end" {
78 -re "\r\n\r\n$gdb_prompt " {
79 pass "serial end"
80 }
81 }
82
83 return 0
84 }
85
86 # For short complaints, all are the same
87
88 proc test_short_complaints { } {
89
90 global gdb_prompt
91
92 gdb_test_exact "call clear_complaints (&symfile_complaints, 1, 1)" "" "short start"
93
94 # Prime the system
95 gdb_test_multiple "call complaint (&symfile_complaints, \"short line 1\")" "short line 1" {
96 -re "short line 1...$gdb_prompt " {
97 pass "short line 1"
98 }
99 }
100
101 # Add a second complaint, expect it
102 gdb_test_multiple "call complaint (&symfile_complaints, \"short line 2\")" "short line 2" {
103 -re "short line 2...$gdb_prompt " {
104 pass "short line 2"
105 }
106 }
107
108 gdb_test_multiple "call clear_complaints (&symfile_complaints, 1, 0)" "short end" {
109 -re "\r\n\r\n$gdb_prompt " {
110 pass "short end"
111 }
112 }
113
114 return 0
115 }
116
117 # Check that nothing comes out when there haven't been any real
118 # complaints. Note that each test is really checking the previous
119 # command.
120
121 proc test_empty_complaint { cmd msg } {
122 global gdb_prompt
123 gdb_test_multiple $cmd $msg {
124 -re "\r\n\r\n$gdb_prompt $" {
125 fail $msg
126 }
127 "\r\n$gdb_prompt $" {
128 pass $msg
129 }
130 }
131 }
132
133 proc test_empty_complaints { } {
134
135 test_empty_complaint "call clear_complaints(&symfile_complaints,0,0)" \
136 "empty non-verbose non-noisy clear"
137 test_empty_complaint "call clear_complaints(&symfile_complaints,1,0)" \
138 "empty verbose non-noisy clear"
139 test_empty_complaint "call clear_complaints(&symfile_complaints,1,1)" \
140 "empty verbose noisy clear"
141 test_empty_complaint "call clear_complaints(&symfile_complaints,0,1)" \
142 "empty non-verbose noisy clear"
143
144 return 0
145 }
146
147 do_self_tests captured_command_loop {
148 test_initial_complaints
149 test_serial_complaints
150 test_short_complaints
151 test_empty_complaints
152 }