]>
Commit | Line | Data |
---|---|---|
618f726f | 1 | # Copyright 2002-2016 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 | ||
60 | # Prime the system | |
4d30e432 | 61 | gdb_test_stdio "call complaint (&symfile_complaints, \"Register a complaint\")" \ |
54951bd7 AC |
62 | "During symbol reading, Register a complaint." |
63 | ||
64 | # Check that the complaint was inserted and where | |
65 | gdb_test "print symfile_complaints->root->fmt" \ | |
66 | ".\[0-9\]+ =.*\"Register a complaint\"" | |
67 | ||
68 | # Re-issue the first message #1 | |
4d30e432 | 69 | gdb_test_stdio "call complaint (&symfile_complaints, symfile_complaints->root->fmt)" \ |
54951bd7 AC |
70 | "During symbol reading, Register a complaint." |
71 | ||
a37bfa30 PA |
72 | # Check that there is only one thing in the list. How the boolean |
73 | # result is output depends on whether GDB is built as a C or C++ | |
74 | # program. | |
54951bd7 | 75 | gdb_test "print symfile_complaints->root->next == &complaint_sentinel" \ |
a37bfa30 | 76 | ".\[0-9\]+ = \(1|true\)" "list has one entry" |
54951bd7 AC |
77 | |
78 | # Add a second complaint, expect it | |
4d30e432 | 79 | gdb_test_stdio "call complaint (&symfile_complaints, \"Testing! Testing! Testing!\")" \ |
54951bd7 AC |
80 | "During symbol reading, Testing. Testing. Testing.." |
81 | ||
82 | return 0 | |
83 | } | |
84 | ||
85 | proc test_serial_complaints { } { | |
54951bd7 AC |
86 | gdb_test_exact "call clear_complaints (&symfile_complaints, 1, 0)" "" "serial start" |
87 | ||
88 | # Prime the system | |
4d30e432 PA |
89 | test_complaint "call complaint (&symfile_complaints, \"serial line 1\")" \ |
90 | "During symbol reading...serial line 1..." \ | |
91 | "serial line 1" | |
54951bd7 AC |
92 | |
93 | # Add a second complaint, expect it | |
4d30e432 PA |
94 | test_complaint "call complaint (&symfile_complaints, \"serial line 2\")" \ |
95 | "serial line 2..." \ | |
96 | "serial line 2" | |
54951bd7 | 97 | |
4d30e432 PA |
98 | gdb_test_stdio "call clear_complaints (&symfile_complaints, 1, 0)" \ |
99 | "\r\n" \ | |
100 | "" \ | |
101 | "serial end" | |
54951bd7 AC |
102 | |
103 | return 0 | |
104 | } | |
105 | ||
106 | # For short complaints, all are the same | |
107 | ||
108 | proc test_short_complaints { } { | |
54951bd7 AC |
109 | gdb_test_exact "call clear_complaints (&symfile_complaints, 1, 1)" "" "short start" |
110 | ||
111 | # Prime the system | |
4d30e432 PA |
112 | test_complaint "call complaint (&symfile_complaints, \"short line 1\")" \ |
113 | "short line 1..." \ | |
114 | "short line 1" | |
54951bd7 AC |
115 | |
116 | # Add a second complaint, expect it | |
4d30e432 PA |
117 | test_complaint "call complaint (&symfile_complaints, \"short line 2\")" \ |
118 | "short line 2..." \ | |
119 | "short line 2" | |
54951bd7 | 120 | |
4d30e432 PA |
121 | gdb_test_stdio "call clear_complaints (&symfile_complaints, 1, 0)" \ |
122 | "\r\n" \ | |
123 | "" \ | |
124 | "short end" | |
54951bd7 AC |
125 | |
126 | return 0 | |
127 | } | |
128 | ||
9dd34b2b AC |
129 | # Check that nothing comes out when there haven't been any real |
130 | # complaints. Note that each test is really checking the previous | |
131 | # command. | |
132 | ||
133 | proc test_empty_complaint { cmd msg } { | |
134 | global gdb_prompt | |
4d30e432 PA |
135 | global inferior_spawn_id gdb_spawn_id |
136 | ||
137 | if {$gdb_spawn_id == $inferior_spawn_id} { | |
138 | gdb_test_no_output $cmd $msg | |
139 | } else { | |
140 | set seen_output 0 | |
141 | gdb_test_multiple $cmd $msg { | |
142 | -i $inferior_spawn_id -re "." { | |
143 | set seen_output 1 | |
144 | exp_continue | |
145 | } | |
146 | -i $gdb_spawn_id "$gdb_prompt $" { | |
147 | gdb_assert !$seen_output $msg | |
148 | } | |
9dd34b2b | 149 | } |
9dd34b2b | 150 | } |
9dd34b2b AC |
151 | } |
152 | ||
153 | proc test_empty_complaints { } { | |
154 | ||
38979823 | 155 | test_empty_complaint "call clear_complaints(&symfile_complaints,0,0)" \ |
9dd34b2b | 156 | "empty non-verbose non-noisy clear" |
38979823 | 157 | test_empty_complaint "call clear_complaints(&symfile_complaints,1,0)" \ |
9dd34b2b | 158 | "empty verbose non-noisy clear" |
38979823 | 159 | test_empty_complaint "call clear_complaints(&symfile_complaints,1,1)" \ |
9dd34b2b | 160 | "empty verbose noisy clear" |
38979823 | 161 | test_empty_complaint "call clear_complaints(&symfile_complaints,0,1)" \ |
9dd34b2b AC |
162 | "empty non-verbose noisy clear" |
163 | ||
164 | return 0 | |
165 | } | |
166 | ||
c95aea6b TT |
167 | do_self_tests captured_command_loop { |
168 | test_initial_complaints | |
169 | test_serial_complaints | |
170 | test_short_complaints | |
171 | test_empty_complaints | |
54951bd7 | 172 | } |