1 # Copyright 2007-2019 Free Software Foundation, Inc.
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.
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.
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/>.
16 if {[gdb_skip_xml_test]} {
17 unsupported "tdesc-arch.exp"
23 # Find some valid architectures - we just need legitimate values
24 # to put in our <architecture> elements.
27 set msg "read valid architectures"
28 gdb_test_multiple "set architecture" $msg {
29 -re "Requires an argument. Valid arguments are (\[^ \]*), (\[^ \]*), .*auto\\.\r\n$gdb_prompt $" {
30 set arch1 $expect_out(1,string)
31 set arch2 $expect_out(2,string)
34 -re "Requires an argument. Valid arguments are (\[^ \]*), auto\\.\r\n$gdb_prompt $" {
35 # If there is just one supported architecture, we can't do this test.
36 unsupported "tdesc-arch.exp"
42 set msg "read default architecture"
43 gdb_test_multiple "show architecture" $msg {
44 -re "The target architecture is set automatically \\(currently (\[^ \]*)\\)\r\n$gdb_prompt $" {
45 set default_arch $expect_out(1,string)
50 # If that did not work, no point running further tests.
51 if { "$arch1" == "" || "$arch2" == "" || "$default_arch" == "" } {
52 unresolved "architecture XML tests"
56 # Run these tests twice, once for $arch1 and once for $arch2, to
57 # make sure that the tdesc file overrides the global default.
59 proc set_arch { arch which } {
63 set filename [standard_output_file tdesc-arch.xml]
64 set fd [open $filename w]
67 <architecture>$arch</architecture>
70 if {[is_remote host]} {
71 set filename [remote_download host $filename tdesc-arch.xml]
74 # Anchor the test output, so that error messages are detected.
75 set cmd "set tdesc filename $filename"
76 set msg "set tdesc filename tdesc-arch.xml ($which architecture)"
77 set cmd_regex [string_to_regexp $cmd]
78 gdb_test_multiple $cmd $msg {
79 -re "^$cmd_regex\r\n$gdb_prompt $" {
82 -re "^$cmd_regex\r\nwarning: A handler for the OS ABI.*\r\n$gdb_prompt $" {
87 set cmd "show architecture"
89 "The target architecture is set automatically \\(currently $arch\\)" \
90 "$cmd ($which architecture)"
92 remote_file host delete $filename
96 set_arch $arch2 second
98 # Check an invalid architecture setting.
99 set filename [standard_output_file tdesc-arch.xml]
100 set fd [open $filename w]
103 <architecture>invalid</architecture>
106 if {[is_remote host]} {
107 set filename [remote_download host $filename "tdesc-arch.xml"]
110 set cmd "set tdesc filename $filename"
112 "warning:.*Target description specified unknown architecture.*" \
113 "set tdesc filename tdesc-arch.xml (invalid architecture)"
115 set cmd "show architecture"
117 "The target architecture is set automatically \\(currently $default_arch\\)" \
118 "$cmd (invalid architecture)"
120 remote_file host delete $filename