Update years in copyright notice for the GDB files.
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.base / alias.exp
CommitLineData
5a56e9c5 1# Test the alias command.
28e7fd62 2# Copyright 2011-2013 Free Software Foundation, Inc.
5a56e9c5
DE
3
4# This program is free software; you can redistribute it and/or modify
5# it under the terms of the GNU General Public License as published by
6# the Free Software Foundation; either version 3 of the License, or
7# (at your option) any later version.
8#
9# This program is distributed in the hope that it will be useful,
10# but WITHOUT ANY WARRANTY; without even the implied warranty of
11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12# GNU General Public License for more details.
13#
14# You should have received a copy of the GNU General Public License
15# along with this program. If not, see <http://www.gnu.org/licenses/>.
16
17gdb_exit
18gdb_start
19gdb_reinitialize_dir $srcdir/$subdir
20
21# Helper to test the -a option to alias.
22# Aliases that are abbreviations of commands (e.g. r -> run)
23# do not appear in help output.
24
25proc test_abbrev_not_present { alias_name } {
26 global gdb_prompt
27 set alias_present 0
28 set test_name "abbrev $alias_name not present in help command list"
29 gdb_test_multiple "help aliases" $test_name {
30 -re "\[\r\n\]$alias_name \[^\r\n\]*" {
31 set alias_present 1
32 exp_continue
33 }
34 -re ".*$gdb_prompt $" {
35 if { !$alias_present } then {
36 pass $test_name
37 } else {
38 fail $test_name
39 }
40 }
41 }
42}
43
44proc test_abbrev_alias { name gdb_command test_value } {
45 gdb_test_no_output $gdb_command
46 gdb_test_no_output "$name print elements $test_value"
47 gdb_test "show print elements" "Limit .* is $test_value\[.\]" "verify $name"
48 test_abbrev_not_present $name
49}
50
51test_abbrev_alias set2 "alias -a set2=set" 42
52test_abbrev_alias set3 "alias -a set3= set" 43
53test_abbrev_alias set4 "alias -a set4 =set" 44
54test_abbrev_alias set5 "alias -a set5 = set" 45
55test_abbrev_alias set6 "alias -a -- set6 = set" 46
56test_abbrev_alias -a "alias -a -- -a = set" 47
57
58gdb_test "alias set2=set" "already exists: set2"
59gdb_test "alias foo=bar" "Invalid command to alias to: bar"
60
61gdb_test_no_output "alias spe = set p elem"
62gdb_test_no_output "spe 50"
63gdb_test "show print elements" "Limit .* is 50\[.\]" "verify spe"
64
65gdb_test_no_output "alias set pr elms = set p elem"
66gdb_test_no_output "set pr elms 51"
67gdb_test "show print elements" "Limit .* is 51\[.\]" "verify set pr elms"
68gdb_test "help set print" "set print elms .*"
This page took 0.17091 seconds and 4 git commands to generate.