1 # Copyright 2016-2022 Free Software Foundation, Inc.
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.
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.
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/>.
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"
23 load_lib completion-support.exp
25 set do_xml_test [expr ![gdb_skip_xml_test]]
29 if {[build_executable "failed to prepare" $testfile $srcfile debug]} {
33 proc run_selftests { binfile } {
34 global decimal gdb_prompt
36 if { $binfile == "" } {
40 clean_restart ${binfile}
44 set test "maintenance selftest"
45 gdb_test_multiple $test $test {
46 -re ".*Running selftest \[^\n\r\]+\." {
47 # The selftests can take some time to complete. To prevent
48 # timeout spot the 'Running ...' lines going past, so long as
49 # these are produced quickly enough then the overall test will
53 -re "Ran ($decimal) unit tests, ($decimal) failed\r\n$gdb_prompt $" {
54 set num_ran $expect_out(1,string)
55 set num_failed $expect_out(2,string)
56 gdb_assert "$num_ran > 0" "$test, ran some tests"
57 gdb_assert "$num_failed == 0" "$test, failed none"
59 -re "Selftests have been disabled for this build.\r\n$gdb_prompt $" {
68 # Test completion of command "maintenance selftest".
70 proc_with_prefix test_completion {} {
71 global self_tests_enabled
75 if { $self_tests_enabled } {
76 test_gdb_complete_tab_multiple "maintenance selftest copy" "_" \
77 {copy_bitwise copy_integer_to_size}
78 test_gdb_complete_tab_unique "maintenance selftest copy_bit" \
79 "maintenance selftest copy_bitwise" " "
81 test_gdb_complete_tab_none "maintenance selftest copy_"
82 test_gdb_complete_tab_none "maintenance selftest copy_bit"
84 test_gdb_complete_tab_unique "maintenance selftest -ver" "maintenance selftest -verbose" " "
85 test_gdb_complete_tab_none "maintenance selftest name_that_does_not_exist"
88 with_test_prefix "no executable loaded" {
89 set self_tests_enabled [run_selftests ""]
92 with_test_prefix "executable loaded" {
93 run_selftests ${binfile}
98 if { ![is_remote host] && $do_xml_test } {
99 gdb_test "maintenance check xml-descriptions ${srcdir}/../features" \
100 "Tested $decimal XML files, 0 failed" \
101 "maintenance check xml-descriptions \${srcdir}/../features"