From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr1-x444.google.com (mail-wr1-x444.google.com [IPv6:2a00:1450:4864:20::444]) by sourceware.org (Postfix) with ESMTPS id E73D7386F012 for ; Mon, 27 Apr 2020 15:59:00 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org E73D7386F012 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=embecosm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=andrew.burgess@embecosm.com Received: by mail-wr1-x444.google.com with SMTP id d17so21192775wrg.11 for ; Mon, 27 Apr 2020 08:59:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=embecosm.com; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=om72V070EI02iORcE9+lJR+6RKbVUQSgG94fRbgP2T8=; b=ZH91acCxAmdAa6ckN99evv+SzsEUtpq1W+h/mNrcoVkXp/NO5kwxhCymbJQ+iuUG1Z PoM3pII/LDinf6p1Pmqulkav8ob87MzJ2SKvyMcYkPp0v8WjQ454qW2/oIZaKJ9Wd9XU jCmdICPtvMOYey529VAk6r6JhoXedMenJ3AveYp900ct3iKheYxsXIebcrv9e0YBYgc1 Z0ftmBtddtgX0XqWEPhW1K7rGo2vyJJyEoLTSHcea+WjFMEsfXAqFncQborw9DotJ7V1 Kwi3cyHv92ZS7foZJo/1rg2yYNKScW6QFPRg+TDu63AO0a3rwID1aW/yIfB+8cW487yt 4fRA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=om72V070EI02iORcE9+lJR+6RKbVUQSgG94fRbgP2T8=; b=UsDv2PPYFkurUm+T6JKEi9xh5QSd1rGQbu0u6kts66XqvPbFkgUU19UkgPN+wNj4Bm 1fV/U7Ceslhq7j4XVW+h9e6HfUTscKbPArDDZDVj4siOTYSpcVdg82qSw66Jp5tiOC1w grgG9oWrF19a1hEmnh2ZSwRiWXGRXJiTssm7OGVpkDH5FWxfr4K8WTXReQFZmmvS6PG1 WitwyHQzrCXt8p2JXCHLLDQr26FOHvM/UfLZ2uGyy5QNwTxw68W8IDAnivkLoxerMQmh 1YKJz0RDhJIVtEs2vlMPdnkg8IhDuUr7yOVtYx3qMiLKytyUbO5pdCRVf0V+K0gb/cdh xkNA== X-Gm-Message-State: AGi0Pub5OFaHH0CydrSSsP5Xcu/pFahw26ikBDBdjWhVtXQU0uYQ3lfI h7xBoaitQUyvJAmSWr5PxClSRIqEf7k= X-Google-Smtp-Source: APiQypKjFpjbajRwBqvDwmpDy11IshWHNN1faJm5aZtLJljOru+P6zoXcGgmdjSeFSuL+2+krux3sw== X-Received: by 2002:adf:ce0d:: with SMTP id p13mr29927611wrn.66.1588003139944; Mon, 27 Apr 2020 08:58:59 -0700 (PDT) Received: from localhost (host81-151-181-184.range81-151.btcentralplus.com. [81.151.181.184]) by smtp.gmail.com with ESMTPSA id a10sm10772159wrg.32.2020.04.27.08.58.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Apr 2020 08:58:59 -0700 (PDT) Date: Mon, 27 Apr 2020 16:58:58 +0100 From: Andrew Burgess To: Keith Seitz Cc: gdb-patches@sourceware.org Subject: Re: [PATCH 2/4] gdb/testsuite: Detect and warn if paths are used in test names Message-ID: <20200427155858.GG3522@embecosm.com> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Operating-System: Linux/5.5.17-200.fc31.x86_64 (x86_64) X-Uptime: 16:56:11 up 7 days, 45 min, X-Editor: GNU Emacs [ http://www.gnu.org/software/emacs ] X-Spam-Status: No, score=-24.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 27 Apr 2020 15:59:02 -0000 * Keith Seitz [2020-04-23 13:26:30 -0700]: > On 4/23/20 10:53 AM, Andrew Burgess wrote: > > 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. > Just a few comments/questions inline. > > Keith > > > 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 . > > + > > +# 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 > > This patch series introduces several new entities into the global scope. > Can they be wrapped in a namespace to protect them from users/collisions? > > This is the approach taken by other libraries such as the dwarf assembler. > > > +# 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 ] } { > > Are srcdir/objdir really regular expressions? > > `regexp' seems really heavy-handed if they are just strings. `string first > would be much faster. [Not that it really matters here, but the Tcl pedantic > in me escapes every now and again. I shall attempt to apprehend him.] > > > + # Count each test just once. > > + incr paths_in_test_names > > + return > > + } > > + } > > +} > > > +# Arrange for CHECK_TEST_NAMES to be called. > > I admit, I had to grep sources to figure out that this is an > (AFAICT undocumented) DejaGNU feature. Perhaps "Arrange for > DejaGNU to call ..." or similar might be clearer? > > > +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" > > Since I failed to contain the Tcl pedantic in me, the above > can be more Tcl-ishly written with `array set', but I am not > requesting that you change anything. Just FYI. Thanks for your feedback, I'm making a few changes to the patch, but I wanted to follow up on the 'array set' issue, I'd like to get things right where I can, however, in this case.... $ tclsh % array set foo {} % array set foo(bar) 1 list must have an even number of elements This is inline with what I see when I try to use 'array set ....' within the Dejagnu script, I get the error 'list must have an even number of elements'. Is there something I'm doing wrong here? Or is 'array set' not actually needed in this case? Thanks, Andrew > > > +# 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 } { > > Yeah, yuck. I see what you mean. IMO, it is what it is. > Not to mention we'd have to backport to numerous flavors of dejagnu or > get everyone using the same one. Double yuck. > > Lesser of two evils. > > > + 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 > > > > >