binutils-gdb/gdb/testsuite/gdb.base/radix.exp

192 lines
6.9 KiB
Plaintext
Raw Normal View History

# This testcase is part of GDB, the GNU debugger.
# Copyright 1993-2019 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 was written by Fred Fish. (fnf@cygnus.com)
# And rewritten by Michael Chastain (mec.gnu@mindspring.com)
# Start with a fresh gdb.
gdb_exit
gdb_start
# Test input radices.
proc test_one_input { iradix input output } {
gdb_test "print $input" "$output" \
"print $input; expect $output; input radix $iradix"
}
proc test_input_radix { iradix iradixhex iradixoctal } {
# set input-radix = $iradix, output-radix = ten
gdb_test "set radix" \
"Input and output radices now set to decimal 10, hex a, octal 12." \
"initialize radix, input radix $iradix"
gdb_test "set input-radix $iradix" \
"Input radix now set to decimal $iradix, hex $iradixhex, octal $iradixoctal."
if { $iradix == 10 } then {
gdb_test "show radix" \
"Input and output radices set to decimal 10, hex a, octal 12." \
"show radix, input radix $iradix"
} else {
gdb_test "show radix" \
"Input radix set to decimal $iradix, hex $iradixhex, octal $iradixoctal.\r\nOutput radix set to decimal 10, hex a, octal 12." \
"show radix, input radix $iradix"
}
# test constants with specific bases that do not use $iradix
test_one_input $iradix "010" "8"
test_one_input $iradix "20." "20"
test_one_input $iradix "(int) 20." "20"
test_one_input $iradix "0xf" "15"
# test simple one-digit constants
test_one_input $iradix "0" "0"
test_one_input $iradix "1" "1"
test_one_input $iradix "-1" "-1"
# test simple two-digit constants
test_one_input $iradix "10" [expr $iradix]
test_one_input $iradix "11" [expr $iradix + 1]
test_one_input $iradix "-10" [expr 0 - $iradix]
test_one_input $iradix "-11" [expr 0 - $iradix - 1]
# test simple three-digit constants
test_one_input $iradix "100" [expr $iradix * $iradix]
test_one_input $iradix "101" [expr $iradix * $iradix + 1]
test_one_input $iradix "-100" [expr 0 - $iradix * $iradix]
test_one_input $iradix "-101" [expr 0 - $iradix * $iradix - 1]
# test a five-digit constant
test_one_input $iradix "10101" \
[expr $iradix * $iradix * $iradix * $iradix + $iradix * $iradix + 1]
}
test_input_radix 2 "2" "2"
test_one_input 2 "4" "Invalid number \"4\"\\."
test_one_input 2 "-2" "Invalid number \"2\"\\."
test_input_radix 3 "3" "3"
test_one_input 3 "2" "2"
test_one_input 3 "20" "6"
test_one_input 3 "3" "Invalid number \"3\"\\."
test_one_input 2 "30" "Invalid number \"30\"\\."
test_input_radix 8 "8" "10"
test_one_input 8 "20" "16"
test_one_input 8 "-20" "-16"
test_one_input 8 "8" "Invalid number \"8\"."
test_one_input 8 "-9" "Invalid number \"9\"."
test_input_radix 10 "a" "12"
test_one_input 10 "-12" "-12"
test_input_radix 16 "10" "20"
# Test output radices.
proc test_one_output { oradix input output } {
gdb_test "print $input" "$output" \
"print $input; expect $output; output radix $oradix"
}
proc test_output_radix { oradix oradixhex oradixoctal } {
# set input-radix = ten, output-radix = $oradix
gdb_test "set radix" \
"Input and output radices now set to decimal 10, hex a, octal 12." \
"initialize radix, output radix $oradix"
gdb_test "set output-radix $oradix" \
"Output radix now set to decimal $oradix, hex $oradixhex, octal $oradixoctal."
if { $oradix == 10 } then {
gdb_test "show radix" \
"Input and output radices set to decimal 10, hex a, octal 12." \
"show radix, output radix $oradix"
} else {
gdb_test "show radix" \
"Input radix set to decimal 10, hex a, octal 12.\r\nOutput radix set to decimal $oradix, hex $oradixhex, octal $oradixoctal." \
"show radix, output radix $oradix"
}
# no standard tests for output radix
}
test_output_radix 8 "8" "10"
test_one_output 8 "010" "010"
test_one_output 8 "0xf" "17"
test_one_output 8 "10" "12"
test_one_output 8 "100" "144"
setup_kfail "gdb/1715" *-*-*
test_one_output 8 "20." "24"
test_one_output 8 "(int) 20." "24"
test_output_radix 10 "a" "12"
test_one_output 10 "010" "8"
test_one_output 10 "0xf" "15"
test_one_output 10 "10" "10"
test_one_output 10 "100" "100"
test_one_output 10 "20." "20"
test_one_output 10 "(int) 20." "20"
test_output_radix 16 "10" "20"
test_one_output 16 "010" "8"
test_one_output 16 "0xf" "f"
test_one_output 16 "10" "a"
test_one_output 16 "100" "64"
setup_kfail "gdb/1715" *-*-*
test_one_output 16 "20." "14"
test_one_output 16 "(int) 20." "14"
# Test rejecting invalid input radices and unsupported output radices
# really rejects the radices, instead of just claiming so (PR 7536).
gdb_test "set radix" \
"Input and output radices now set to decimal 10, hex a, octal 12\." \
Fix test names starting with uppercase using multi-line gdb_test/mi_gdb_test This fixes offender testcases that have test names starting with uppercase when using gdb_test/mi_gdb_test in a multi-line construct. gdb/testsuite/ChangeLog 2016-12-01 Luis Machado <lgustavo@codesourcery.com> Fix test names starting with uppercase throughout the files. * gdb.ada/array_return.exp * gdb.ada/expr_delims.exp * gdb.ada/mi_dyn_arr.exp * gdb.ada/mi_interface.exp * gdb.ada/mi_var_array.exp * gdb.ada/watch_arg.exp * gdb.arch/alpha-step.exp * gdb.arch/altivec-regs.exp * gdb.arch/e500-regs.exp * gdb.arch/powerpc-d128-regs.exp * gdb.base/arrayidx.exp * gdb.base/break.exp * gdb.base/checkpoint.exp * gdb.base/debug-expr.exp * gdb.base/dmsym.exp * gdb.base/radix.exp * gdb.base/sepdebug.exp * gdb.base/testenv.exp * gdb.base/watch_thread_num.exp * gdb.base/watchpoint-cond-gone.exp * gdb.cell/break.exp * gdb.cell/ea-cache.exp * gdb.compile/compile.exp * gdb.cp/gdb2495.exp * gdb.gdb/selftest.exp * gdb.gdb/xfullpath.exp * gdb.go/hello.exp * gdb.go/integers.exp * gdb.objc/basicclass.exp * gdb.pascal/hello.exp * gdb.pascal/integers.exp * gdb.python/py-breakpoint.exp * gdb.python/py-cmd.exp * gdb.python/py-linetable.exp * gdb.python/py-xmethods.exp * gdb.python/python.exp * gdb.reverse/consecutive-precsave.exp * gdb.reverse/finish-precsave.exp * gdb.reverse/i386-precsave.exp * gdb.reverse/machinestate-precsave.exp * gdb.reverse/sigall-precsave.exp * gdb.reverse/solib-precsave.exp * gdb.reverse/step-precsave.exp * gdb.reverse/until-precsave.exp * gdb.reverse/watch-precsave.exp * gdb.threads/leader-exit.exp * gdb.threads/pthreads.exp * gdb.threads/wp-replication.exp * gdb.trace/actions.exp * gdb.trace/mi-tsv-changed.exp * gdb.trace/tsv.exp
2016-12-02 04:44:38 +08:00
"reset radices"
gdb_test "set input-radix 0" \
"Nonsense input radix ``decimal 0''; input radix unchanged\\." \
"Reject input-radix 0"
gdb_test "show input-radix" \
"Default input radix for entering numbers is 10\\." \
Fix test names starting with uppercase using multi-line gdb_test/mi_gdb_test This fixes offender testcases that have test names starting with uppercase when using gdb_test/mi_gdb_test in a multi-line construct. gdb/testsuite/ChangeLog 2016-12-01 Luis Machado <lgustavo@codesourcery.com> Fix test names starting with uppercase throughout the files. * gdb.ada/array_return.exp * gdb.ada/expr_delims.exp * gdb.ada/mi_dyn_arr.exp * gdb.ada/mi_interface.exp * gdb.ada/mi_var_array.exp * gdb.ada/watch_arg.exp * gdb.arch/alpha-step.exp * gdb.arch/altivec-regs.exp * gdb.arch/e500-regs.exp * gdb.arch/powerpc-d128-regs.exp * gdb.base/arrayidx.exp * gdb.base/break.exp * gdb.base/checkpoint.exp * gdb.base/debug-expr.exp * gdb.base/dmsym.exp * gdb.base/radix.exp * gdb.base/sepdebug.exp * gdb.base/testenv.exp * gdb.base/watch_thread_num.exp * gdb.base/watchpoint-cond-gone.exp * gdb.cell/break.exp * gdb.cell/ea-cache.exp * gdb.compile/compile.exp * gdb.cp/gdb2495.exp * gdb.gdb/selftest.exp * gdb.gdb/xfullpath.exp * gdb.go/hello.exp * gdb.go/integers.exp * gdb.objc/basicclass.exp * gdb.pascal/hello.exp * gdb.pascal/integers.exp * gdb.python/py-breakpoint.exp * gdb.python/py-cmd.exp * gdb.python/py-linetable.exp * gdb.python/py-xmethods.exp * gdb.python/python.exp * gdb.reverse/consecutive-precsave.exp * gdb.reverse/finish-precsave.exp * gdb.reverse/i386-precsave.exp * gdb.reverse/machinestate-precsave.exp * gdb.reverse/sigall-precsave.exp * gdb.reverse/solib-precsave.exp * gdb.reverse/step-precsave.exp * gdb.reverse/until-precsave.exp * gdb.reverse/watch-precsave.exp * gdb.threads/leader-exit.exp * gdb.threads/pthreads.exp * gdb.threads/wp-replication.exp * gdb.trace/actions.exp * gdb.trace/mi-tsv-changed.exp * gdb.trace/tsv.exp
2016-12-02 04:44:38 +08:00
"input radix unchanged after rejecting 0"
gdb_test "set input-radix 1" \
"Nonsense input radix ``decimal 1''; input radix unchanged\\." \
"Reject input-radix 1"
gdb_test "show input-radix" \
"Default input radix for entering numbers is 10\\." \
Fix test names starting with uppercase using multi-line gdb_test/mi_gdb_test This fixes offender testcases that have test names starting with uppercase when using gdb_test/mi_gdb_test in a multi-line construct. gdb/testsuite/ChangeLog 2016-12-01 Luis Machado <lgustavo@codesourcery.com> Fix test names starting with uppercase throughout the files. * gdb.ada/array_return.exp * gdb.ada/expr_delims.exp * gdb.ada/mi_dyn_arr.exp * gdb.ada/mi_interface.exp * gdb.ada/mi_var_array.exp * gdb.ada/watch_arg.exp * gdb.arch/alpha-step.exp * gdb.arch/altivec-regs.exp * gdb.arch/e500-regs.exp * gdb.arch/powerpc-d128-regs.exp * gdb.base/arrayidx.exp * gdb.base/break.exp * gdb.base/checkpoint.exp * gdb.base/debug-expr.exp * gdb.base/dmsym.exp * gdb.base/radix.exp * gdb.base/sepdebug.exp * gdb.base/testenv.exp * gdb.base/watch_thread_num.exp * gdb.base/watchpoint-cond-gone.exp * gdb.cell/break.exp * gdb.cell/ea-cache.exp * gdb.compile/compile.exp * gdb.cp/gdb2495.exp * gdb.gdb/selftest.exp * gdb.gdb/xfullpath.exp * gdb.go/hello.exp * gdb.go/integers.exp * gdb.objc/basicclass.exp * gdb.pascal/hello.exp * gdb.pascal/integers.exp * gdb.python/py-breakpoint.exp * gdb.python/py-cmd.exp * gdb.python/py-linetable.exp * gdb.python/py-xmethods.exp * gdb.python/python.exp * gdb.reverse/consecutive-precsave.exp * gdb.reverse/finish-precsave.exp * gdb.reverse/i386-precsave.exp * gdb.reverse/machinestate-precsave.exp * gdb.reverse/sigall-precsave.exp * gdb.reverse/solib-precsave.exp * gdb.reverse/step-precsave.exp * gdb.reverse/until-precsave.exp * gdb.reverse/watch-precsave.exp * gdb.threads/leader-exit.exp * gdb.threads/pthreads.exp * gdb.threads/wp-replication.exp * gdb.trace/actions.exp * gdb.trace/mi-tsv-changed.exp * gdb.trace/tsv.exp
2016-12-02 04:44:38 +08:00
"input radix unchanged after rejecting 1"
gdb_test "set output-radix 0" \
"Unsupported output radix ``decimal 0''; output radix unchanged\\." \
"Reject output-radix 0"
gdb_test "show output-radix" \
"Default output radix for printing of values is 10\\." \
"Output radix unchanged after rejecting 0"
gdb_test "set output-radix 1" \
"Unsupported output radix ``decimal 1''; output radix unchanged\\." \
"Reject output-radix 1"
gdb_test "show output-radix" \
"Default output radix for printing of values is 10\\." \
Fix test names starting with uppercase using multi-line gdb_test/mi_gdb_test This fixes offender testcases that have test names starting with uppercase when using gdb_test/mi_gdb_test in a multi-line construct. gdb/testsuite/ChangeLog 2016-12-01 Luis Machado <lgustavo@codesourcery.com> Fix test names starting with uppercase throughout the files. * gdb.ada/array_return.exp * gdb.ada/expr_delims.exp * gdb.ada/mi_dyn_arr.exp * gdb.ada/mi_interface.exp * gdb.ada/mi_var_array.exp * gdb.ada/watch_arg.exp * gdb.arch/alpha-step.exp * gdb.arch/altivec-regs.exp * gdb.arch/e500-regs.exp * gdb.arch/powerpc-d128-regs.exp * gdb.base/arrayidx.exp * gdb.base/break.exp * gdb.base/checkpoint.exp * gdb.base/debug-expr.exp * gdb.base/dmsym.exp * gdb.base/radix.exp * gdb.base/sepdebug.exp * gdb.base/testenv.exp * gdb.base/watch_thread_num.exp * gdb.base/watchpoint-cond-gone.exp * gdb.cell/break.exp * gdb.cell/ea-cache.exp * gdb.compile/compile.exp * gdb.cp/gdb2495.exp * gdb.gdb/selftest.exp * gdb.gdb/xfullpath.exp * gdb.go/hello.exp * gdb.go/integers.exp * gdb.objc/basicclass.exp * gdb.pascal/hello.exp * gdb.pascal/integers.exp * gdb.python/py-breakpoint.exp * gdb.python/py-cmd.exp * gdb.python/py-linetable.exp * gdb.python/py-xmethods.exp * gdb.python/python.exp * gdb.reverse/consecutive-precsave.exp * gdb.reverse/finish-precsave.exp * gdb.reverse/i386-precsave.exp * gdb.reverse/machinestate-precsave.exp * gdb.reverse/sigall-precsave.exp * gdb.reverse/solib-precsave.exp * gdb.reverse/step-precsave.exp * gdb.reverse/until-precsave.exp * gdb.reverse/watch-precsave.exp * gdb.threads/leader-exit.exp * gdb.threads/pthreads.exp * gdb.threads/wp-replication.exp * gdb.trace/actions.exp * gdb.trace/mi-tsv-changed.exp * gdb.trace/tsv.exp
2016-12-02 04:44:38 +08:00
"output radix unchanged after rejecting 1"
gdb_test "set radix 7" \
"Unsupported output radix ``decimal 7''; output radix unchanged\\." \
"set radix 7 rejected"
gdb_test "show output-radix" \
"Default output radix for printing of values is 10\\." \
Fix test names starting with uppercase using multi-line gdb_test/mi_gdb_test This fixes offender testcases that have test names starting with uppercase when using gdb_test/mi_gdb_test in a multi-line construct. gdb/testsuite/ChangeLog 2016-12-01 Luis Machado <lgustavo@codesourcery.com> Fix test names starting with uppercase throughout the files. * gdb.ada/array_return.exp * gdb.ada/expr_delims.exp * gdb.ada/mi_dyn_arr.exp * gdb.ada/mi_interface.exp * gdb.ada/mi_var_array.exp * gdb.ada/watch_arg.exp * gdb.arch/alpha-step.exp * gdb.arch/altivec-regs.exp * gdb.arch/e500-regs.exp * gdb.arch/powerpc-d128-regs.exp * gdb.base/arrayidx.exp * gdb.base/break.exp * gdb.base/checkpoint.exp * gdb.base/debug-expr.exp * gdb.base/dmsym.exp * gdb.base/radix.exp * gdb.base/sepdebug.exp * gdb.base/testenv.exp * gdb.base/watch_thread_num.exp * gdb.base/watchpoint-cond-gone.exp * gdb.cell/break.exp * gdb.cell/ea-cache.exp * gdb.compile/compile.exp * gdb.cp/gdb2495.exp * gdb.gdb/selftest.exp * gdb.gdb/xfullpath.exp * gdb.go/hello.exp * gdb.go/integers.exp * gdb.objc/basicclass.exp * gdb.pascal/hello.exp * gdb.pascal/integers.exp * gdb.python/py-breakpoint.exp * gdb.python/py-cmd.exp * gdb.python/py-linetable.exp * gdb.python/py-xmethods.exp * gdb.python/python.exp * gdb.reverse/consecutive-precsave.exp * gdb.reverse/finish-precsave.exp * gdb.reverse/i386-precsave.exp * gdb.reverse/machinestate-precsave.exp * gdb.reverse/sigall-precsave.exp * gdb.reverse/solib-precsave.exp * gdb.reverse/step-precsave.exp * gdb.reverse/until-precsave.exp * gdb.reverse/watch-precsave.exp * gdb.threads/leader-exit.exp * gdb.threads/pthreads.exp * gdb.threads/wp-replication.exp * gdb.trace/actions.exp * gdb.trace/mi-tsv-changed.exp * gdb.trace/tsv.exp
2016-12-02 04:44:38 +08:00
"output radix unchanged after rejection through set radix command"