Switch the license of all .c files to GPLv3.
[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 }
9c6759c1
UW
35 -re "Requires an argument. Valid arguments are (\[^ \]*), auto\\.\r\n$gdb_prompt $" {
36 # If there is just one supported architecture, we can't do this test.
37 unsupported "tdesc-arch.exp"
38 return -1
39 }
e515b470
DJ
40}
41
42set default_arch ""
43set msg "read default architecture"
44gdb_test_multiple "show architecture" $msg {
45 -re "The target architecture is set automatically \\(currently (\[^ \]*)\\)\r\n$gdb_prompt $" {
46 set default_arch $expect_out(1,string)
47 pass $msg
48 }
49}
50
51# If that did not work, no point running further tests.
52if { "$arch1" == "" || "$arch2" == "" || "$default_arch" == "" } {
53 unresolved "architecture XML tests"
54 return -1
55}
56
57# Run these tests twice, once for $arch1 and once for $arch2, to
58# make sure that the tdesc file overrides the global default.
59
60proc set_arch { arch which } {
61 global gdb_prompt
62
63 set fd [open "tdesc-arch.xml" w]
64 puts $fd \
65 "<target>
66 <architecture>$arch</architecture>
67 </target>"
68 close $fd
69
70 # Anchor the test output, so that error messages are detected.
71 set cmd "set tdesc filename tdesc-arch.xml"
72 set msg "$cmd ($which architecture)"
73 set cmd_regex [string_to_regexp $cmd]
74 gdb_test_multiple $cmd $msg {
75 -re "^$cmd_regex\r\n$gdb_prompt $" {
76 pass $msg
77 }
3da939d7
DJ
78 -re "^$cmd_regex\r\nwarning: A handler for the OS ABI.*\r\n$gdb_prompt $" {
79 kfail gdb/2225 $msg
80 }
e515b470
DJ
81 }
82
83 set cmd "show architecture"
84 gdb_test $cmd \
85 "The target architecture is set automatically \\(currently $arch\\)" \
86 "$cmd ($which architecture)"
87
88 file delete "tdesc-arch.xml"
89}
90
91set_arch $arch1 first
92set_arch $arch2 second
93
94# Check an invalid architecture setting.
95set fd [open "tdesc-arch.xml" w]
96puts $fd \
97 "<target>
98 <architecture>invalid</architecture>
99 </target>"
100close $fd
101
102set cmd "set tdesc filename tdesc-arch.xml"
103gdb_test $cmd \
104 "warning:.*Target description specified unknown architecture.*" \
105 "$cmd (invalid architecture)"
106
107set cmd "show architecture"
108gdb_test $cmd \
109 "The target architecture is set automatically \\(currently $default_arch\\)" \
110 "$cmd (invalid architecture)"
111
112file delete "tdesc-arch.xml"
This page took 0.079024 seconds and 4 git commands to generate.