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