1 # Copyright 2002-2018 Free Software Foundation, Inc.
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.
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.
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/>.
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).
20 load_lib selftest-support.exp
22 if [target_info exists gdb,noinferiorio] {
23 verbose "Skipping because of no inferiorio capabilities."
27 # Similar to gdb_test_stdio, except no \r\n is expected before
28 # $gdb_prompt in the $gdb_spawn_id.
30 proc test_complaint {test inferior_io_re msg} {
31 global inferior_spawn_id gdb_spawn_id
34 set inferior_matched 0
37 gdb_test_multiple $test $msg {
38 -i $inferior_spawn_id -re "$inferior_io_re" {
39 set inferior_matched 1
44 -i $gdb_spawn_id -re "$gdb_prompt $" {
46 if {!$inferior_matched} {
52 verbose -log "inferior_matched=$inferior_matched, gdb_matched=$gdb_matched"
53 gdb_assert {$inferior_matched && $gdb_matched} $msg
56 proc test_initial_complaints { } {
57 # Unsupress complaints
58 gdb_test "set stop_whining = 2"
62 "call complaint_internal (&symfile_complaints, \"Register a complaint\")" \
63 "During symbol reading, Register a complaint."
65 # Check that the complaint was inserted and where
66 gdb_test "print symfile_complaints->root->fmt" \
67 ".\[0-9\]+ =.*\"Register a complaint\""
69 # Re-issue the first message #1
71 "call complaint_internal (&symfile_complaints, symfile_complaints->root->fmt)" \
72 "During symbol reading, Register a complaint."
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++
77 gdb_test "print symfile_complaints->root->next == &complaint_sentinel" \
78 ".\[0-9\]+ = \(1|true\)" "list has one entry"
80 # Add a second complaint, expect it
82 "call complaint_internal (&symfile_complaints, \"Testing! Testing! Testing!\")" \
83 "During symbol reading, Testing. Testing. Testing.."
88 # For short complaints, all are the same
90 proc test_short_complaints { } {
91 gdb_test_exact "call clear_complaints (&symfile_complaints, 1, 1)" "" "short start"
95 "call complaint_internal (&symfile_complaints, \"short line 1\")" \
99 # Add a second complaint, expect it
101 "call complaint_internal (&symfile_complaints, \"short line 2\")" \
108 # Check that nothing comes out when there haven't been any real
109 # complaints. Note that each test is really checking the previous
112 proc test_empty_complaint { cmd msg } {
114 global inferior_spawn_id gdb_spawn_id
116 if {$gdb_spawn_id == $inferior_spawn_id} {
117 gdb_test_no_output $cmd $msg
120 gdb_test_multiple $cmd $msg {
121 -i $inferior_spawn_id -re "." {
125 -i $gdb_spawn_id "$gdb_prompt $" {
126 gdb_assert !$seen_output $msg
132 proc test_empty_complaints { } {
134 test_empty_complaint "call clear_complaints(&symfile_complaints,0,0)" \
135 "empty non-verbose non-noisy clear"
136 test_empty_complaint "call clear_complaints(&symfile_complaints,1,0)" \
137 "empty verbose non-noisy clear"
138 test_empty_complaint "call clear_complaints(&symfile_complaints,1,1)" \
139 "empty verbose noisy clear"
140 test_empty_complaint "call clear_complaints(&symfile_complaints,0,1)" \
141 "empty non-verbose noisy clear"
146 do_self_tests captured_command_loop {
147 test_initial_complaints
148 test_short_complaints
149 test_empty_complaints