Commit | Line | Data |
---|---|---|
5fdf6324 AB |
1 | # Copyright (C) 2016 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 | standard_testfile | |
17 | ||
18 | if {[prepare_for_testing $testfile.exp $testfile $srcfile debug]} { | |
19 | untested $testfile.exp | |
20 | return -1 | |
21 | } | |
22 | ||
23 | if ![runto_main] then { | |
bc6c7af4 | 24 | fail "can't run to main" |
5fdf6324 AB |
25 | return 0 |
26 | } | |
27 | ||
28 | # Run "show max-value-size" and return the interesting bit of the | |
29 | # result. This is either the maximum size in bytes, or the string | |
30 | # "unlimited". | |
31 | proc get_max_value_size {} { | |
32 | global gdb_prompt | |
33 | global decimal | |
34 | ||
35 | gdb_test_multiple "show max-value-size" "" { | |
36 | -re "Maximum value size is ($decimal) bytes.*$gdb_prompt $" { | |
37 | return $expect_out(1,string) | |
38 | } | |
39 | -re "Maximum value size is unlimited.*$gdb_prompt $" { | |
40 | return "unlimited" | |
41 | } | |
42 | } | |
43 | } | |
44 | ||
45 | # Assuming that MAX_VALUE_SIZE is the current value for | |
46 | # max-value-size, print the test values. Use TEST_PREFIX to make the | |
47 | # test names unique. | |
48 | proc do_value_printing { max_value_size test_prefix } { | |
49 | with_test_prefix ${test_prefix} { | |
50 | gdb_test "p/d one" " = 0" | |
51 | if { $max_value_size != "unlimited" && $max_value_size < 100 } then { | |
52 | gdb_test "p/d one_hundred" \ | |
53 | "value requires 100 bytes, which is more than max-value-size" | |
54 | } else { | |
55 | gdb_test "p/d one_hundred" " = \\{0 <repeats 100 times>\\}" | |
56 | } | |
57 | gdb_test "p/d one_hundred \[99\]" " = 0" | |
58 | } | |
59 | } | |
60 | ||
61 | # Install SET_VALUE as the value for max-value-size, then print the | |
62 | # test values. | |
63 | proc set_and_check_max_value_size { set_value } { | |
64 | if { $set_value == "unlimited" } then { | |
65 | set check_pattern "unlimited" | |
66 | } else { | |
67 | set check_pattern "${set_value} bytes" | |
68 | } | |
69 | ||
70 | gdb_test_no_output "set max-value-size ${set_value}" | |
71 | gdb_test "show max-value-size" \ | |
72 | "Maximum value size is ${check_pattern}." \ | |
73 | "check that the value shows as ${check_pattern}" | |
74 | ||
75 | do_value_printing ${set_value} "max-value-size is '${set_value}'" | |
76 | } | |
77 | ||
78 | # Check the default value is sufficient. | |
79 | do_value_printing [get_max_value_size] "using initial max-value-size" | |
80 | ||
81 | # Check some values for max-value-size that should prevent some | |
82 | # allocations. | |
83 | set_and_check_max_value_size 25 | |
84 | set_and_check_max_value_size 99 | |
85 | ||
86 | # Check values for max-value-size that should allow all allocations. | |
87 | set_and_check_max_value_size 100 | |
88 | set_and_check_max_value_size 200 | |
89 | set_and_check_max_value_size "unlimited" | |
90 | ||
91 | # Check that we can't set the maximum size stupidly low. | |
92 | gdb_test "set max-value-size 1" \ | |
93 | "max-value-size set too low, increasing to \[0-9\]+ bytes" | |
94 | gdb_test "set max-value-size 0" \ | |
95 | "max-value-size set too low, increasing to \[0-9\]+ bytes" | |
96 | gdb_test "set max-value-size -5" \ | |
97 | "only -1 is allowed to set as unlimited" |