Move mkdir_recursive to common/filestuff.c
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.gdb / complaints.exp
1 # Copyright 2002-2018 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 # Similar to gdb_test_stdio, except no \r\n is expected before
28 # $gdb_prompt in the $gdb_spawn_id.
29
30 proc test_complaint {test inferior_io_re msg} {
31 global inferior_spawn_id gdb_spawn_id
32 global gdb_prompt
33
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 { } {
57 # Unsupress complaints
58 gdb_test "set stop_whining = 2"
59
60 gdb_test_no_output "set var \$cstr = \"Register a complaint\""
61
62 # Prime the system
63 gdb_test_stdio \
64 "call complaint_internal (\$cstr)" \
65 "During symbol reading: Register a complaint"
66
67 # Re-issue the first message #1
68 gdb_test_stdio \
69 "call complaint_internal (\$cstr)" \
70 "During symbol reading: Register a complaint"
71
72 # Add a second complaint, expect it
73 gdb_test_stdio \
74 "call complaint_internal (\"Testing! Testing! Testing!\")" \
75 "During symbol reading: Testing. Testing. Testing."
76
77 return 0
78 }
79
80 # Check that nothing comes out when there haven't been any real
81 # complaints. Note that each test is really checking the previous
82 # command.
83
84 proc test_empty_complaint { cmd msg } {
85 global gdb_prompt
86 global inferior_spawn_id gdb_spawn_id
87
88 if {$gdb_spawn_id == $inferior_spawn_id} {
89 gdb_test_no_output $cmd $msg
90 } else {
91 set seen_output 0
92 gdb_test_multiple $cmd $msg {
93 -i $inferior_spawn_id -re "." {
94 set seen_output 1
95 exp_continue
96 }
97 -i $gdb_spawn_id "$gdb_prompt $" {
98 gdb_assert !$seen_output $msg
99 }
100 }
101 }
102 }
103
104 proc test_empty_complaints { } {
105
106 test_empty_complaint "call clear_complaints()" \
107 "clear complaints"
108
109 return 0
110 }
111
112 do_self_tests captured_command_loop {
113 test_initial_complaints
114 test_empty_complaints
115 }
This page took 0.031578 seconds and 4 git commands to generate.