Automatic Copyright Year update after running gdb/copyright.py
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.base / info_sources.exp
CommitLineData
88b9d363 1# Copyright 2019-2022 Free Software Foundation, Inc.
db4dc13e
PW
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
18standard_testfile .c info_sources_base.c
19
20if {[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.
30proc test_info_sources {args expect_seen_info_sources expect_seen_info_sources_base} {
9fc29955 31 global gdb_prompt srcfile srcfile2
db4dc13e
PW
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 {
9fc29955
AB
37 -re "^\[^,\]*${srcfile}(, |\[\r\n\]+)" {
38 incr seen_info_sources
db4dc13e
PW
39 exp_continue
40 }
9fc29955
AB
41 -re "^\[^,\]*${srcfile2}(, |\[\r\n\]+)" {
42 incr seen_info_sources_base 1
db4dc13e
PW
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
59if ![runto_main] {
60 untested $testfile.exp
61 return -1
62}
db4dc13e 63
9fc29955
AB
64# List both files with no regexp:
65with_test_prefix "in main" {
66 test_info_sources "" 1 1
67}
68
69gdb_test "break some_other_func" ""
db4dc13e
PW
70gdb_test "continue"
71
72# List both files with no regexp:
73test_info_sources "" 1 1
74# Same but with option terminator:
75test_info_sources "--" 1 1
76
77# List both files with regexp matching anywhere in the filenames:
78test_info_sources "info_sources" 1 1
74e4b667
SL
79if { ! [is_remote host] } {
80 test_info_sources "gdb.base" 1 1
81}
db4dc13e
PW
82
83# List both files with regexp matching the filename basenames,
84# using various parts of the -basename option:
85test_info_sources "-b info_sources" 1 1
86test_info_sources "-basename info_sources" 1 1
87test_info_sources "-b -- info_sources" 1 1
88test_info_sources "-ba info_sources" 1 1
89test_info_sources "-base -- info_sources" 1 1
90test_info_sources "-basena info_sources" 1 1
91test_info_sources "-basename -- info_sources" 1 1
92
93# List only the file with basename matching regexp:
94test_info_sources "-b base" 0 1
95
96# List the files with dirname matching regexp,
97# using various part of the -dirname option:
74e4b667
SL
98if { ! [is_remote host] } {
99 test_info_sources "-d base" 1 1
100 test_info_sources "-dirname base" 1 1
101}
db4dc13e
PW
102
103# Test non matching regexp, with option terminator:
104test_info_sources "-b -- -d" 0 0
105test_info_sources "-d -- -d" 0 0
This page took 0.43813 seconds and 4 git commands to generate.