1 # Copyright 2015-2019 Free Software Foundation, Inc.
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.
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.
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/>.
16 # This file is part of the gdb testsuite.
18 # Test the operation of the "history remove-duplicates" option.
21 # Check that the previous history entry is ENTRY.
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"
29 # Send ^P followed by ^L.
42 # Foreach element ELT in THINGS, run the command "print $ELT", making sure that
43 # each invocation of "print" has a unique test name.
45 proc run_print_on_each_thing { things } {
48 foreach thing $things {
49 gdb_test "print $thing" "" "printing $thing (item #$index)"
57 # These tests require readline support.
58 if { ![readline_is_used] } {
59 unsupported "readline isn't used."
63 # By default the option is set to 0.
64 gdb_test "show history remove-duplicates" "is 0\\."
66 # Test the "unlimited" setting.
67 with_test_prefix "remove-duplicates=unlimited" {
70 gdb_test "set history remove-duplicates unlimited"
72 run_print_on_each_thing { 0 1 2 1 1 2 3 3 4 1 2 3 4 }
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"
82 # Test the "1" setting.
83 with_test_prefix "remove-duplicates=1" {
86 gdb_test "set history remove-duplicates 1"
88 run_print_on_each_thing { 0 1 0 2 2 1 }
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)"
98 # Test the "0" setting.
99 with_test_prefix "remove-duplicates=0" {
102 gdb_test "set history remove-duplicates 0"
104 run_print_on_each_thing { 0 0 1 1 }
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)"
113 # Test the "2" setting.
114 with_test_prefix "remove-duplicates=2" {
117 gdb_test "set history remove-duplicates 2"
119 run_print_on_each_thing { 1 2 0 2 0 }
121 check_prev_history_entry "print 0"
122 check_prev_history_entry "print 2"
123 check_prev_history_entry "print 1"