1 # Copyright 2007-2024 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 require allow_xml_test
20 # Find some valid architectures - we just need legitimate values
21 # to put in our <architecture> elements.
24 set msg "read valid architectures"
25 gdb_test_multiple "set architecture" $msg {
26 -re "Requires an argument. Valid arguments are (\[^ \]*), (\[^ \]*), .*auto\\.\r\n$gdb_prompt $" {
27 set arch1 $expect_out(1,string)
28 set arch2 $expect_out(2,string)
31 -re "Requires an argument. Valid arguments are (\[^ \]*), auto\\.\r\n$gdb_prompt $" {
32 # If there is just one supported architecture, we can't do this test.
33 unsupported "tdesc-arch.exp"
39 set msg "read default architecture"
40 gdb_test_multiple "show architecture" $msg {
41 -re "The target architecture is set to \"auto\" \\(currently \"(\[^ \]*)\"\\)\\.\r\n$gdb_prompt $" {
42 set default_arch $expect_out(1,string)
47 # If that did not work, no point running further tests.
48 if { "$arch1" == "" || "$arch2" == "" || "$default_arch" == "" } {
49 unresolved "architecture XML tests"
53 # Run these tests twice, once for $arch1 and once for $arch2, to
54 # make sure that the tdesc file overrides the global default.
55 # TRANS_MODE indicates how newlines should be represented; it should
56 # be one of the values supported by "fconfigure -translation".
58 proc set_arch { arch which trans_mode } {
62 set filename [standard_output_file tdesc-arch.xml]
63 set fd [open $filename w]
64 fconfigure $fd -translation $trans_mode
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 to \"auto\" \\(currently \"$arch\"\\)\\." \
90 "$cmd, $which architecture"
92 remote_file host delete $filename
95 set_arch $arch1 first lf
96 set_arch $arch2 second lf
98 with_test_prefix crlf {
99 set_arch $arch1 first crlf
100 set_arch $arch2 second crlf
103 # Check an invalid architecture setting.
104 set filename [standard_output_file tdesc-arch.xml]
105 set fd [open $filename w]
108 <architecture>invalid</architecture>
111 if {[is_remote host]} {
112 set filename [remote_download host $filename "tdesc-arch.xml"]
115 set cmd "set tdesc filename $filename"
117 "warning:.*Target description specified unknown architecture.*" \
118 "set tdesc filename tdesc-arch.xml, invalid architecture"
120 set cmd "show architecture"
122 "The target architecture is set to \"auto\" \\(currently \"$default_arch\"\\)\\." \
123 "$cmd, invalid architecture"
125 remote_file host delete $filename