From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 40564 invoked by alias); 27 May 2019 17:49:42 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 40555 invoked by uid 89); 27 May 2019 17:49:42 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,KAM_SHORT,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 spammy=!!!, regardless, verifications, 6066 X-HELO: mail-wr1-f65.google.com Received: from mail-wr1-f65.google.com (HELO mail-wr1-f65.google.com) (209.85.221.65) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 27 May 2019 17:49:40 +0000 Received: by mail-wr1-f65.google.com with SMTP id f8so17591109wrt.1 for ; Mon, 27 May 2019 10:49:39 -0700 (PDT) Return-Path: Received: from ?IPv6:2001:8a0:f913:f700:4eeb:42ff:feef:f164? ([2001:8a0:f913:f700:4eeb:42ff:feef:f164]) by smtp.gmail.com with ESMTPSA id a4sm10542189wrf.78.2019.05.27.10.49.37 (version=TLS1_3 cipher=AEAD-AES128-GCM-SHA256 bits=128/128); Mon, 27 May 2019 10:49:37 -0700 (PDT) Subject: Re: [RFAv3 5/6] Test the | (pipe) command. To: Philippe Waroquiers , gdb-patches@sourceware.org References: <20190504161753.15530-1-philippe.waroquiers@skynet.be> <20190504161753.15530-6-philippe.waroquiers@skynet.be> From: Pedro Alves Message-ID: Date: Mon, 27 May 2019 17:49:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.2.1 MIME-Version: 1.0 In-Reply-To: <20190504161753.15530-6-philippe.waroquiers@skynet.be> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-SW-Source: 2019-05/txt/msg00592.txt.bz2 On 5/4/19 5:17 PM, Philippe Waroquiers wrote: > gdb/testsuite/ChangeLog > 2019-05-04 Philippe Waroquiers > > * gdb.base/shell.exp: Test pipe command, $_shell_exitcode, > $_shell_exitsignal. > * gdb.base/default.exp: Update for new convenience variables. > > Update default.exp ^^^^^^^^^^^^^^^^^^ spurious. > --- > gdb/testsuite/gdb.base/default.exp | 2 + > gdb/testsuite/gdb.base/shell.exp | 68 +++++++++++++++++++++++++++++- > 2 files changed, 69 insertions(+), 1 deletion(-) > > diff --git a/gdb/testsuite/gdb.base/default.exp b/gdb/testsuite/gdb.base/default.exp > index 56ec917aa3..0325b8045d 100644 > --- a/gdb/testsuite/gdb.base/default.exp > +++ b/gdb/testsuite/gdb.base/default.exp > @@ -606,6 +606,8 @@ set show_conv_list \ > {$_isvoid = } \ > {$_gdb_major = 8} \ > {$_gdb_minor = 4} \ > + {$_shell_exitsignal = void} \ > + {$_shell_exitcode = 0} \ > } > if ![skip_python_tests] { > append show_conv_list \ > diff --git a/gdb/testsuite/gdb.base/shell.exp b/gdb/testsuite/gdb.base/shell.exp > index 60d6e31e4f..9b85e4988b 100644 > --- a/gdb/testsuite/gdb.base/shell.exp > +++ b/gdb/testsuite/gdb.base/shell.exp > @@ -13,7 +13,7 @@ > # You should have received a copy of the GNU General Public License > # along with this program. If not, see . > > -# Test that the shell and ! commands work. > +# Test that the shell and ! and | and pipe commands work. Too many ands. I'd suggest: # Test that the "shell", "!", "|" and "pipe" commands work. > > gdb_exit > gdb_start > @@ -22,3 +22,69 @@ gdb_test "shell echo foo" "foo" > > gdb_test "! echo foo" "foo" > gdb_test "!echo foo" "foo" > + > +# Convenience variables with shell command. > +gdb_test "! exit 0" "" This always passes regardless of output. Is that intended? If not, use gdb_test_no_output. Ditto for all other similar cases below. > +gdb_test "p \$_shell_exitcode" " = 0" "shell success exitcode" > +gdb_test "p \$_shell_exitsignal" " = void" "shell success exitsignal" > + > +gdb_test "! exit 1" "" > +gdb_test "p \$_shell_exitcode" " = 1" "shell fail exitcode" > +gdb_test "p \$_shell_exitsignal" " = void" "shell fail exitsignal" > + > +gdb_test "! kill -2 $$" "" > +gdb_test "p \$_shell_exitcode" " = void" "shell interrupt exitcode" > +gdb_test "p \$_shell_exitsignal" " = 2" "shell interrupt exitsignal" > + > + > +gdb_test "pipe help pipe | wc -l" "10" "check simple pipe" > +gdb_test "pipe help pipe | grep Usage: | wc -l" "4" "check double pipe" That looks a bit brittle. We'll have to update the tests if we change the help output. Wouldn't something a bit more stable be better? E.g., gdb has output/printf/echo commands. You could use those to precisely control the output in the testcase. To avoid cluttering the test logs, you could make the testcase define a command that uses echo, and then use that command: define foo echo "hello world\n" ... end > + > +gdb_test "| help pipe | grep Usage: | wc -l" "4" "check double pipe, pipe char" > +gdb_test "|help pipe|grep Usage:|wc -l" "4" "no space around pipe char" > + > +gdb_test "echo coucou\\n" "coucou" "echo coucou" > +gdb_test "||wc -l" "1" "Check repeat previous command" Lowercase "Check". Or better, remove "Check". > + > +gdb_test "| -d ! echo this contains a | character\\n ! sed -e 's/|/PIPE/'" \ > + "this contains a PIPE character" "verify alternate 1char sep" > + > +gdb_test "|-d ! echo this contains a | character\\n!sed -e 's/|/PIPE/'" \ > + "this contains a PIPE character" "verify alternate 1char sep, no space" > + > +gdb_test "| -d !!! echo this contains a | character\\n !!! sed -e 's/|/PIPE/'" \ > + "this contains a PIPE character" "verify alternate 3char sep" > + > +gdb_test "|-d !!! echo this contains a | character\\n!!!sed -e 's/|/PIPE/'" \ > + "this contains a PIPE character" "verify alternate 3char sep, no space" > + > +# Convenience variables with pipe command. > +gdb_test "|p 123| exit 0" "" > +gdb_test "p \$_shell_exitcode" " = 0" "pipe success exitcode" > +gdb_test "p \$_shell_exitsignal" " = void" "pipe success exitsignal" > + > +gdb_test "|p 123| exit 1" "" > +gdb_test "p \$_shell_exitcode" " = 1" "pipe fail exitcode" > +gdb_test "p \$_shell_exitsignal" " = void" "pipe fail exitsignal" > + > +gdb_test "|p 123| kill -2 $$" "" > +gdb_test "p \$_shell_exitcode" " = void" "pipe interrupt exitcode" > +gdb_test "p \$_shell_exitsignal" " = 2" "pipe interrupt exitsignal" > + > +# Error handling verifications. > +gdb_test "|" "Missing COMMAND" "all missing" > +gdb_test "|-d" "Missing separator SEP after -d" "-d value missing" > +gdb_test "|-d " "Missing separator SEP after -d" "-d spaces value missing" > +gdb_test "| echo coucou" \ > + "Missing separator before SHELL_COMMAND" \ > + "| separator missing" > +gdb_test "|-d SEP echo coucou" \ > + "Missing separator before SHELL_COMMAND" \ > + "SEP separator missing" > +gdb_test "|echo coucou|" \ > + "Missing SHELL_COMMAND" \ > + "SHELL_COMMAND missing" > +gdb_test "|-d ! echo coucou !" \ > + "Missing SHELL_COMMAND" \ > + "SHELL_COMMAND missing" > + At least the last two above have duplicate test names. I think you're missing a test for "-dSEP", no space. Thanks, Pedro Alves