Imported Upstream version 7.5
[platform/upstream/gdb.git] / gdb / testsuite / gdb.base / async.exp
1 #   Copyright 1999, 2007-2012 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 set testfile "async"
22 set srcfile ${testfile}.c
23 set binfile ${objdir}/${subdir}/${testfile}
24
25 if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug nowarnings}] != "" } {
26     untested async.exp
27     return -1
28 }
29
30 if [get_compiler_info] {
31     return -1
32 }
33
34 ########################################
35 ##
36 ## Don't do any of these tests until we reach consensus on this file.
37 ##
38 return 0
39 ########################################
40
41 set board [target_info name]
42 set current_target [target_info gdb_protocol]
43 if { $current_target == "remote" } {
44   unset_board_info "gdb_protocol"
45   set_board_info "gdb_protocol" "async"
46   } else {
47       return 0
48   }
49
50 gdb_exit
51 gdb_start
52 gdb_reinitialize_dir $srcdir/$subdir
53 gdb_load ${binfile}
54
55 #
56 # set it up at a breakpoint so we can play with it
57 #
58 if ![runto_main] then {
59     perror "couldn't run to breakpoint"
60     continue
61 }
62
63 gdb_test "break baz" ".*" ""
64
65 #
66 # Make sure we get a 'completed' message when the target is done.
67 #
68 gdb_test "set display-exec-done on" ".*" ""
69
70
71 send_gdb "next&\n" 
72 gdb_expect {
73     -re "^next&\r\n$gdb_prompt.*z = 9.*completed\.\r\n" { pass "next &" }
74     -re "$gdb_prompt.*completed\.$" { fail "next &" }
75     timeout  { fail "(timeout) next &" }
76 }
77
78 send_gdb "step&\n" 
79 gdb_expect {
80     -re "^step&\r\n$gdb_prompt.*y = foo \\(\\).*completed\.\r\n" { pass "step &" }
81     -re "$gdb_prompt.*completed\.$" { fail "step &" }
82     timeout  { fail "(timeout) step &" }
83 }
84
85 send_gdb "step&\n" 
86 gdb_expect {
87     -re "^step&\r\n$gdb_prompt foo \\(\\) at .*async.c.*x = 5.*completed\.\r\n" \
88             { pass "step &" }
89     -re "$gdb_prompt.*completed\.$" { fail "step &" }
90     timeout  { fail "(timeout) step &" }
91 }
92
93 send_gdb "stepi&\n" 
94 gdb_expect {
95     -re "^stepi&\r\n$gdb_prompt.*$hex.*x = 5.*completed\.\r\n" { pass "stepi &" }
96     -re "$gdb_prompt.*completed\.$" { fail "stepi &" }
97     timeout  { fail "(timeout) stepi &" }
98 }
99
100 send_gdb "nexti&\n" 
101 gdb_expect {
102     -re "^nexti&\r\n$gdb_prompt.*y = 3.*completed\.\r\n" { pass "nexti &" }
103     -re "$gdb_prompt.*completed\.$" { fail "nexti &" }
104     timeout  { fail "(timeout) nexti &" }
105 }
106
107 send_gdb "finish&\n" 
108 gdb_expect {
109     -re "^finish&\r\nRun till exit from #0  foo \\(\\) at.*async.c.*\r\n$gdb_prompt.*$hex in main \\(\\) at.*async.c.*y = foo \\(\\).*Value returned is.*= 8.*completed\.\r\n" \
110             { pass "finish &" }
111     -re "$gdb_prompt.*completed\.$" { fail "finish &" }
112     timeout  { fail "(timeout) finish &" }
113 }
114
115 send_gdb "jump 33&\n" 
116 gdb_expect {
117     -re "^jump 33&.*Continuing at $hex.*$gdb_prompt.*Breakpoint 2, baz \\(\\) at.*async.c.*return 5.*completed\.\r\n" \
118             { pass "jump &" }
119     -re ".*$gdb_prompt.*completed\.$" { fail "jump &" }
120     timeout  { fail "(timeout) jump &" }
121 }
122
123 send_gdb "until 35&\n" 
124 gdb_expect {
125     -re "^until 35&.*$gdb_prompt.*$hex in main \\(\\) at.*async.c.*y = baz \\(\\).*completed\.\r\n" \
126             { pass "until &" }
127     -re "$gdb_prompt.*completed\.$" { fail "until &" }
128     timeout  { fail "(timeout) until &" }
129 }
130
131 gdb_test "set display-exec-done off" ".*" ""
132
133 unset_board_info "gdb_protocol"
134 set_board_info "gdb_protocol" "remote"
135
136
137
138
139
140