valgrind-infcall.exp revision 1.8
1# Copyright 2012-2019 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
16load_lib valgrind.exp
17
18if [is_remote target] {
19    # The test always runs locally.
20    return 0
21}
22
23standard_testfile .c
24if {[build_executable $testfile.exp $testfile $srcfile {debug}] == -1} {
25    return -1
26}
27
28if { [vgdb_start] == -1 } {
29    return -1
30}
31
32set continue_count 1
33set loop 1
34while {$loop && $continue_count < 100} {
35    set test "continue #$continue_count"
36    gdb_test_multiple "continue" "" {
37	-re "Invalid free\\(\\).*: main .*\r\n$gdb_prompt $" {
38	    pass $test
39	    set loop 0
40	}
41	-re "Remote connection closed.*\r\n$gdb_prompt $" {
42	    fail "$test (remote connection closed)"
43	    # Only if valgrind got stuck.
44	    kill_wait_spawned_process $valgrind_spawn_id
45	    return -1
46	}
47	-re "The program is not being run\\.\r\n$gdb_prompt $" {
48	    fail "$test (valgrind vgdb has terminated)"
49	    # Only if valgrind got stuck.
50	    kill_wait_spawned_process $valgrind_spawn_id
51	    return -1
52	}
53	-re "\r\n$gdb_prompt $" {
54	    pass "$test (false warning)"
55	}
56    }
57    set continue_count [expr $continue_count + 1]
58}
59
60set test "p gdb_test_infcall ()"
61gdb_test_multiple $test $test {
62    -re "unhandled instruction bytes.*\r\n$gdb_prompt $" {
63	fail $test
64    }
65    -re "Continuing \\.\\.\\..*\r\n\\\$1 = 2\r\n$gdb_prompt $" {
66	pass $test
67    }
68}
69
70vgdb_stop
71