Imported Upstream version 7.5
[platform/upstream/gdb.git] / gdb / testsuite / gdb.base / readline-ask.exp
1 # Copyright (C) 2011-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 set testfile readline-ask
17 set executable ${testfile}.x
18 set srcfile ${testfile}.c
19 set binfile ${objdir}/${subdir}/${executable}
20 set inputrc ${srcdir}/${subdir}/${testfile}.inputrc
21
22 if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" object {debug}] != "" } {
23     untested ${testfile}.exp
24     return -1
25 }
26
27 # INPUTRC gets reset for the next testfile.
28 setenv INPUTRC $inputrc
29 clean_restart ${executable}
30
31 gdb_test_no_output "set width 50"
32 gdb_test_no_output "set height 3"
33
34 set cmd "p symbol_0"
35 send_gdb "$cmd\t"
36 set test "bell for more message"
37 gdb_test_multiple "" $test {
38     -re "$cmd\007$" {
39         pass $test
40     }
41 }
42
43 send_gdb "\t"
44 set test "more message for 01 and 02"
45 gdb_test_multiple "" $test {
46     -re "^\r\nsymbol_01_length_40_____________________\r\nsymbol_02_length_40_____________________\r\n--More--$" {
47         pass $test
48     }
49     -re "$gdb_prompt " {
50         fail $test
51     }
52 }
53
54 # There get some VT100 characters printed.
55
56 send_gdb "\r"
57 set test "more message for 03"
58 gdb_test_multiple "" $test {
59     -re "\rsymbol_03_length_40_____________________\r\n--More--$" {
60         pass $test
61     }
62 }
63
64 # "$gdb_prompt $" will not match as $cmd gets output: $gdb_prompt p symbol_0
65 # And "$gdb_prompt p symbol_0" cannot be matched as the default "$gdb_prompt $"
66 # string from gdb_test_multiple could match earlier.
67
68 send_gdb "\r"
69 set test "more finish for 04"
70 gdb_test_multiple "" $test {
71     -re "\rsymbol_04_length_40_____________________\r\n$gdb_prompt " {
72         pass $test
73     }
74 }
75
76 gdb_test "foo" {No symbol "symbol_0foo" in current context\.} "abort more message"
77
78 set cmd "p symbol_"
79 send_gdb "$cmd\t"
80 set test "bell for ask message"
81 gdb_test_multiple "" $test {
82     -re "$cmd\007$" {
83         pass $test
84     }
85 }
86
87 send_gdb "\t"
88 set test "ask message"
89 gdb_test_multiple "" $test {
90     -re "^\r\nDisplay all 5 possibilities\\? \\(y or n\\)$" {
91         pass $test
92     }
93     -re "$gdb_prompt " {
94         fail $test
95         return 0
96     }
97 }
98
99 send_gdb "y"
100 set test "ask message for 01 and 02"
101 gdb_test_multiple "" $test {
102     -re "^\r\nsymbol_01_length_40_____________________\r\nsymbol_02_length_40_____________________\r\n--More--$" {
103         pass $test
104     }
105 }
106
107 # There get some VT100 characters printed.
108 # See the "$gdb_prompt " match like in "more finish for 04".
109
110 send_gdb "n"
111 set test "ask message no"
112 gdb_test_multiple "" $test {
113     -re "\r$gdb_prompt " {
114         pass $test
115     }
116 }
117
118 gdb_test "foo" {No symbol "symbol_foo" in current context\.} "abort ask message"