]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/testsuite/gdb.base/endian.exp
3058e6294aad5c405f125bbeb45a06f7a9d48583
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.base / endian.exp
1 # Copyright (C) 2018-2020 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 # Test automatic endianness selection.
17
18 standard_testfile
19
20 set en_auto "The target endianness is set automatically"
21 set en_set "The target is set to"
22
23 clean_restart
24
25 # First check that the automatic endianness is updated
26 # with the `set endian' command.
27 gdb_test "set endian auto" \
28 "$en_auto \\\(currently \(\?:big\|little\) endian\\\)\\." \
29 "default target endianness"
30 gdb_test "set endian big" "$en_set big endian\\." \
31 "set target endianness"
32 gdb_test "set endian auto" "$en_auto \\\(currently big endian\\\)\\." \
33 "auto target endianness"
34 gdb_test "set endian little" "$en_set little endian\\." \
35 "set target endianness little"
36 gdb_test "set endian auto" "$en_auto \\\(currently little endian\\\)\\." \
37 "auto target endianness little"
38 gdb_test "set endian big" "$en_set big endian\\." \
39 "set target endianness big"
40 gdb_test "set endian auto" "$en_auto \\\(currently big endian\\\)\\." \
41 "auto target endianness big"
42
43 if { [build_executable ${testfile}.exp $testfile] } {
44 gdb_suppress_entire_file "$pf_prefix cannot build executable"
45 }
46
47 if { [gdb_file_cmd $binfile] } {
48 gdb_suppress_entire_file "$pf_prefix cannot select executable"
49 }
50 set test "get target endianness"
51 if { [gdb_test_multiple "show endian" "$test" {
52 -re "$en_auto \\\(currently \(big\|little\) endian\\\)\\..*$gdb_prompt" {
53 set endian $expect_out(1,string)
54 pass "$test"
55 }
56 }] } {
57 gdb_suppress_entire_file \
58 "$pf_prefix cannot determine executable endianness"
59 set endian ""
60 }
61
62 # Now check that the automatic endianness is updated
63 # according to the executable selected.
64 if { [gdb_unload] } {
65 gdb_suppress_entire_file "$pf_prefix cannot unselect executable"
66 }
67 gdb_test "set endian big" "$en_set big endian\\." \
68 "override target endianness big"
69 gdb_test "set endian auto" "$en_auto \\\(currently big endian\\\)\\." \
70 "override auto target endianness big"
71 if { [gdb_file_cmd $binfile] } {
72 gdb_suppress_entire_file "$pf_prefix cannot select executable"
73 }
74 gdb_test "show endian" "$en_auto \\\(currently $endian endian\\\)\\." \
75 "previously big default executable endianness"
76 if { [gdb_unload] } {
77 gdb_suppress_entire_file "$pf_prefix cannot unselect executable"
78 }
79 gdb_test "show endian" "$en_auto \\\(currently $endian endian\\\)\\." \
80 "previously big default no executable endianness"
81 gdb_test "set endian little" "$en_set little endian\\." \
82 "override target endianness little"
83 gdb_test "set endian auto" "$en_auto \\\(currently little endian\\\)\\." \
84 "override auto target endianness little"
85 if { [gdb_file_cmd $binfile] } {
86 gdb_suppress_entire_file "$pf_prefix cannot select executable"
87 }
88 gdb_test "show endian" "$en_auto \\\(currently $endian endian\\\)\\." \
89 "previously little default executable endianness"
90 if { [gdb_unload] } {
91 gdb_suppress_entire_file "$pf_prefix cannot unselect executable"
92 }
93 gdb_test "show endian" "$en_auto \\\(currently $endian endian\\\)\\." \
94 "previously little default no executable endianness"