Commit | Line | Data |
---|---|---|
88b9d363 | 1 | # Copyright 2016-2022 Free Software Foundation, Inc. |
dcd1f979 TT |
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 | ||
81f47ac2 AH |
16 | # Do not run if gdb debug is enabled as maintenance output will be |
17 | # redirected to the log files. | |
18 | if [gdb_debug_enabled] { | |
19 | untested "debug is enabled" | |
20 | return 0 | |
21 | } | |
22 | ||
1af17fd9 YQ |
23 | set do_xml_test [expr ![gdb_skip_xml_test]] |
24 | ||
b97eff8f AB |
25 | standard_testfile |
26 | ||
27 | if {[prepare_for_testing "failed to prepare" $testfile $srcfile debug]} { | |
28 | return -1 | |
29 | } | |
30 | ||
31 | proc run_selftests { binfile } { | |
32 | global decimal gdb_prompt | |
33 | ||
34 | if { $binfile == "" } { | |
35 | gdb_exit | |
36 | gdb_start | |
37 | } else { | |
38 | clean_restart ${binfile} | |
39 | } | |
40 | ||
41 | set test "maintenance selftest" | |
42 | gdb_test_multiple $test $test { | |
43 | -re ".*Running selftest \[^\n\r\]+\." { | |
44 | # The selftests can take some time to complete. To prevent | |
45 | # timeout spot the 'Running ...' lines going past, so long as | |
46 | # these are produced quickly enough then the overall test will | |
47 | # not timeout. | |
48 | exp_continue | |
49 | } | |
50 | -re "Ran ($decimal) unit tests, ($decimal) failed\r\n$gdb_prompt $" { | |
51 | set num_ran $expect_out(1,string) | |
52 | set num_failed $expect_out(2,string) | |
53 | gdb_assert "$num_ran > 0" "$test, ran some tests" | |
54 | ||
55 | if { $binfile != "" } { | |
56 | # There's a known issue here (see PR gdb/27891), | |
57 | # however, we should not have more than 1 failure. | |
58 | gdb_assert "$num_failed <= 1" "$test, failed no more than 1" | |
59 | setup_kfail "gdb/27891" "*-*-*" | |
60 | } | |
61 | gdb_assert "$num_failed == 0" "$test, failed none" | |
62 | } | |
63 | -re "Selftests have been disabled for this build.\r\n$gdb_prompt $" { | |
64 | unsupported $test | |
65 | } | |
66 | } | |
67 | } | |
68 | ||
69 | with_test_prefix "no executable loaded" { | |
70 | run_selftests "" | |
71 | } | |
72 | ||
73 | with_test_prefix "executable loaded" { | |
74 | run_selftests ${binfile} | |
1e5ded6c | 75 | } |
27d41eac | 76 | |
1af17fd9 | 77 | if { ![is_remote host] && $do_xml_test } { |
27d41eac | 78 | gdb_test "maintenance check xml-descriptions ${srcdir}/../features" \ |
fee6da6e PA |
79 | "Tested $decimal XML files, 0 failed" \ |
80 | "maintenance check xml-descriptions \${srcdir}/../features" | |
27d41eac | 81 | } |