]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/testsuite/gdb.xml/tdesc-arch.exp
Update copyright year range in header of all files managed by GDB
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.xml / tdesc-arch.exp
1 # Copyright 2007-2024 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 3 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, see <http://www.gnu.org/licenses/>.
15
16 require allow_xml_test
17
18 gdb_start
19
20 # Find some valid architectures - we just need legitimate values
21 # to put in our <architecture> elements.
22 set arch1 ""
23 set arch2 ""
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)
29 pass $msg
30 }
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"
34 return -1
35 }
36 }
37
38 set default_arch ""
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)
43 pass $msg
44 }
45 }
46
47 # If that did not work, no point running further tests.
48 if { "$arch1" == "" || "$arch2" == "" || "$default_arch" == "" } {
49 unresolved "architecture XML tests"
50 return -1
51 }
52
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".
57
58 proc set_arch { arch which trans_mode } {
59 global gdb_prompt
60 global subdir
61
62 set filename [standard_output_file tdesc-arch.xml]
63 set fd [open $filename w]
64 fconfigure $fd -translation $trans_mode
65 puts $fd \
66 "<target>
67 <architecture>$arch</architecture>
68 </target>"
69 close $fd
70 if {[is_remote host]} {
71 set filename [remote_download host $filename tdesc-arch.xml]
72 }
73
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 $" {
80 pass $msg
81 }
82 -re "^$cmd_regex\r\nwarning: A handler for the OS ABI.*\r\n$gdb_prompt $" {
83 kfail gdb/2225 $msg
84 }
85 }
86
87 set cmd "show architecture"
88 gdb_test $cmd \
89 "The target architecture is set to \"auto\" \\(currently \"$arch\"\\)\\." \
90 "$cmd ($which architecture)"
91
92 remote_file host delete $filename
93 }
94
95 set_arch $arch1 first lf
96 set_arch $arch2 second lf
97
98 with_test_prefix crlf {
99 set_arch $arch1 first crlf
100 set_arch $arch2 second crlf
101 }
102
103 # Check an invalid architecture setting.
104 set filename [standard_output_file tdesc-arch.xml]
105 set fd [open $filename w]
106 puts $fd \
107 "<target>
108 <architecture>invalid</architecture>
109 </target>"
110 close $fd
111 if {[is_remote host]} {
112 set filename [remote_download host $filename "tdesc-arch.xml"]
113 }
114
115 set cmd "set tdesc filename $filename"
116 gdb_test $cmd \
117 "warning:.*Target description specified unknown architecture.*" \
118 "set tdesc filename tdesc-arch.xml (invalid architecture)"
119
120 set cmd "show architecture"
121 gdb_test $cmd \
122 "The target architecture is set to \"auto\" \\(currently \"$default_arch\"\\)\\." \
123 "$cmd (invalid architecture)"
124
125 remote_file host delete $filename