blob: d604d029974a86809ec6fff90e1a2db5765de2ec (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
|
# Copyright (C) 2022 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# This test script checks how GDB handles exiting with ctrl-d.
# Start GDB, and then close it by sendig ctrl-d. Check that the
# string 'quit' appears where we expect it too.
proc run_test {} {
clean_restart
# The gdb_start call above swallows the GDB prompt, and we want
# the prompt for the test below.
#
# Send a newline character, which will cause GDB to redisplay the
# prompt.
send_gdb "\n"
gdb_test_multiple "" "discard newline" {
-re "^\r\n" {
}
}
# Send GDB a ctrl-d. Check that we see the 'quit' string in the
# expected place.
send_gdb "\004"
gdb_test_multiple "" "close GDB with eof" {
-re "$::gdb_prompt \[^\n\]*\r\[^\n\]*quit" {
fail "$gdb_test_name (misplaced \\r)"
}
-re "$::gdb_prompt \[^\n\]*\r\[^\n\]*\r\nquit\r\n" {
# For versions of readline that don't include the
# RL_STATE_EOF patch, then the 'quit' is printed on the
# subsequent line.
kfail gdb/28833 "$gdb_test_name (older version of readline)"
}
-re "$::gdb_prompt quit\[^\n\]*\r\n\[^\n\]*\r\n$" {
# There was a bug where GDB would print an extra blank
# line after the 'quit', this catches that case.
fail $gdb_test_name
}
-re "$::gdb_prompt quit\[^\n\]*\r\n\[^\n\]*$" {
pass $gdb_test_name
}
eof {
fail "$gdb_test_name (missed the prompt)"
}
}
}
with_test_prefix "default" {
run_test
}
save_vars { env(TERM) } {
setenv TERM ansi
with_test_prefix "with non-dump terminal" {
run_test
save_vars { env(INPUTRC) } {
# Create an inputrc file that turns bracketed paste mode
# on. This is usually turned off (see lib/gdb.exp), but
# for the next test we want to see what happens with this
# on.
set inputrc [standard_output_file inputrc]
set fd [open "$inputrc" w]
puts $fd "set enable-bracketed-paste on"
close $fd
setenv INPUTRC "$inputrc"
with_test_prefix "with bracketed-paste-mode on" {
run_test
}
}
}
}
|