Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Pedro Alves <palves@redhat.com>
To: Philippe Waroquiers <philippe.waroquiers@skynet.be>,
	gdb-patches@sourceware.org
Subject: Re: [RFAv3 5/6] Test the | (pipe) command.
Date: Mon, 27 May 2019 17:49:00 -0000	[thread overview]
Message-ID: <db87eaba-30db-371d-58e7-6ef1925a1214@redhat.com> (raw)
In-Reply-To: <20190504161753.15530-6-philippe.waroquiers@skynet.be>

On 5/4/19 5:17 PM, Philippe Waroquiers wrote:
> gdb/testsuite/ChangeLog
> 2019-05-04  Philippe Waroquiers  <philippe.waroquiers@skynet.be>
> 
> 	* 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 = <internal function _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 <http://www.gnu.org/licenses/>.
>  
> -# 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


  reply	other threads:[~2019-05-27 17:49 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-04 16:18 [RFAv3 0/6] Implement " Philippe Waroquiers
2019-05-04 16:18 ` [RFAv3 4/6] " Philippe Waroquiers
2019-05-27 17:48   ` Pedro Alves
2019-05-27 17:55     ` Pedro Alves
2019-05-04 16:18 ` [RFAv3 5/6] Test the " Philippe Waroquiers
2019-05-27 17:49   ` Pedro Alves [this message]
2019-05-04 16:18 ` [RFAv3 3/6] Add function execute_command_to_ui_file Philippe Waroquiers
2019-05-04 16:18 ` [RFAv3 1/6] Add previous_saved_command_line to allow a command to repeat a previous command Philippe Waroquiers
2019-05-27 17:29   ` Pedro Alves
2019-05-04 16:18 ` [RFAv3 6/6] NEWS and documentation for | (pipe) command Philippe Waroquiers
2019-05-04 16:26   ` Eli Zaretskii
2019-05-04 16:33     ` Eli Zaretskii
2019-05-27 17:51   ` Pedro Alves
2019-05-04 16:18 ` [RFAv3 2/6] Improve process exit status macros on MinGW Philippe Waroquiers
2019-05-27 17:33   ` Pedro Alves
2019-05-27 18:38     ` Eli Zaretskii
2019-05-29 12:38       ` Pedro Alves
2019-05-29 15:03         ` Eli Zaretskii
2019-05-30 10:26         ` Philippe Waroquiers
2019-12-17 17:00     ` Eli Zaretskii
2019-12-17 17:51       ` Pedro Alves
2019-12-18 17:08         ` Eli Zaretskii
2019-12-18 17:42           ` Pedro Alves
2019-12-18 18:33             ` Eli Zaretskii
2019-12-25 15:57               ` Eli Zaretskii
2020-01-03 19:59                 ` Pedro Alves
2020-01-03 20:08                   ` Pedro Alves
2020-01-03 20:34                   ` Eli Zaretskii
2020-01-06 11:57                     ` Pedro Alves
2020-01-06 16:17                       ` Eli Zaretskii
2020-01-06 18:51                         ` Pedro Alves
2020-01-06 19:26                           ` Eli Zaretskii
2020-01-06 18:59                   ` Hannes Domani via gdb-patches
2020-01-06 19:34                     ` Eli Zaretskii
2020-01-06 19:38                       ` Hannes Domani via gdb-patches
2020-01-06 19:55                         ` Eli Zaretskii
2020-01-03 17:04               ` Pedro Alves

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=db87eaba-30db-371d-58e7-6ef1925a1214@redhat.com \
    --to=palves@redhat.com \
    --cc=gdb-patches@sourceware.org \
    --cc=philippe.waroquiers@skynet.be \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox