From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from barracuda.ebox.ca (barracuda.ebox.ca [96.127.255.19]) by sourceware.org (Postfix) with ESMTPS id 410733855007 for ; Wed, 16 Jun 2021 19:37:55 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 410733855007 X-ASG-Debug-ID: 1623872273-0c856e67e215c4a20001-fS2M51 Received: from smtp.ebox.ca (smtp.ebox.ca [96.127.255.82]) by barracuda.ebox.ca with ESMTP id mImJ4Ngd3p5QCngX (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 16 Jun 2021 15:37:53 -0400 (EDT) X-Barracuda-Envelope-From: simon.marchi@efficios.com X-Barracuda-RBL-Trusted-Forwarder: 96.127.255.82 Received: from epycamd.internal.efficios.com (192-222-181-218.qc.cable.ebox.net [192.222.181.218]) by smtp.ebox.ca (Postfix) with ESMTP id 9E6CA441B21; Wed, 16 Jun 2021 15:37:53 -0400 (EDT) From: Simon Marchi X-Barracuda-RBL-IP: 192.222.181.218 X-Barracuda-Effective-Source-IP: 192-222-181-218.qc.cable.ebox.net[192.222.181.218] X-Barracuda-Apparent-Source-IP: 192.222.181.218 To: gdb-patches@sourceware.org Cc: Simon Marchi Subject: [PATCH 1/4] gdb/testsuite: gdb.base/args.exp: use save_vars Date: Wed, 16 Jun 2021 15:37:48 -0400 X-ASG-Orig-Subj: [PATCH 1/4] gdb/testsuite: gdb.base/args.exp: use save_vars Message-Id: <20210616193751.468795-1-simon.marchi@efficios.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Barracuda-Connect: smtp.ebox.ca[96.127.255.82] X-Barracuda-Start-Time: 1623872273 X-Barracuda-Encrypted: DHE-RSA-AES256-SHA X-Barracuda-URL: https://96.127.255.19:443/cgi-mod/mark.cgi X-Barracuda-BRTS-Status: 1 X-Virus-Scanned: by bsmtpd at ebox.ca X-Barracuda-Scan-Msg-Size: 3397 X-Barracuda-Spam-Score: 0.00 X-Barracuda-Spam-Status: No, SCORE=0.00 using global scores of TAG_LEVEL=1000.0 QUARANTINE_LEVEL=1000.0 KILL_LEVEL=8.0 tests= X-Barracuda-Spam-Report: Code version 3.2, rules version 3.2.3.90692 Rule breakdown below pts rule name description ---- ---------------------- -------------------------------------------------- X-Spam-Status: No, score=-22.0 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_NONE, KAM_DMARC_STATUS, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_SOFTFAIL, 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: Wed, 16 Jun 2021 19:37:56 -0000 Use save_vars instead of manually saving/restoring. This ensures that if anything throws an error, GDBFLAGS will be correctly restored. Remove the global GDBFLAGS declaration at the top, it's not necessary. gdb/testsuite/ChangeLog: * gdb.base/args.exp: Use save_vars. Change-Id: I3a45e4fc1635ec0212de2415040f91eecaf4a057 --- gdb/testsuite/gdb.base/args.exp | 56 ++++++++++++++++----------------- 1 file changed, 27 insertions(+), 29 deletions(-) diff --git a/gdb/testsuite/gdb.base/args.exp b/gdb/testsuite/gdb.base/args.exp index e848c70a482..bff750dff24 100644 --- a/gdb/testsuite/gdb.base/args.exp +++ b/gdb/testsuite/gdb.base/args.exp @@ -15,9 +15,6 @@ # This is a test for the gdb invocation option --args. - -global GDBFLAGS - # Skip test if target does not support argument passing. if [target_info exists noargs] { return @@ -64,39 +61,40 @@ proc args_test { name arglist } { # # Test that the --args are processed correctly. # -set old_gdbflags $GDBFLAGS -set GDBFLAGS "$old_gdbflags --args $binfile 1 3" -args_test basic {{1} {3}} +save_vars { GDBFLAGS } { + set old_gdbflags $GDBFLAGS -# -# Test that the --args are processed correctly even if one of them is empty. -# The syntax needed is a little peculiar; DejaGNU treats the arguments as a -# list and expands them itself, since no shell redirection is involved. -# -set GDBFLAGS "$old_gdbflags --args $binfile 1 {} 3" -args_test "one empty" {{1} {} {3}} + set GDBFLAGS "$old_gdbflags --args $binfile 1 3" + args_test basic {{1} {3}} -# -# try with 2 empty args -# -set GDBFLAGS "$old_gdbflags --args $binfile 1 {} {} 3" -args_test "two empty" {{1} {} {} 3} + # + # Test that the --args are processed correctly even if one of them is empty. + # The syntax needed is a little peculiar; DejaGNU treats the arguments as a + # list and expands them itself, since no shell redirection is involved. + # + set GDBFLAGS "$old_gdbflags --args $binfile 1 {} 3" + args_test "one empty" {{1} {} {3}} -# Try with arguments containing literal single quotes. + # + # try with 2 empty args + # + set GDBFLAGS "$old_gdbflags --args $binfile 1 {} {} 3" + args_test "two empty" {{1} {} {} 3} -set GDBFLAGS "$old_gdbflags --args $binfile 1 '' 3" -args_test "one empty (with single quotes)" {{1} {''} {3}} + # Try with arguments containing literal single quotes. -set GDBFLAGS "$old_gdbflags --args $binfile 1 '' '' 3" -args_test "two empty (with single quotes)" {{1} {''} {''} {3}} + set GDBFLAGS "$old_gdbflags --args $binfile 1 '' 3" + args_test "one empty (with single quotes)" {{1} {''} {3}} -# try with arguments containing literal newlines. + set GDBFLAGS "$old_gdbflags --args $binfile 1 '' '' 3" + args_test "two empty (with single quotes)" {{1} {''} {''} {3}} -set GDBFLAGS "-nx --args $binfile 1 {\n} 3" -args_test "one newline" {{1} {\\n} {3}} + # try with arguments containing literal newlines. -set GDBFLAGS "-nx --args $binfile 1 {\n} {\n} 3" -args_test "two newlines" {{1} {\\n} {\\n} {3}} + set GDBFLAGS "-nx --args $binfile 1 {\n} 3" + args_test "one newline" {{1} {\\n} {3}} -set GDBFLAGS $old_gdbflags + set GDBFLAGS "-nx --args $binfile 1 {\n} {\n} 3" + args_test "two newlines" {{1} {\\n} {\\n} {3}} +} -- 2.31.1