Commit | Line | Data |
---|---|---|
88b9d363 | 1 | # Copyright 2002-2022 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 | 20 | load_lib selftest-support.exp |
54951bd7 | 21 | |
c0b9f2c6 PA |
22 | if [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 |
30 | proc 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 | ||
56 | proc test_initial_complaints { } { | |
54951bd7 AC |
57 | # Unsupress complaints |
58 | gdb_test "set stop_whining = 2" | |
59 | ||
ff1cf532 TT |
60 | gdb_test_no_output "set var \$cstr = \"Register a complaint\"" |
61 | ||
54951bd7 | 62 | # Prime the system |
62d7ae92 | 63 | gdb_test_stdio \ |
ff1cf532 | 64 | "call complaint_internal (\$cstr)" \ |
5ca8c39f | 65 | "During symbol reading: Register a complaint" |
54951bd7 | 66 | |
54951bd7 | 67 | # Re-issue the first message #1 |
c9f3b40e TV |
68 | with_test_prefix "re-issue" { |
69 | gdb_test_stdio \ | |
70 | "call complaint_internal (\$cstr)" \ | |
71 | "During symbol reading: Register a complaint" | |
72 | } | |
54951bd7 | 73 | |
54951bd7 | 74 | # Add a second complaint, expect it |
62d7ae92 | 75 | gdb_test_stdio \ |
b98664d3 | 76 | "call complaint_internal (\"Testing! Testing! Testing!\")" \ |
5ca8c39f | 77 | "During symbol reading: Testing. Testing. Testing." |
54951bd7 | 78 | |
54951bd7 AC |
79 | return 0 |
80 | } | |
81 | ||
9dd34b2b AC |
82 | # Check that nothing comes out when there haven't been any real |
83 | # complaints. Note that each test is really checking the previous | |
84 | # command. | |
85 | ||
86 | proc test_empty_complaint { cmd msg } { | |
87 | global gdb_prompt | |
4d30e432 PA |
88 | global inferior_spawn_id gdb_spawn_id |
89 | ||
90 | if {$gdb_spawn_id == $inferior_spawn_id} { | |
91 | gdb_test_no_output $cmd $msg | |
92 | } else { | |
93 | set seen_output 0 | |
94 | gdb_test_multiple $cmd $msg { | |
95 | -i $inferior_spawn_id -re "." { | |
96 | set seen_output 1 | |
97 | exp_continue | |
98 | } | |
99 | -i $gdb_spawn_id "$gdb_prompt $" { | |
100 | gdb_assert !$seen_output $msg | |
101 | } | |
9dd34b2b | 102 | } |
9dd34b2b | 103 | } |
9dd34b2b AC |
104 | } |
105 | ||
106 | proc test_empty_complaints { } { | |
e34a209e TV |
107 | global decimal |
108 | ||
109 | set re [multi_line \ | |
110 | "All functions matching regular expression \[^:\]*:" \ | |
111 | "" \ | |
112 | "File \[^\r\n\]*/complaints\\.c:" \ | |
113 | "$decimal:\tvoid clear_complaints\\(\\);"] | |
114 | ||
115 | set found 0 | |
116 | gdb_test_multiple "info function ^clear_complaints()$" "" { | |
117 | -re -wrap $re { | |
118 | set found 1 | |
119 | } | |
120 | -re -wrap "" { | |
121 | } | |
122 | } | |
123 | if { ! $found } { | |
124 | untested "Cannot find clear_complaints, skipping test" | |
125 | return 0 | |
126 | } | |
9dd34b2b | 127 | |
5ca8c39f TT |
128 | test_empty_complaint "call clear_complaints()" \ |
129 | "clear complaints" | |
9dd34b2b AC |
130 | |
131 | return 0 | |
132 | } | |
133 | ||
c95aea6b TT |
134 | do_self_tests captured_command_loop { |
135 | test_initial_complaints | |
c95aea6b | 136 | test_empty_complaints |
54951bd7 | 137 | } |