Commit | Line | Data |
---|---|---|
42a4f53d | 1 | # Copyright 2007-2019 Free Software Foundation, Inc. |
e515b470 DJ |
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 | |
e22f8b7c | 5 | # the Free Software Foundation; either version 3 of the License, or |
e515b470 DJ |
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 | |
e22f8b7c | 14 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
e515b470 DJ |
15 | |
16 | if {[gdb_skip_xml_test]} { | |
17 | unsupported "tdesc-arch.exp" | |
18 | return -1 | |
19 | } | |
20 | ||
21 | gdb_start | |
22 | ||
23 | # Find some valid architectures - we just need legitimate values | |
24 | # to put in our <architecture> elements. | |
25 | set arch1 "" | |
26 | set arch2 "" | |
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) | |
32 | pass $msg | |
33 | } | |
9c6759c1 UW |
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" | |
37 | return -1 | |
38 | } | |
e515b470 DJ |
39 | } |
40 | ||
41 | set default_arch "" | |
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) | |
46 | pass $msg | |
47 | } | |
48 | } | |
49 | ||
50 | # If that did not work, no point running further tests. | |
51 | if { "$arch1" == "" || "$arch2" == "" || "$default_arch" == "" } { | |
52 | unresolved "architecture XML tests" | |
53 | return -1 | |
54 | } | |
55 | ||
56 | # Run these tests twice, once for $arch1 and once for $arch2, to | |
57 | # make sure that the tdesc file overrides the global default. | |
f69656d0 TT |
58 | # TRANS_MODE indicates how newlines should be represented; it should |
59 | # be one of the values supported by "fconfigure -translation". | |
e515b470 | 60 | |
f69656d0 | 61 | proc set_arch { arch which trans_mode } { |
e515b470 | 62 | global gdb_prompt |
d252f7e5 | 63 | global subdir |
e515b470 | 64 | |
cfb7b9a3 TT |
65 | set filename [standard_output_file tdesc-arch.xml] |
66 | set fd [open $filename w] | |
f69656d0 | 67 | fconfigure $fd -translation $trans_mode |
e515b470 DJ |
68 | puts $fd \ |
69 | "<target> | |
70 | <architecture>$arch</architecture> | |
71 | </target>" | |
72 | close $fd | |
cfb7b9a3 TT |
73 | if {[is_remote host]} { |
74 | set filename [remote_download host $filename tdesc-arch.xml] | |
75 | } | |
e515b470 DJ |
76 | |
77 | # Anchor the test output, so that error messages are detected. | |
cfb7b9a3 TT |
78 | set cmd "set tdesc filename $filename" |
79 | set msg "set tdesc filename tdesc-arch.xml ($which architecture)" | |
e515b470 DJ |
80 | set cmd_regex [string_to_regexp $cmd] |
81 | gdb_test_multiple $cmd $msg { | |
82 | -re "^$cmd_regex\r\n$gdb_prompt $" { | |
83 | pass $msg | |
84 | } | |
3da939d7 DJ |
85 | -re "^$cmd_regex\r\nwarning: A handler for the OS ABI.*\r\n$gdb_prompt $" { |
86 | kfail gdb/2225 $msg | |
87 | } | |
e515b470 DJ |
88 | } |
89 | ||
90 | set cmd "show architecture" | |
91 | gdb_test $cmd \ | |
92 | "The target architecture is set automatically \\(currently $arch\\)" \ | |
93 | "$cmd ($which architecture)" | |
94 | ||
cfb7b9a3 | 95 | remote_file host delete $filename |
e515b470 DJ |
96 | } |
97 | ||
f69656d0 TT |
98 | set_arch $arch1 first lf |
99 | set_arch $arch2 second lf | |
100 | ||
101 | with_test_prefix crlf { | |
102 | set_arch $arch1 first crlf | |
103 | set_arch $arch2 second crlf | |
104 | } | |
e515b470 DJ |
105 | |
106 | # Check an invalid architecture setting. | |
cfb7b9a3 TT |
107 | set filename [standard_output_file tdesc-arch.xml] |
108 | set fd [open $filename w] | |
e515b470 DJ |
109 | puts $fd \ |
110 | "<target> | |
111 | <architecture>invalid</architecture> | |
112 | </target>" | |
113 | close $fd | |
cfb7b9a3 TT |
114 | if {[is_remote host]} { |
115 | set filename [remote_download host $filename "tdesc-arch.xml"] | |
116 | } | |
e515b470 | 117 | |
cfb7b9a3 | 118 | set cmd "set tdesc filename $filename" |
e515b470 DJ |
119 | gdb_test $cmd \ |
120 | "warning:.*Target description specified unknown architecture.*" \ | |
cfb7b9a3 | 121 | "set tdesc filename tdesc-arch.xml (invalid architecture)" |
e515b470 DJ |
122 | |
123 | set cmd "show architecture" | |
124 | gdb_test $cmd \ | |
125 | "The target architecture is set automatically \\(currently $default_arch\\)" \ | |
126 | "$cmd (invalid architecture)" | |
127 | ||
cfb7b9a3 | 128 | remote_file host delete $filename |