]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/testsuite/gdb.gdb/unittest.exp
Automatic Copyright Year update after running gdb/copyright.py
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.gdb / unittest.exp
1 # Copyright 2016-2022 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 # 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
23 load_lib completion-support.exp
24
25 set do_xml_test [expr ![gdb_skip_xml_test]]
26
27 standard_testfile
28
29 if {[build_executable "failed to prepare" $testfile $srcfile debug]} {
30 return -1
31 }
32
33 proc run_selftests { binfile } {
34 global decimal gdb_prompt
35
36 if { $binfile == "" } {
37 gdb_exit
38 gdb_start
39 } else {
40 clean_restart ${binfile}
41 }
42
43 set enabled 1
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
50 # not timeout.
51 exp_continue
52 }
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"
58 }
59 -re "Selftests have been disabled for this build.\r\n$gdb_prompt $" {
60 unsupported $test
61 set enabled 0
62 }
63 }
64
65 return $enabled
66 }
67
68 # Test completion of command "maintenance selftest".
69
70 proc_with_prefix test_completion {} {
71 global self_tests_enabled
72
73 clean_restart
74
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" " "
80 } else {
81 test_gdb_complete_tab_none "maintenance selftest copy_"
82 test_gdb_complete_tab_none "maintenance selftest copy_bit"
83 }
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"
86 }
87
88 with_test_prefix "no executable loaded" {
89 set self_tests_enabled [run_selftests ""]
90 }
91
92 with_test_prefix "executable loaded" {
93 run_selftests ${binfile}
94 }
95
96 test_completion
97
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"
102 }