tdesc-arch.exp revision 1.9 1 1.9 christos # Copyright 2007-2020 Free Software Foundation, Inc.
2 1.1 christos
3 1.1 christos # This program is free software; you can redistribute it and/or modify
4 1.1 christos # it under the terms of the GNU General Public License as published by
5 1.1 christos # the Free Software Foundation; either version 3 of the License, or
6 1.1 christos # (at your option) any later version.
7 1.1 christos #
8 1.1 christos # This program is distributed in the hope that it will be useful,
9 1.1 christos # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 1.1 christos # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 1.1 christos # GNU General Public License for more details.
12 1.1 christos #
13 1.1 christos # You should have received a copy of the GNU General Public License
14 1.1 christos # along with this program. If not, see <http://www.gnu.org/licenses/>.
15 1.1 christos
16 1.1 christos if {[gdb_skip_xml_test]} {
17 1.1 christos unsupported "tdesc-arch.exp"
18 1.1 christos return -1
19 1.1 christos }
20 1.1 christos
21 1.1 christos gdb_start
22 1.1 christos
23 1.1 christos # Find some valid architectures - we just need legitimate values
24 1.1 christos # to put in our <architecture> elements.
25 1.1 christos set arch1 ""
26 1.1 christos set arch2 ""
27 1.1 christos set msg "read valid architectures"
28 1.1 christos gdb_test_multiple "set architecture" $msg {
29 1.1 christos -re "Requires an argument. Valid arguments are (\[^ \]*), (\[^ \]*), .*auto\\.\r\n$gdb_prompt $" {
30 1.1 christos set arch1 $expect_out(1,string)
31 1.1 christos set arch2 $expect_out(2,string)
32 1.1 christos pass $msg
33 1.1 christos }
34 1.1 christos -re "Requires an argument. Valid arguments are (\[^ \]*), auto\\.\r\n$gdb_prompt $" {
35 1.1 christos # If there is just one supported architecture, we can't do this test.
36 1.1 christos unsupported "tdesc-arch.exp"
37 1.1 christos return -1
38 1.1 christos }
39 1.1 christos }
40 1.1 christos
41 1.1 christos set default_arch ""
42 1.1 christos set msg "read default architecture"
43 1.1 christos gdb_test_multiple "show architecture" $msg {
44 1.9 christos -re "The target architecture is set to \"auto\" \\(currently \"(\[^ \]*)\"\\)\\.\r\n$gdb_prompt $" {
45 1.1 christos set default_arch $expect_out(1,string)
46 1.1 christos pass $msg
47 1.1 christos }
48 1.1 christos }
49 1.1 christos
50 1.1 christos # If that did not work, no point running further tests.
51 1.1 christos if { "$arch1" == "" || "$arch2" == "" || "$default_arch" == "" } {
52 1.1 christos unresolved "architecture XML tests"
53 1.1 christos return -1
54 1.1 christos }
55 1.1 christos
56 1.1 christos # Run these tests twice, once for $arch1 and once for $arch2, to
57 1.1 christos # make sure that the tdesc file overrides the global default.
58 1.9 christos # TRANS_MODE indicates how newlines should be represented; it should
59 1.9 christos # be one of the values supported by "fconfigure -translation".
60 1.1 christos
61 1.9 christos proc set_arch { arch which trans_mode } {
62 1.1 christos global gdb_prompt
63 1.1 christos global subdir
64 1.1 christos
65 1.1 christos set filename [standard_output_file tdesc-arch.xml]
66 1.1 christos set fd [open $filename w]
67 1.9 christos fconfigure $fd -translation $trans_mode
68 1.1 christos puts $fd \
69 1.1 christos "<target>
70 1.1 christos <architecture>$arch</architecture>
71 1.1 christos </target>"
72 1.1 christos close $fd
73 1.1 christos if {[is_remote host]} {
74 1.1 christos set filename [remote_download host $filename tdesc-arch.xml]
75 1.1 christos }
76 1.1 christos
77 1.1 christos # Anchor the test output, so that error messages are detected.
78 1.1 christos set cmd "set tdesc filename $filename"
79 1.1 christos set msg "set tdesc filename tdesc-arch.xml ($which architecture)"
80 1.1 christos set cmd_regex [string_to_regexp $cmd]
81 1.1 christos gdb_test_multiple $cmd $msg {
82 1.1 christos -re "^$cmd_regex\r\n$gdb_prompt $" {
83 1.1 christos pass $msg
84 1.1 christos }
85 1.1 christos -re "^$cmd_regex\r\nwarning: A handler for the OS ABI.*\r\n$gdb_prompt $" {
86 1.1 christos kfail gdb/2225 $msg
87 1.1 christos }
88 1.1 christos }
89 1.1 christos
90 1.1 christos set cmd "show architecture"
91 1.1 christos gdb_test $cmd \
92 1.9 christos "The target architecture is set to \"auto\" \\(currently \"$arch\"\\)\\." \
93 1.1 christos "$cmd ($which architecture)"
94 1.1 christos
95 1.1 christos remote_file host delete $filename
96 1.1 christos }
97 1.1 christos
98 1.9 christos set_arch $arch1 first lf
99 1.9 christos set_arch $arch2 second lf
100 1.9 christos
101 1.9 christos with_test_prefix crlf {
102 1.9 christos set_arch $arch1 first crlf
103 1.9 christos set_arch $arch2 second crlf
104 1.9 christos }
105 1.1 christos
106 1.1 christos # Check an invalid architecture setting.
107 1.1 christos set filename [standard_output_file tdesc-arch.xml]
108 1.1 christos set fd [open $filename w]
109 1.1 christos puts $fd \
110 1.1 christos "<target>
111 1.1 christos <architecture>invalid</architecture>
112 1.1 christos </target>"
113 1.1 christos close $fd
114 1.1 christos if {[is_remote host]} {
115 1.1 christos set filename [remote_download host $filename "tdesc-arch.xml"]
116 1.1 christos }
117 1.1 christos
118 1.1 christos set cmd "set tdesc filename $filename"
119 1.1 christos gdb_test $cmd \
120 1.1 christos "warning:.*Target description specified unknown architecture.*" \
121 1.1 christos "set tdesc filename tdesc-arch.xml (invalid architecture)"
122 1.1 christos
123 1.1 christos set cmd "show architecture"
124 1.1 christos gdb_test $cmd \
125 1.9 christos "The target architecture is set to \"auto\" \\(currently \"$default_arch\"\\)\\." \
126 1.1 christos "$cmd (invalid architecture)"
127 1.1 christos
128 1.1 christos remote_file host delete $filename
129