* Makefile.in (ALL_SUBDIRS): Add gdb.xml.
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.xml / tdesc-arch.exp
CommitLineData
e515b470
DJ
1# Copyright 2007 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 2 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, write to the Free Software
15# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
16
17if {[gdb_skip_xml_test]} {
18 unsupported "tdesc-arch.exp"
19 return -1
20}
21
22gdb_start
23
24# Find some valid architectures - we just need legitimate values
25# to put in our <architecture> elements.
26set arch1 ""
27set arch2 ""
28set msg "read valid architectures"
29gdb_test_multiple "set architecture" $msg {
30 -re "Requires an argument. Valid arguments are (\[^ \]*), (\[^ \]*), .*auto\\.\r\n$gdb_prompt $" {
31 set arch1 $expect_out(1,string)
32 set arch2 $expect_out(2,string)
33 pass $msg
34 }
35}
36
37set default_arch ""
38set msg "read default architecture"
39gdb_test_multiple "show architecture" $msg {
40 -re "The target architecture is set automatically \\(currently (\[^ \]*)\\)\r\n$gdb_prompt $" {
41 set default_arch $expect_out(1,string)
42 pass $msg
43 }
44}
45
46# If that did not work, no point running further tests.
47if { "$arch1" == "" || "$arch2" == "" || "$default_arch" == "" } {
48 unresolved "architecture XML tests"
49 return -1
50}
51
52# Run these tests twice, once for $arch1 and once for $arch2, to
53# make sure that the tdesc file overrides the global default.
54
55proc set_arch { arch which } {
56 global gdb_prompt
57
58 set fd [open "tdesc-arch.xml" w]
59 puts $fd \
60 "<target>
61 <architecture>$arch</architecture>
62 </target>"
63 close $fd
64
65 # Anchor the test output, so that error messages are detected.
66 set cmd "set tdesc filename tdesc-arch.xml"
67 set msg "$cmd ($which architecture)"
68 set cmd_regex [string_to_regexp $cmd]
69 gdb_test_multiple $cmd $msg {
70 -re "^$cmd_regex\r\n$gdb_prompt $" {
71 pass $msg
72 }
73 }
74
75 set cmd "show architecture"
76 gdb_test $cmd \
77 "The target architecture is set automatically \\(currently $arch\\)" \
78 "$cmd ($which architecture)"
79
80 file delete "tdesc-arch.xml"
81}
82
83set_arch $arch1 first
84set_arch $arch2 second
85
86# Check an invalid architecture setting.
87set fd [open "tdesc-arch.xml" w]
88puts $fd \
89 "<target>
90 <architecture>invalid</architecture>
91 </target>"
92close $fd
93
94set cmd "set tdesc filename tdesc-arch.xml"
95gdb_test $cmd \
96 "warning:.*Target description specified unknown architecture.*" \
97 "$cmd (invalid architecture)"
98
99set cmd "show architecture"
100gdb_test $cmd \
101 "The target architecture is set automatically \\(currently $default_arch\\)" \
102 "$cmd (invalid architecture)"
103
104file delete "tdesc-arch.xml"
This page took 0.026869 seconds and 4 git commands to generate.