public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Andrew Burgess <andrew.burgess@embecosm.com>
To: gdb-patches@sourceware.org
Subject: [PATCHv2 2/3] gdb/testsuite: Detect and warn about duplicate test names
Date: Mon, 27 Apr 2020 23:01:45 +0100	[thread overview]
Message-ID: <c5fb1d524514af85067e56f7308d61409477e39a.1588024848.git.andrew.burgess@embecosm.com> (raw)
In-Reply-To: <cover.1588024848.git.andrew.burgess@embecosm.com>

Building on the previous commit, this patch detects when two tests
have the same test name and causes Dejagnu to print a new result type
'# of duplicate test names' in the result summary.

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/check-test-names.exp (all_test_names): New global.
	(duplicate_test_names_seen): New global.
	(check_test_names): Check for duplicate test names.
	(log_summary): Warn about duplicate test names.
	(reset_vars): Reset counters for duplicate test names.
---
 gdb/testsuite/ChangeLog                |  8 +++++++
 gdb/testsuite/lib/check-test-names.exp | 32 +++++++++++++++++++++-----
 2 files changed, 34 insertions(+), 6 deletions(-)

diff --git a/gdb/testsuite/lib/check-test-names.exp b/gdb/testsuite/lib/check-test-names.exp
index 702dc6ef406..15c5544c8e4 100644
--- a/gdb/testsuite/lib/check-test-names.exp
+++ b/gdb/testsuite/lib/check-test-names.exp
@@ -19,13 +19,18 @@
 # to compare results between two runs of GDB from different trees.
 
 namespace eval ::CheckTestNames {
-    # An associative array of counts of tests that include a path in their
-    # test name.  There are two counts, 'count', which counts occurrences
-    # within a single variant run, and 'total', which counts across all
-    # variants.
+    # An associative array of all test names to the number of times each
+    # name is seen.  Used to detect duplicate test names.
+    variable all_test_names
+    array set all_test_names {}
+
+    # An associative array of counts of tests that either include a path in
+    # their test name, or have a duplicate test name.  There are two counts
+    # for each issue, 'count', which counts occurrences within a single
+    # variant run, and 'total', which counts across all variants.
     variable counts
     array set counts {}
-    foreach nm {paths} {
+    foreach nm {paths duplicates} {
 	set counts($nm,count) 0
 	set counts($nm,total) 0
     }
@@ -46,6 +51,7 @@ namespace eval ::CheckTestNames {
     # incremented.
     proc check { message } {
 	global srcdir objdir
+	variable all_test_names
 
 	foreach path [list $srcdir $objdir] {
 	    if { [ string first $path $message ] >= 0 } {
@@ -54,6 +60,16 @@ namespace eval ::CheckTestNames {
 		return
 	    }
 	}
+
+	# Initialise a count, or increment the count for this test name.
+	if {![info exists all_test_names($message)]} {
+	    set all_test_names($message) 0
+	} else {
+	    if {$all_test_names($message) == 0} {
+		inc_count duplicates
+	    }
+	    incr all_test_names($message)
+	}
     }
 
     # If COUNT is greater than zero, disply PREFIX followed by COUNT.
@@ -81,17 +97,21 @@ namespace eval ::CheckTestNames {
 
 	maybe_show_count "# of paths in test names\t" \
 	    $counts(paths,$which)
+	maybe_show_count "# of duplicate test names\t" \
+	    $counts(duplicates,$which)
     }
 
     # Rename Dejagnu's reset_vars procedure, and create do_reset_vars to
     # replace it.  We arrange to have do_reset_vars called later.
     rename ::reset_vars reset_vars
     proc do_reset_vars {} {
+	variable all_test_names
 	variable counts
 
 	CheckTestNames::reset_vars
 
-	foreach nm {paths} {
+	unset all_test_names
+	foreach nm {paths duplicates} {
 	    set counts($nm,count) 0
 	}
     }
-- 
2.25.3


  parent reply	other threads:[~2020-04-27 22:01 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 ` [PATCH 2/4] gdb/testsuite: Detect and warn if paths are used in " Andrew Burgess
2020-04-23 20:26   ` 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   ` Andrew Burgess [this message]
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=c5fb1d524514af85067e56f7308d61409477e39a.1588024848.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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).