Fix skip.exp test failure observed with gcc-9.2.0
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.base / info_sources.exp
1 # Copyright 2019 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 'info sources [-d | -b] [--] [REGEX]'
17
18 standard_testfile .c info_sources_base.c
19
20 if {[prepare_for_testing $testfile.exp $testfile \
21 [list $srcfile $srcfile2] debug]} {
22 untested $testfile.exp
23 return -1
24 }
25
26 # Executes "info sources " $args.
27 # EXPECT_SEEN_INFO_SOURCES 1 indicates that the source file info_sources.c must be seen
28 # in the output. Similarly, EXPECT_SEEN_INFO_SOURCES_BASE indicates that the source file
29 # info_sources_base.c must be seen in the output.
30 proc test_info_sources {args expect_seen_info_sources expect_seen_info_sources_base} {
31 global gdb_prompt
32
33 set seen_info_sources 0
34 set seen_info_sources_base 0
35 set cmd [concat "info sources " $args]
36 gdb_test_multiple $cmd $cmd {
37 -re "^\[^,\]*info_sources.c(, |\[\r\n\]+)" {
38 set seen_info_sources 1
39 exp_continue
40 }
41 -re "^\[^,\]*info_sources_base.c(, |\[\r\n\]+)" {
42 set seen_info_sources_base 1
43 exp_continue
44 }
45 -re ", " {
46 exp_continue
47 }
48 -re "$gdb_prompt $" {
49 if {$seen_info_sources == $expect_seen_info_sources \
50 && $seen_info_sources_base == $expect_seen_info_sources_base} {
51 pass $cmd
52 } else {
53 fail $cmd
54 }
55 }
56 }
57 }
58
59 if ![runto_main] {
60 untested $testfile.exp
61 return -1
62 }
63 gdb_test "break some_other_func" ""
64
65 gdb_test "continue"
66
67 # List both files with no regexp:
68 test_info_sources "" 1 1
69 # Same but with option terminator:
70 test_info_sources "--" 1 1
71
72 # List both files with regexp matching anywhere in the filenames:
73 test_info_sources "info_sources" 1 1
74 test_info_sources "gdb.base" 1 1
75
76 # List both files with regexp matching the filename basenames,
77 # using various parts of the -basename option:
78 test_info_sources "-b info_sources" 1 1
79 test_info_sources "-basename info_sources" 1 1
80 test_info_sources "-b -- info_sources" 1 1
81 test_info_sources "-ba info_sources" 1 1
82 test_info_sources "-base -- info_sources" 1 1
83 test_info_sources "-basena info_sources" 1 1
84 test_info_sources "-basename -- info_sources" 1 1
85
86 # List only the file with basename matching regexp:
87 test_info_sources "-b base" 0 1
88
89 # List the files with dirname matching regexp,
90 # using various part of the -dirname option:
91 test_info_sources "-d base" 1 1
92 test_info_sources "-dirname base" 1 1
93
94 # Test non matching regexp, with option terminator:
95 test_info_sources "-b -- -d" 0 0
96 test_info_sources "-d -- -d" 0 0
This page took 0.031766 seconds and 4 git commands to generate.