]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/testsuite/gdb.base/gdbhistsize-history.exp
Update copyright year range in all GDB files.
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.base / gdbhistsize-history.exp
CommitLineData
b811d2c2 1# Copyright 2015-2020 Free Software Foundation, Inc.
bc460514
PP
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 setting of "history size" via the GDBHISTSIZE environment variable
19
20
7e763b86
SL
21# We cannot expect remote hosts to see environment variables set on the
22# local machine.
23
24if { [is_remote host] } {
25 unsupported "can't set environment variables on remote host"
26 return -1
27}
28
bc460514
PP
29# Check that the history size is properly set to SIZE when the environment
30# variable ENV_VAR is set to GDBHISTSIZE.
31
32proc test_histsize_history_setting { histsize size { env_var "GDBHISTSIZE" } } {
33 global env
34
2d35e871
JK
35 save_vars { env(GDBHISTFILE) env(GDBHISTSIZE) env($env_var) } {
36 # These environment variables take precedence over whatever
37 # history size is set in .gdbinit. Make sure the former is not
38 # set.
39 unset -nocomplain env(GDBHISTFILE)
40 unset -nocomplain env(GDBHISTSIZE)
41
b6dafabf
PP
42 set env($env_var) $histsize
43
44 with_test_prefix "histsize=$histsize" {
45 gdb_exit
46 gdb_start
47
48 gdb_test "show history size" "The size of the command history is $size."
49
50 if { $size == "0" } {
51 gdb_test_no_output "show commands"
52 } elseif { $size != "1" } {
53 gdb_test "show commands" \
54 " . show history size\r\n . show commands"
55 }
56 }
bc460514
PP
57 }
58}
59
60test_histsize_history_setting "" "unlimited"
61test_histsize_history_setting "0" "0"
62test_histsize_history_setting "20" "20"
63test_histsize_history_setting " 20 " "20"
64test_histsize_history_setting "-5" "unlimited"
65
66# Test defaulting to 256 upon encountering a non-numeric GDBHISTSIZE.
67test_histsize_history_setting "not_an_integer" "256"
68test_histsize_history_setting "10zab" "256"
69test_histsize_history_setting "-5ab" "256"
70
71# A huge number (hopefully larger than INT_MAX)
72test_histsize_history_setting "99999999999999999999999999999999999" "unlimited"
73
74# We no longer read HISTSIZE
75test_histsize_history_setting "50" "256" "HISTSIZE"