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 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117
|
# Copyright 2015 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 file is part of the gdb testsuite.
# Test the operation of the "history remove-duplicates" option.
# Check that the previous history entry is ENTRY.
proc check_prev_history_entry { entry { test_suffix "" } } {
set test_name "history entry is $entry"
if { $test_suffix != "" } {
append test_name " $test_suffix"
}
# Send ^P followed by ^L.
send_gdb "\x10\x0c"
gdb_expect {
-re $entry {
pass $test_name
}
timeout {
fail $test_name
}
}
}
# Foreach element ELT in THINGS, run the command "print $ELT", making sure that
# each invocation of "print" has a unique test name.
proc run_print_on_each_thing { things } {
set index 0
foreach thing $things {
gdb_test "print $thing" "" "printing $thing (item #$index)"
incr index
}
}
# By default the option is set to 0.
gdb_exit
gdb_start
gdb_test "show history remove-duplicates" "is 0\\."
# Test the "unlimited" setting.
with_test_prefix "remove-duplicates=unlimited" {
gdb_exit
gdb_start
gdb_test "set history remove-duplicates unlimited"
run_print_on_each_thing { 0 1 2 1 1 2 3 3 4 1 2 3 4 }
check_prev_history_entry "print 4"
check_prev_history_entry "print 3"
check_prev_history_entry "print 2"
check_prev_history_entry "print 1"
check_prev_history_entry "print 0"
}
# Test the "1" setting.
with_test_prefix "remove-duplicates=1" {
gdb_exit
gdb_start
gdb_test "set history remove-duplicates 1"
run_print_on_each_thing { 0 1 0 2 2 1 }
check_prev_history_entry "print 1"
check_prev_history_entry "print 2"
check_prev_history_entry "print 0"
check_prev_history_entry "print 1" "(again)"
check_prev_history_entry "print 0" "(again)"
}
# Test the "0" setting.
with_test_prefix "remove-duplicates=0" {
gdb_exit
gdb_start
gdb_test "set history remove-duplicates 0"
run_print_on_each_thing { 0 0 1 1 }
check_prev_history_entry "print 1"
check_prev_history_entry "print 1" "(again)"
check_prev_history_entry "print 0"
check_prev_history_entry "print 0" "(again)"
}
# Test the "2" setting.
with_test_prefix "remove-duplicates=2" {
gdb_exit
gdb_start
gdb_test "set history remove-duplicates 2"
run_print_on_each_thing { 1 2 0 2 0 }
check_prev_history_entry "print 0"
check_prev_history_entry "print 2"
check_prev_history_entry "print 1"
}
|