From patchwork Wed Sep 27 17:27:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Burgess X-Patchwork-Id: 76792 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id BB0973875463 for ; Wed, 27 Sep 2023 17:29:02 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org BB0973875463 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1695835742; bh=dMCnzAUBv4x5wdKLT2L0TstnMWoykZtsQkW7hTpu/Tg=; h=To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=Fdz5EkQMlbUVErGih8pnqxVIOYFVFchqFCp7cQQ6UjTAroYqVch/RNeeHXG2nTFQU 0Xxc6zOimbwszO0BymPgXe6GeQaZEhflbK86k03ak8EsPklheVgnEpYIgDBQY95pHe 6QlL6cW8Fu+O4l0CpS/88+zlP8RhoZVCwcoEsVYs= X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 437A73861864 for ; Wed, 27 Sep 2023 17:28:14 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 437A73861864 Received: from mail-qk1-f200.google.com (mail-qk1-f200.google.com [209.85.222.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-185-qoQ_mkXYO3qcWj_H2QCOFQ-1; Wed, 27 Sep 2023 13:28:12 -0400 X-MC-Unique: qoQ_mkXYO3qcWj_H2QCOFQ-1 Received: by mail-qk1-f200.google.com with SMTP id af79cd13be357-77574c4394aso312279885a.2 for ; Wed, 27 Sep 2023 10:28:12 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695835692; x=1696440492; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=dMCnzAUBv4x5wdKLT2L0TstnMWoykZtsQkW7hTpu/Tg=; b=tNd1Gf1LL4G1NTKW4g3LQT6nVmaGGRXDtLgFIsI+kbQ9FUv2OQGub+v989qNzjeLEY 0XIKzfKcpTwiphLi5Leeb6S6BPAadfxZyPPW/youxFdWCt0/PrJlxKjI0stW1KfRnUR4 iQHW3ZCfJsdi0JQQdhqfb2EFNKxoxkfaChFvfk1dOmqKY22rU6UnjbuiGdCDSLKwiOlb cA+V6tMrANUvNXhI9mVftNf9LQM9cs8Xju+3bvTTbWWK9n8FBLtUi+JR31dYXRU1gK2+ TlHZ9xnjWs8LhMh8TDKiHuMOD8jV2zSEQTZi/uT9KxpuclJ/jX04or8szLQSJVYVkAM3 3eqw== X-Gm-Message-State: AOJu0YxRQv4VPqROCHtAoTMIJWiUuA8r9jTN/sdQdsoyajfzslx7rLCj UiEWnim5NaKrm+Op4m0fR5KLD/6MZtJioMQq7xQeK3AmdtSfqYMDLEpzy2V9/8EFpMUk6DebLMz OO1iDGOcXxaE5AO4SXnZmPLcgmSZJ8hxPYwNjCRUTzgY0Wm+32Z06acBrj5rgT3lkMAAmTwCY9T y5Rt1k7Q== X-Received: by 2002:a05:620a:4415:b0:774:244c:8b21 with SMTP id v21-20020a05620a441500b00774244c8b21mr3764242qkp.15.1695835691784; Wed, 27 Sep 2023 10:28:11 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHhQ1zw98C9C3Ojn4CCSVdrm5ZYWw5pT4kEL7JWgbTt/s9g/aD3SASv7rudJeebyP3ASZ5BPg== X-Received: by 2002:a05:620a:4415:b0:774:244c:8b21 with SMTP id v21-20020a05620a441500b00774244c8b21mr3764217qkp.15.1695835691487; Wed, 27 Sep 2023 10:28:11 -0700 (PDT) Received: from localhost ([31.111.84.209]) by smtp.gmail.com with ESMTPSA id x7-20020ae9f807000000b0076da620166bsm5592020qkh.103.2023.09.27.10.28.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Sep 2023 10:28:11 -0700 (PDT) To: gdb-patches@sourceware.org Cc: Andrew Burgess , Andreas Schwab Subject: [PATCHv2 5/5] gdb/testsuite: cleanup in gdb.base/args.exp Date: Wed, 27 Sep 2023 18:27:58 +0100 Message-Id: <34f347e769efca7a502b1466fa0c903c433c1f3a.1695835626.git.aburgess@redhat.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: References: <2b98ca58e47638b4760d86bd6e1fa9a9a79fa2ad.1695817255.git.aburgess@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-11.7 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Andrew Burgess via Gdb-patches From: Andrew Burgess Reply-To: Andrew Burgess Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org Sender: "Gdb-patches" The last few commits resolved the KFAILs in gdb.base/args.exp. With those out of the way we can clean up this test script a little. In this commit I have: - Stopped passing 'nowarnings' flag when building the source file. I see no reason why this source should issue a warning, - Moved setup of GDBFLAGS into args_test proc, callers that passed a newline needed a small tweak, and also the matching code needs updating for newline handling, but I think this is nicer, the argument lists are now given just once, - Updated comment on args_test, - Updated other comments. There should be no change in what is tested after this commit. --- gdb/testsuite/gdb.base/args.exp | 89 ++++++++++++++------------------- 1 file changed, 37 insertions(+), 52 deletions(-) diff --git a/gdb/testsuite/gdb.base/args.exp b/gdb/testsuite/gdb.base/args.exp index 0e2dc8b1399..43ea6e5caa8 100644 --- a/gdb/testsuite/gdb.base/args.exp +++ b/gdb/testsuite/gdb.base/args.exp @@ -24,76 +24,61 @@ require !use_gdb_stub standard_testfile -if {[build_executable $testfile.exp $testfile \ - $srcfile {debug nowarnings}] == -1} { +if {[build_executable $testfile.exp $testfile $srcfile] == -1} { untested "failed to compile" return -1 } # NAME is the name to use for the tests and ARGLIST is the list of -# expected arguments. +# arguments that are passed to GDB when it is started. proc args_test { name arglist } { - global srcdir - global subdir - global testfile - global hex - global decimal - - clean_restart $testfile - - runto_main - gdb_breakpoint [gdb_get_line_number "set breakpoint here"] - gdb_continue_to_breakpoint "breakpoint for $name" - - set expected_len [expr 1 + [llength $arglist]] - gdb_test "print argc" "\\\$$decimal = $expected_len" "argc for $name" - - set i 1 - foreach arg $arglist { - gdb_test "print argv\[$i\]" "\\\$$decimal = $hex \"$arg\"" \ - "argv\[$i\] for $name" - set i [expr $i + 1] + save_vars { ::GDBFLAGS } { + set ::GDBFLAGS "$::GDBFLAGS --args $::binfile $arglist" + + clean_restart $::binfile + + runto_main + gdb_breakpoint [gdb_get_line_number "set breakpoint here"] + gdb_continue_to_breakpoint "breakpoint for $name" + + set expected_len [expr 1 + [llength $arglist]] + gdb_test "print argc" "\\\$$::decimal = $expected_len" "argc for $name" + + set i 1 + foreach arg $arglist { + if { $arg eq "\n" } { + set arg {\\n} + } + verbose -log "APB: regexp '$arg'" + gdb_test "print argv\[$i\]" "\\\$$::decimal = $::hex \"$arg\"" \ + "argv\[$i\] for $name" + set i [expr $i + 1] + } } } -# # Test that the --args are processed correctly. -# -save_vars { GDBFLAGS } { - set old_gdbflags $GDBFLAGS +args_test basic {{1} {3}} - set GDBFLAGS "$old_gdbflags --args $binfile 1 3" - args_test basic {{1} {3}} +# Test that the --args are processed correctly even if one of them is +# empty. - # - # 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}} +args_test "one empty" {{1} {} {3}} - # - # try with 2 empty args - # - set GDBFLAGS "$old_gdbflags --args $binfile 1 {} {} 3" - args_test "two empty" {{1} {} {} 3} +# Try with 2 empty args. - # Try with arguments containing literal single quotes. +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}} +args_test "one empty with single quotes" {{1} {''} {3}} - # try with arguments containing literal newlines. +args_test "two empty with single quotes" {{1} {''} {''} {3}} - set GDBFLAGS "$old_gdbflags --args $binfile 1 {\n} 3" - args_test "one newline" {{1} {\\n} {3}} +# Try with arguments containing literal newlines. - set GDBFLAGS "$old_gdbflags --args $binfile 1 {\n} {\n} 3" - args_test "two newlines" {{1} {\\n} {\\n} {3}} -} +args_test "one newline" {{1} "\n" {3}} + +args_test "two newlines" {{1} "\n" "\n" {3}}