From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by sourceware.org (Postfix) with ESMTPS id 2CA41389851B for ; Thu, 11 Jun 2020 16:25:54 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 2CA41389851B Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=tdevries@suse.de X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 03802AD31; Thu, 11 Jun 2020 16:25:56 +0000 (UTC) Subject: Re: [PATCH][gdb/testsuite] Don't abort testrun for invalid command in test-case To: Pedro Alves , gdb-patches@sourceware.org References: <20200611143522.GA19667@delia> <7d7ce523-b58c-a77d-15be-8091feb6389a@redhat.com> From: Tom de Vries Autocrypt: addr=tdevries@suse.de; keydata= xsBNBF0ltCcBCADDhsUnMMdEXiHFfqJdXeRvgqSEUxLCy/pHek88ALuFnPTICTwkf4g7uSR7 HvOFUoUyu8oP5mNb4VZHy3Xy8KRZGaQuaOHNhZAT1xaVo6kxjswUi3vYgGJhFMiLuIHdApoc u5f7UbV+egYVxmkvVLSqsVD4pUgHeSoAcIlm3blZ1sDKviJCwaHxDQkVmSsGXImaAU+ViJ5l CwkvyiiIifWD2SoOuFexZyZ7RUddLosgsO0npVUYbl6dEMq2a5ijGF6/rBs1m3nAoIgpXk6P TCKlSWVW6OCneTaKM5C387972qREtiArTakRQIpvDJuiR2soGfdeJ6igGA1FZjU+IsM5ABEB AAHNH1RvbSBkZSBWcmllcyA8dGRldnJpZXNAc3VzZS5kZT7CwKsEEwEIAD4WIQSsnSe5hKbL MK1mGmjuhV2rbOJEoAUCXSW0JwIbAwUJA8JnAAULCQgHAgYVCgkICwIEFgIDAQIeAQIXgAAh CRDuhV2rbOJEoBYhBKydJ7mEpsswrWYaaO6FXats4kSgc48H/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y7jyBsP5QxeTqwxC/1ZtNS DUCSFQjqA6bEGwM22dP8OUY6SC94x1G81A9/xbtm9LQxKm0EiDH8KBMLfQ== Message-ID: <18e36963-4f04-f871-33fb-89a5d1683bbd@suse.de> Date: Thu, 11 Jun 2020 18:25:52 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.5.0 MIME-Version: 1.0 In-Reply-To: <7d7ce523-b58c-a77d-15be-8091feb6389a@redhat.com> Content-Type: multipart/mixed; boundary="------------CEA839F7ECA6999DF8839321" Content-Language: en-US X-Spam-Status: No, score=-16.0 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, 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: Thu, 11 Jun 2020 16:25:57 -0000 This is a multi-part message in MIME format. --------------CEA839F7ECA6999DF8839321 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit On 11-06-2020 17:31, Pedro Alves wrote: > On 6/11/20 3:35 PM, Tom de Vries wrote: >> Hi, >> >> Say we add a call to foobar at the end of a test-case, and run the >> test-suite. We'll run into a dejagnu error: >> ... >> ERROR: (DejaGnu) proc "foobar" does not exist. >> ... >> and the test-suite run is aborted. >> >> It's reasonable that the test-case is aborted, but it's not reasonable that >> the testsuite run is aborted. >> >> Problems in one test-case should not leak into other test-cases, and they >> generally don't. The exception is the "invalid command name" problem due to >> an override of ::unknown in dejagnu's framework.exp. >> >> Fix this by limiting the scope of dejagnu's ::unknown override. >> >> Tested on x86_64-linux. >> >> Any comments? > > We should ask the DejaGnu folks to make the exiting on error > optional, so that in a future version we can drop the hack. > Agreed. > What about, say, an error due to calling a tcl proc with the wrong > arguments? "unknown" isn't called for that. Any idea how to > catch those? > If I do: ... diff --git a/gdb/testsuite/gdb.ada/O2_float_param.exp b/gdb/testsuite/gdb.ada/O2_float_param.exp index 09ebeec405..afbf6c5ace 100644 --- a/gdb/testsuite/gdb.ada/O2_float_param.exp +++ b/gdb/testsuite/gdb.ada/O2_float_param.exp @@ -29,3 +29,9 @@ runto "increment" gdb_test "frame" \ "#0\\s+callee\\.increment \\(val(=val@entry)?=99\\.0, msg=\\.\\.\\.\\).*" + +proc foo { a b c } { + +} + +foo ... and run the test-suite, I get: ... Running /data/gdb_versions/devel/src/gdb/testsuite/gdb.ada/O2_float_param.exp ... ERROR: tcl error sourcing /data/gdb_versions/devel/src/gdb/testsuite/gdb.ada/O2_float_param.exp. ERROR: wrong # args: should be "foo a b c" while executing "foo" (file "/data/gdb_versions/devel/src/gdb/testsuite/gdb.ada/O2_float_param.exp" line 37) invoked from within "source /data/gdb_versions/devel/src/gdb/testsuite/gdb.ada/O2_float_param.exp" ("uplevel" body line 1) invoked from within "uplevel #0 source /data/gdb_versions/devel/src/gdb/testsuite/gdb.ada/O2_float_param.exp" invoked from within "catch "uplevel #0 source $test_file_name"" Running /data/gdb_versions/devel/src/gdb/testsuite/gdb.ada/access_tagged_param.exp ... Running /data/gdb_versions/devel/src/gdb/testsuite/gdb.ada/access_to_packed_array.exp ... ... ... So, the error is caught in proc runtest: ... if { [catch "uplevel #0 source $test_file_name"] == 1 } { ... >> +# Save the unknown proc defined by dejagnu. >> +rename ::unknown ::dejagnu_unknown >> + >> +# Override the unknown proc with a gdb-local version. >> +proc unknown { args } { >> + set script [info script] >> + >> + set script [file dirname $script] >> + set subdir3 [file tail $script] >> + >> + set script [file dirname $script] >> + set subdir2 [file tail $script] >> + >> + set script [file dirname $script] >> + set subdir1 [file tail $script] >> + >> + if { $subdir1 == "gdb" >> + && $subdir2 == "testsuite" >> + && [regexp {^gdb[.]} $subdir3] } { >> + # If we're executing a gdb test-case, skip dejagnu_unknown to prevent >> + # it from exiting and aborting the entire test run. >> + return [uplevel 1 ::tcl_unknown $args] >> + } >> + > > I'd think it would be cleaner to override unknown in gdb_init, > and restore in gdb_finish. No need for filename matching that way. > Like below. Any reason you didn't go for this instead? > I don't think it's cleaner, because we run default_gdb_init, as well the bit of proc runtest between ${tool}_init a ${tool}_finish with the altered ::unknown. Alternatively, we could override source to detect the precise point that runtest hands control to the test-case, as attached. But there's still filename matching. [ Note btw, that this approach changes the scope of the fix slightly. ] Thanks, - Tom --------------CEA839F7ECA6999DF8839321 Content-Type: text/x-patch; charset=UTF-8; name="0001-gdb-testsuite-Don-t-abort-testrun-for-invalid-command-in-test-case.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename*0="0001-gdb-testsuite-Don-t-abort-testrun-for-invalid-command-i"; filename*1="n-test-case.patch" [gdb/testsuite] Don't abort testrun for invalid command in test-case Say we add a call to foobar at the end of a test-case, and run the test-suite. We'll run into a dejagnu error: ... ERROR: (DejaGnu) proc "foobar" does not exist. ... and the test-suite run is aborted. It's reasonable that the test-case is aborted, but it's not reasonable that the testsuite run is aborted. Problems in one test-case should not leak into other test-cases, and they generally don't. The exception is the "invalid command name" problem due to an override of ::unknown in dejagnu's framework.exp. Fix this by limiting the scope of dejagnu's ::unknown override. Tested on x86_64-linux. gdb/testsuite/ChangeLog: 2020-06-11 Tom de Vries PR testsuite/26110 * lib/gdb.exp (gdb_unknown): New proc. (::tcl_source): Rename from ::source. (source): New proc. --- gdb/testsuite/lib/gdb.exp | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp index 51f8a05464..ae6d561a10 100644 --- a/gdb/testsuite/lib/gdb.exp +++ b/gdb/testsuite/lib/gdb.exp @@ -7243,5 +7243,35 @@ proc with_override { name override body } { return $result } +proc gdb_unknown { args } { + # Skip dejagnu_unknown to prevent it from exiting and aborting the entire + # test run. + return [uplevel 1 ::tcl_unknown $args] +} + +rename ::source ::tcl_source + +proc source { arg } { + set script $arg + + set script [file dirname $script] + set subdir3 [file tail $script] + + set script [file dirname $script] + set subdir2 [file tail $script] + + set script [file dirname $script] + set subdir1 [file tail $script] + + if { $subdir1 == "gdb" + && $subdir2 == "testsuite" + && [regexp {^gdb[.]} $subdir3] } { + return \ + [uplevel 1 with_override ::unknown gdb_unknown \"::tcl_source $arg\"] + } + + return [uplevel 1 ::tcl_source $arg] +} + # Always load compatibility stuff. load_lib future.exp --------------CEA839F7ECA6999DF8839321--