1# Copyright (C) 2011-2020 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
16standard_testfile .c
17set inputrc ${srcdir}/${subdir}/${testfile}.inputrc
18
19if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" object {debug}] != "" } {
20    untested "failed to compile"
21    return -1
22}
23
24# INPUTRC gets reset for the next testfile.
25setenv INPUTRC $inputrc
26clean_restart ${binfile}
27
28if { ![readline_is_used] } {
29    unsupported "completion doesn't work when readline isn't used."
30    return -1
31}
32
33gdb_test_no_output "set width 50"
34gdb_test_no_output "set height 3"
35
36set cmd "p symbol_0"
37send_gdb "$cmd\t"
38set test "bell for more message"
39gdb_test_multiple "" $test {
40    -re "$cmd\007$" {
41	pass $test
42    }
43}
44
45send_gdb "\t"
46set test "more message for 01 and 02"
47gdb_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
58send_gdb "\r"
59set test "more message for 03"
60gdb_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
70send_gdb "\r"
71set test "more finish for 04"
72gdb_test_multiple "" $test {
73    -re "\rsymbol_04_length_40_____________________\r\n$gdb_prompt " {
74	pass $test
75    }
76}
77
78gdb_test "foo" {No symbol "symbol_0foo" in current context\.} "abort more message"
79
80set cmd "p symbol_"
81send_gdb "$cmd\t"
82set test "bell for ask message"
83gdb_test_multiple "" $test {
84    -re "$cmd\007$" {
85	pass $test
86    }
87}
88
89send_gdb "\t"
90set test "ask message"
91gdb_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
101send_gdb "y"
102set test "ask message for 01 and 02"
103gdb_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
112send_gdb "n"
113set test "ask message no"
114gdb_test_multiple "" $test {
115    -re "\r$gdb_prompt " {
116	pass $test
117    }
118}
119
120gdb_test "foo" {No symbol "symbol_foo" in current context\.} "abort ask message"
121