]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/testsuite/gdb.base/async.exp
gdb.base/async.exp: Factor out test pattern to a procedure.
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.base / async.exp
1 # Copyright 1999-2014 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
17 #
18 # test running programs
19 #
20
21 standard_testfile
22
23 ########################################
24 ##
25 ## Don't do any of these tests until we reach consensus on this file.
26 ##
27 return 0
28 ########################################
29
30 if {[prepare_for_testing $testfile.exp $testfile $srcfile debug]} {
31 untested $testfile.exp
32 return -1
33 }
34
35 gdb_test_no_output "set target-async on"
36
37 #
38 # set it up at a breakpoint so we can play with it
39 #
40 if ![runto_main] then {
41 perror "couldn't run to breakpoint"
42 continue
43 }
44
45 gdb_test "break baz" ".*" ""
46
47 #
48 # Make sure we get a 'completed' message when the target is done.
49 #
50 gdb_test_no_output "set exec-done-display on"
51
52 # Test a background execution command. COMMAND is the command to
53 # send. BEFORE_PROMPT is the pattern expected before the GDB prompt
54 # is output. AFTER_PROMPT is the pattern expected after the prompt
55 # and before "completed". MESSAGE is optional, and is the pass/fail
56 # message to br printed. If omitted, then the command string is used
57 # as message.
58 proc test_background {command before_prompt after_prompt {message ""}} {
59 global gdb_prompt
60
61 if {$message eq ""} {
62 set message $command
63 }
64
65 send_gdb "$command\n"
66 gdb_expect {
67 -re "^$command\r\n${before_prompt}${gdb_prompt}${after_prompt}completed\.\r\n" {
68 pass "$message"
69 }
70 -re "$gdb_prompt.*completed\.$" {
71 fail "$message"
72 }
73 timeout {
74 fail "$message (timeout)"
75 }
76 }
77 }
78
79 test_background "next&" "" ".*z = 9.*"
80
81 test_background "step&" "" ".*y = foo \\(\\).*"
82
83 test_background "step&" "" " foo \\(\\) at .*async.c.*x = 5.*"
84
85 test_background "stepi&" "" ".*$hex.*x = 5.*"
86
87 test_background "nexti&" "" ".*y = 3.*"
88
89 test_background "finish&" \
90 "Run till exit from #0 foo \\(\\) at.*async.c.*\r\n" \
91 ".*$hex in main \\(\\) at.*async.c.*y = foo \\(\\).*Value returned is.*= 8.*"
92
93 set jump_here [gdb_get_line_number "jump here"]
94 test_background "jump $jump_here&" \
95 ".*Continuing at $hex.*" \
96 ".*Breakpoint 2, baz \\(\\) at.*async.c.*return 5.*" \
97 "jump&"
98
99 set until_here [gdb_get_line_number "until here"]
100 test_background "until $until_here&" \
101 ".*" \
102 ".*$hex in main \\(\\) at.*async.c.*y = baz \\(\\).*" \
103 "until&"
104
105 gdb_test_no_output "set exec-done-display off"