Remove symfile_complaints
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.gdb / complaints.exp
CommitLineData
e2882c85 1# Copyright 2002-2018 Free Software Foundation, Inc.
54951bd7
AC
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
e22f8b7c 5# the Free Software Foundation; either version 3 of the License, or
54951bd7 6# (at your option) any later version.
e22f8b7c 7#
54951bd7
AC
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.
e22f8b7c 12#
54951bd7 13# You should have received a copy of the GNU General Public License
e22f8b7c 14# along with this program. If not, see <http://www.gnu.org/licenses/>.
54951bd7 15
54951bd7
AC
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
c95aea6b 20load_lib selftest-support.exp
54951bd7 21
c0b9f2c6
PA
22if [target_info exists gdb,noinferiorio] {
23 verbose "Skipping because of no inferiorio capabilities."
24 return
25}
26
4d30e432
PA
27# Similar to gdb_test_stdio, except no \r\n is expected before
28# $gdb_prompt in the $gdb_spawn_id.
54951bd7 29
4d30e432
PA
30proc test_complaint {test inferior_io_re msg} {
31 global inferior_spawn_id gdb_spawn_id
54951bd7
AC
32 global gdb_prompt
33
4d30e432
PA
34 set inferior_matched 0
35 set gdb_matched 0
36
37 gdb_test_multiple $test $msg {
38 -i $inferior_spawn_id -re "$inferior_io_re" {
39 set inferior_matched 1
40 if {!$gdb_matched} {
41 exp_continue
42 }
43 }
44 -i $gdb_spawn_id -re "$gdb_prompt $" {
45 set gdb_matched 1
46 if {!$inferior_matched} {
47 exp_continue
48 }
49 }
50 }
51
52 verbose -log "inferior_matched=$inferior_matched, gdb_matched=$gdb_matched"
53 gdb_assert {$inferior_matched && $gdb_matched} $msg
54}
55
56proc test_initial_complaints { } {
54951bd7
AC
57 # Unsupress complaints
58 gdb_test "set stop_whining = 2"
59
60 # Prime the system
62d7ae92 61 gdb_test_stdio \
b98664d3 62 "call complaint_internal (\"Register a complaint\")" \
62d7ae92 63 "During symbol reading, Register a complaint."
54951bd7
AC
64
65 # Check that the complaint was inserted and where
b98664d3 66 gdb_test "print symfile_complaint_book.root->fmt" \
54951bd7
AC
67 ".\[0-9\]+ =.*\"Register a complaint\""
68
69 # Re-issue the first message #1
62d7ae92 70 gdb_test_stdio \
b98664d3 71 "call complaint_internal (symfile_complaint_book.root->fmt)" \
62d7ae92 72 "During symbol reading, Register a complaint."
54951bd7 73
a37bfa30
PA
74 # Check that there is only one thing in the list. How the boolean
75 # result is output depends on whether GDB is built as a C or C++
76 # program.
b98664d3 77 gdb_test "print symfile_complaint_book.root->next == &complaint_sentinel" \
a37bfa30 78 ".\[0-9\]+ = \(1|true\)" "list has one entry"
54951bd7
AC
79
80 # Add a second complaint, expect it
62d7ae92 81 gdb_test_stdio \
b98664d3 82 "call complaint_internal (\"Testing! Testing! Testing!\")" \
62d7ae92 83 "During symbol reading, Testing. Testing. Testing.."
54951bd7
AC
84
85 return 0
86}
87
54951bd7
AC
88# For short complaints, all are the same
89
90proc test_short_complaints { } {
b98664d3 91 gdb_test_exact "call clear_complaints (1)" "" "short start"
54951bd7
AC
92
93 # Prime the system
62d7ae92 94 test_complaint \
b98664d3 95 "call complaint_internal (\"short line 1\")" \
4d30e432
PA
96 "short line 1..." \
97 "short line 1"
54951bd7
AC
98
99 # Add a second complaint, expect it
62d7ae92 100 test_complaint \
b98664d3 101 "call complaint_internal (\"short line 2\")" \
4d30e432
PA
102 "short line 2..." \
103 "short line 2"
54951bd7 104
54951bd7
AC
105 return 0
106}
107
9dd34b2b
AC
108# Check that nothing comes out when there haven't been any real
109# complaints. Note that each test is really checking the previous
110# command.
111
112proc test_empty_complaint { cmd msg } {
113 global gdb_prompt
4d30e432
PA
114 global inferior_spawn_id gdb_spawn_id
115
116 if {$gdb_spawn_id == $inferior_spawn_id} {
117 gdb_test_no_output $cmd $msg
118 } else {
119 set seen_output 0
120 gdb_test_multiple $cmd $msg {
121 -i $inferior_spawn_id -re "." {
122 set seen_output 1
123 exp_continue
124 }
125 -i $gdb_spawn_id "$gdb_prompt $" {
126 gdb_assert !$seen_output $msg
127 }
9dd34b2b 128 }
9dd34b2b 129 }
9dd34b2b
AC
130}
131
132proc test_empty_complaints { } {
133
b98664d3 134 test_empty_complaint "call clear_complaints(0)" \
4e9668d0 135 "empty non-verbose clear"
b98664d3 136 test_empty_complaint "call clear_complaints(1)" \
4e9668d0 137 "empty verbose clear"
9dd34b2b
AC
138
139 return 0
140}
141
c95aea6b
TT
142do_self_tests captured_command_loop {
143 test_initial_complaints
c95aea6b
TT
144 test_short_complaints
145 test_empty_complaints
54951bd7 146}
This page took 1.903062 seconds and 4 git commands to generate.