]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/testsuite/gdb.base/history-duplicates.exp
update copyright year range in GDB files
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.base / history-duplicates.exp
1 # Copyright 2015-2017 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 # This file is part of the gdb testsuite.
17
18 # Test the operation of the "history remove-duplicates" option.
19
20
21 # Check that the previous history entry is ENTRY.
22
23 proc check_prev_history_entry { entry { test_suffix "" } } {
24 set test_name "history entry is $entry"
25 if { $test_suffix != "" } {
26 append test_name " $test_suffix"
27 }
28
29 # Send ^P followed by ^L.
30 send_gdb "\x10\x0c"
31
32 gdb_expect {
33 -re $entry {
34 pass $test_name
35 }
36 timeout {
37 fail $test_name
38 }
39 }
40 }
41
42 # Foreach element ELT in THINGS, run the command "print $ELT", making sure that
43 # each invocation of "print" has a unique test name.
44
45 proc run_print_on_each_thing { things } {
46 set index 0
47
48 foreach thing $things {
49 gdb_test "print $thing" "" "printing $thing (item #$index)"
50 incr index
51 }
52 }
53
54 gdb_exit
55 gdb_start
56
57 # These tests require readline support.
58 if { ![readline_is_used] } {
59 unsupported "readline isn't used."
60 return -1
61 }
62
63 # By default the option is set to 0.
64 gdb_test "show history remove-duplicates" "is 0\\."
65
66 # Test the "unlimited" setting.
67 with_test_prefix "remove-duplicates=unlimited" {
68 gdb_exit
69 gdb_start
70 gdb_test "set history remove-duplicates unlimited"
71
72 run_print_on_each_thing { 0 1 2 1 1 2 3 3 4 1 2 3 4 }
73
74 check_prev_history_entry "print 4"
75 check_prev_history_entry "print 3"
76 check_prev_history_entry "print 2"
77 check_prev_history_entry "print 1"
78 check_prev_history_entry "print 0"
79 }
80
81
82 # Test the "1" setting.
83 with_test_prefix "remove-duplicates=1" {
84 gdb_exit
85 gdb_start
86 gdb_test "set history remove-duplicates 1"
87
88 run_print_on_each_thing { 0 1 0 2 2 1 }
89
90 check_prev_history_entry "print 1"
91 check_prev_history_entry "print 2"
92 check_prev_history_entry "print 0"
93 check_prev_history_entry "print 1" "(again)"
94 check_prev_history_entry "print 0" "(again)"
95 }
96
97
98 # Test the "0" setting.
99 with_test_prefix "remove-duplicates=0" {
100 gdb_exit
101 gdb_start
102 gdb_test "set history remove-duplicates 0"
103
104 run_print_on_each_thing { 0 0 1 1 }
105
106 check_prev_history_entry "print 1"
107 check_prev_history_entry "print 1" "(again)"
108 check_prev_history_entry "print 0"
109 check_prev_history_entry "print 0" "(again)"
110 }
111
112
113 # Test the "2" setting.
114 with_test_prefix "remove-duplicates=2" {
115 gdb_exit
116 gdb_start
117 gdb_test "set history remove-duplicates 2"
118
119 run_print_on_each_thing { 1 2 0 2 0 }
120
121 check_prev_history_entry "print 0"
122 check_prev_history_entry "print 2"
123 check_prev_history_entry "print 1"
124 }