From: Andrew Burgess <andrew.burgess@embecosm.com>
To: gdb-patches@sourceware.org
Subject: [PATCH 2/4] gdb/testsuite: Detect and warn if paths are used in test names
Date: Thu, 23 Apr 2020 18:53:56 +0100 [thread overview]
Message-ID: <eb50c0087867409cc6459b66ddfb260ede3117e0.1587663712.git.andrew.burgess@embecosm.com> (raw)
In-Reply-To: <cover.1587663712.git.andrew.burgess@embecosm.com>
A new library is introduced that hooks into the core of Dejagnu and
detects when a test's name includes either the source or build paths.
If any offending test names are detected then Dejagnu will print a
new result type, '# of paths in test names'. Users should treat this
result type just like other bad results types, and aim not to increase
this number.
Currently for a local run on my machine, I don't see any offending
test names, but it is possible that different targets, or different
configurations, might currently be breaking the no paths rule.
In order to get this working I have needed to wrap two core Dejagnu
functions, log_summary, and reset_vars. Relying on core functions
that are not part of any API is always going to be risky, given the
relatively slow rate of Dejagnu change this is probably OK for now,
and we can possibly upstream some changes to Dejagnu that would allow
this functionality to be supported in a more official way later on.
Currently if the tests are run in parallel mode the new result type is
not merged into the combined summary file so users will need to run in
non-parallel mode to check this result. A later commit will fix this.
gdb/testsuite/ChangeLog:
* lib/gdb.exp: Include check-test-names.exp library.
* lib/check-test-names.exp: New file.
---
gdb/testsuite/ChangeLog | 5 ++
gdb/testsuite/lib/check-test-names.exp | 79 ++++++++++++++++++++++++++
gdb/testsuite/lib/gdb.exp | 1 +
3 files changed, 85 insertions(+)
create mode 100644 gdb/testsuite/lib/check-test-names.exp
diff --git a/gdb/testsuite/lib/check-test-names.exp b/gdb/testsuite/lib/check-test-names.exp
new file mode 100644
index 00000000000..6377ace3fc3
--- /dev/null
+++ b/gdb/testsuite/lib/check-test-names.exp
@@ -0,0 +1,79 @@
+# Copyright 2020 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 <http://www.gnu.org/licenses/>.
+
+# This library provides some protection against the introduction of
+# tests that include either the source of build paths in the test
+# name. When a test includes the path in its test name it is harder
+# to compare results between two runs of GDB from different trees.
+
+# Count the number of test names that contain either the source path,
+# or the build path.
+set paths_in_test_names 0
+
+# Check if MESSAGE contains either the source path or the build path.
+# This will result in test names that can't easily be compared between
+# different runs of GDB.
+#
+# Any offending paths in message cause PATHS_IN_TEST_NAMES to be
+# incremented.
+proc check_test_names { message } {
+ global srcdir objdir
+ global paths_in_test_names
+
+ foreach pattern [list $srcdir $objdir] {
+ if { [ regexp $pattern $message ] } {
+ # Count each test just once.
+ incr paths_in_test_names
+ return
+ }
+ }
+}
+
+# Arrange for CHECK_TEST_NAMES to be called.
+set local_record_procs(pass) "check_test_names"
+set local_record_procs(fail) "check_test_names"
+set local_record_procs(xfail) "check_test_names"
+set local_record_procs(kfail) "check_test_names"
+set local_record_procs(xpass) "check_test_names"
+set local_record_procs(kpass) "check_test_names"
+set local_record_procs(unresolved) "check_test_names"
+set local_record_procs(untested) "check_test_names"
+set local_record_procs(unsupported) "check_test_names"
+
+# Wrapper around the global Dejagnu LOG_SUMMARY procedure. Prints a
+# warning if any tests were found that contained either the source or
+# build paths.
+rename log_summary original_log_summary
+proc log_summary { args } {
+ global paths_in_test_names
+
+ # If ARGS is the empty list then we don't want to pass a single
+ # empty string as a parameter here.
+ eval "original_log_summary $args"
+
+ if { $paths_in_test_names > 0 } {
+ clone_output "# of paths in test names\t${paths_in_test_names}"
+ }
+}
+
+# Wrapper around the global Dejagnu RESET_VARS procedure, resets our
+# PATHS_IN_TEST_NAMES counter.
+rename reset_vars original_reset_vars
+proc reset_vars {} {
+ global paths_in_test_names
+
+ original_reset_vars
+ set paths_in_test_names 0
+}
diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index 8418c3d8753..a294b53f2c3 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -29,6 +29,7 @@ load_lib libgloss.exp
load_lib cache.exp
load_lib gdb-utils.exp
load_lib memory.exp
+load_lib check-test-names.exp
global GDB
--
2.25.3
next prev parent reply other threads:[~2020-04-23 17:54 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-23 17:53 [PATCH 0/4] Automatic detection of test name problems Andrew Burgess
2020-04-23 17:53 ` [PATCH 1/4] gdb/testsuite: Remove build paths from test names Andrew Burgess
2020-04-24 14:00 ` Simon Marchi
2020-04-23 17:53 ` Andrew Burgess [this message]
2020-04-23 20:26 ` [PATCH 2/4] gdb/testsuite: Detect and warn if paths are used in " Keith Seitz
2020-04-27 15:58 ` Andrew Burgess
2020-04-27 16:42 ` Keith Seitz
2020-04-27 19:06 ` Andrew Burgess
2020-04-23 17:53 ` [PATCH 3/4] gdb/testsuite: Detect and warn about duplicate " Andrew Burgess
2020-04-23 20:28 ` Keith Seitz
2020-04-23 17:53 ` [PATCH 4/4] contrib: Handle GDB specific test result types Andrew Burgess
2020-04-23 20:25 ` [PATCH 0/4] Automatic detection of test name problems Keith Seitz
2020-04-27 22:01 ` [PATCHv2 0/3] " Andrew Burgess
2020-04-27 22:01 ` [PATCHv2 1/3] gdb/testsuite: Detect and warn if paths are used in test names Andrew Burgess
2020-04-27 22:01 ` [PATCHv2 2/3] gdb/testsuite: Detect and warn about duplicate " Andrew Burgess
2020-04-27 22:01 ` [PATCHv2 3/3] contrib: Handle GDB specific test result types Andrew Burgess
2020-04-28 19:08 ` [PATCHv2 0/3] Automatic detection of test name problems Keith Seitz
2020-04-29 9:02 ` Andrew Burgess
2020-04-29 15:04 ` Simon Marchi
2020-04-29 15:38 ` Andrew Burgess
2020-04-29 16:03 ` Keith Seitz
2020-04-29 18:22 ` Simon Marchi
2020-04-30 11:20 ` [PATCHv3 " Andrew Burgess
2020-04-30 11:20 ` [PATCHv3 1/3] gdb/testsuite: Detect and warn if paths are used in test names Andrew Burgess
2020-04-30 11:20 ` [PATCHv3 2/3] gdb/testsuite: Detect and warn about duplicate " Andrew Burgess
2020-07-31 21:34 ` Simon Marchi
2020-08-03 10:02 ` Andrew Burgess
2020-08-03 12:18 ` Simon Marchi
2020-04-30 11:20 ` [PATCHv3 3/3] contrib: Handle GDB specific test result types Andrew Burgess
2020-04-30 18:01 ` [PATCHv3 0/3] Automatic detection of test name problems Tom Tromey
2020-05-11 21:30 ` Andrew Burgess
2020-05-12 16:48 ` Andrew Burgess
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=eb50c0087867409cc6459b66ddfb260ede3117e0.1587663712.git.andrew.burgess@embecosm.com \
--to=andrew.burgess@embecosm.com \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox