From db4dc13eebbd73cddfe3abb6c001982c7bdbba3f Mon Sep 17 00:00:00 2001 From: Philippe Waroquiers Date: Sun, 31 Mar 2019 20:12:22 +0200 Subject: [PATCH] New test for 'info sources [-dirname | -basename] [--] [REGEXP]'. This patch introduces a test for the 'info sources' command and its new arguments [-dirname | -basename] [--] [REGEXP]. gdb/testsuite/ChangeLog 2019-08-03 Philippe Waroquiers * gdb.base/info_sources.exp: New file. * gdb.base/info_sources.c: New file. * gdb.base/info_sources_base.c: New file. --- gdb/testsuite/ChangeLog | 6 ++ gdb/testsuite/gdb.base/info_sources.c | 23 ++++++ gdb/testsuite/gdb.base/info_sources.exp | 96 ++++++++++++++++++++++ gdb/testsuite/gdb.base/info_sources_base.c | 22 +++++ 4 files changed, 147 insertions(+) create mode 100644 gdb/testsuite/gdb.base/info_sources.c create mode 100644 gdb/testsuite/gdb.base/info_sources.exp create mode 100644 gdb/testsuite/gdb.base/info_sources_base.c diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index 09878b6059d..91814f24c4e 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2019-08-03 Philippe Waroquiers + + * gdb.base/info_sources.exp: New file. + * gdb.base/info_sources.c: New file. + * gdb.base/info_sources_base.c: New file. + 2019-08-01 Pedro Franco de Carvalho * gdb.base/batch-exit-status.exp: Call test_exit_status with diff --git a/gdb/testsuite/gdb.base/info_sources.c b/gdb/testsuite/gdb.base/info_sources.c new file mode 100644 index 00000000000..75fab6df703 --- /dev/null +++ b/gdb/testsuite/gdb.base/info_sources.c @@ -0,0 +1,23 @@ +/* This testcase is part of GDB, the GNU debugger. + + Copyright 2019 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +extern void some_other_func (void); +int main () +{ + some_other_func (); + return 0; +} diff --git a/gdb/testsuite/gdb.base/info_sources.exp b/gdb/testsuite/gdb.base/info_sources.exp new file mode 100644 index 00000000000..6a883ac0f51 --- /dev/null +++ b/gdb/testsuite/gdb.base/info_sources.exp @@ -0,0 +1,96 @@ +# Copyright 2019 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# Test 'info sources [-d | -b] [--] [REGEX]' + +standard_testfile .c info_sources_base.c + +if {[prepare_for_testing $testfile.exp $testfile \ + [list $srcfile $srcfile2] debug]} { + untested $testfile.exp + return -1 +} + +# Executes "info sources " $args. +# EXPECT_SEEN_INFO_SOURCES 1 indicates that the source file info_sources.c must be seen +# in the output. Similarly, EXPECT_SEEN_INFO_SOURCES_BASE indicates that the source file +# info_sources_base.c must be seen in the output. +proc test_info_sources {args expect_seen_info_sources expect_seen_info_sources_base} { + global gdb_prompt + + set seen_info_sources 0 + set seen_info_sources_base 0 + set cmd [concat "info sources " $args] + gdb_test_multiple $cmd $cmd { + -re "^\[^,\]*info_sources.c(, |\[\r\n\]+)" { + set seen_info_sources 1 + exp_continue + } + -re "^\[^,\]*info_sources_base.c(, |\[\r\n\]+)" { + set seen_info_sources_base 1 + exp_continue + } + -re ", " { + exp_continue + } + -re "$gdb_prompt $" { + if {$seen_info_sources == $expect_seen_info_sources \ + && $seen_info_sources_base == $expect_seen_info_sources_base} { + pass $cmd + } else { + fail $cmd + } + } + } +} + +if ![runto_main] { + untested $testfile.exp + return -1 +} +gdb_test "break some_other_func" "" + +gdb_test "continue" + +# List both files with no regexp: +test_info_sources "" 1 1 +# Same but with option terminator: +test_info_sources "--" 1 1 + +# List both files with regexp matching anywhere in the filenames: +test_info_sources "info_sources" 1 1 +test_info_sources "gdb.base" 1 1 + +# List both files with regexp matching the filename basenames, +# using various parts of the -basename option: +test_info_sources "-b info_sources" 1 1 +test_info_sources "-basename info_sources" 1 1 +test_info_sources "-b -- info_sources" 1 1 +test_info_sources "-ba info_sources" 1 1 +test_info_sources "-base -- info_sources" 1 1 +test_info_sources "-basena info_sources" 1 1 +test_info_sources "-basename -- info_sources" 1 1 + +# List only the file with basename matching regexp: +test_info_sources "-b base" 0 1 + +# List the files with dirname matching regexp, +# using various part of the -dirname option: +test_info_sources "-d base" 1 1 +test_info_sources "-dirname base" 1 1 + +# Test non matching regexp, with option terminator: +test_info_sources "-b -- -d" 0 0 +test_info_sources "-d -- -d" 0 0 diff --git a/gdb/testsuite/gdb.base/info_sources_base.c b/gdb/testsuite/gdb.base/info_sources_base.c new file mode 100644 index 00000000000..8eae23b240c --- /dev/null +++ b/gdb/testsuite/gdb.base/info_sources_base.c @@ -0,0 +1,22 @@ +/* This testcase is part of GDB, the GNU debugger. + + Copyright 2019 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +void some_other_func (void) +{ + return; +} + -- 2.30.2