Commit | Line | Data |
---|---|---|
88b9d363 | 1 | # Copyright 2020-2022 Free Software Foundation, Inc. |
caa7fd04 AB |
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 | # Testing for 'maint print xml-tdesc'. Check we can print out the | |
17 | # current target description and load it back in again. | |
18 | ||
19 | if {[gdb_skip_xml_test]} { | |
20 | unsupported "xml tests not being run" | |
21 | return -1 | |
22 | } | |
23 | ||
24 | standard_testfile | |
25 | ||
26 | if {[prepare_for_testing "failed to prepare" $testfile $srcfile debug]} { | |
27 | return -1 | |
28 | } | |
29 | ||
30 | if ![runto_main] then { | |
31 | fail "can't run to main" | |
32 | return 0 | |
33 | } | |
34 | ||
35 | # Three files we're going to write out to. | |
36 | set xml_file_1 [standard_output_file outfile1.xml] | |
37 | set xml_file_2 [standard_output_file outfile2.xml] | |
38 | set xml_file_3 [standard_output_file outfile3.xml] | |
39 | ||
40 | # Write the current target description to a file. | |
41 | gdb_test_no_output "pipe maint print xml-tdesc | cat > $xml_file_1" \ | |
42 | "write current target description to file" | |
43 | ||
44 | # Read the target description back in to GDB, and the write it back | |
45 | # out to a file. | |
46 | gdb_test_no_output \ | |
47 | "pipe maint print xml-tdesc $xml_file_1 | cat > $xml_file_2" \ | |
48 | "read previous xml description, and write it out to a second file" | |
49 | ||
50 | # Check the two produced files are identical. | |
51 | gdb_test "shell diff -s $xml_file_1 $xml_file_2" \ | |
52 | "Files \[^\r\n\]* are identical" \ | |
53 | "first two produced xml files are identical" | |
54 | ||
55 | # Restart GDB. | |
56 | clean_restart | |
57 | ||
58 | # Change to use one of the target descriptions we wrote out earlier. | |
59 | gdb_test_no_output "set tdesc filename $xml_file_1" \ | |
60 | "set target description to use" | |
61 | ||
62 | # Load the executable. | |
63 | gdb_load ${binfile} | |
64 | ||
65 | # Run to `main' where we begin our tests. | |
66 | if ![runto_main] then { | |
67 | untested "could not run to main" | |
68 | return -1 | |
69 | } | |
70 | ||
71 | # Run info registers just to check this appears to run fine with the | |
72 | # new target description. | |
4b62a30d LM |
73 | gdb_test_multiple "info all-registers" "Run info registers" -lbl { |
74 | -re -wrap "" { | |
75 | pass $gdb_test_name | |
76 | } | |
77 | } | |
caa7fd04 AB |
78 | |
79 | # Write out the current target description. | |
80 | gdb_test_no_output "pipe maint print xml-tdesc | cat > $xml_file_3" \ | |
81 | "write third target description to file" | |
82 | ||
83 | # And check that it matches the original file we loaded. | |
84 | gdb_test "shell diff -s $xml_file_1 $xml_file_3" \ | |
85 | "Files \[^\r\n\]* are identical" \ | |
86 | "first and third produced xml files are identical" |