public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Luis Machado <luis.machado@arm.com>
To: Gustavo Romero <gustavo.romero@linaro.org>, gdb-patches@sourceware.org
Cc: thiago.bauermann@linaro.org, eliz@gnu.org, tom@tromey.com
Subject: Re: [PATCH v5 7/8] gdb/testsuite: Add unit tests for qIsAddressTagged packet
Date: Thu, 18 Apr 2024 11:39:21 +0100	[thread overview]
Message-ID: <d2b0e0cf-90ab-42f8-a2f1-b68efe77c905@arm.com> (raw)
In-Reply-To: <20240417210424.216374-8-gustavo.romero@linaro.org>

Based on what I mentioned in 06/08, we need to clearly define if garbage replies
starting with 00 and 01 are valid or not, and document that. We also need to adjust
these tests.

On 4/17/24 22:04, Gustavo Romero wrote:
> Add unit tests for testing qIsAddressTagged packet request creation and
> reply checks.
> 
> Signed-off-by: Gustavo Romero <gustavo.romero@linaro.org>
> ---
>  gdb/remote.c | 67 ++++++++++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 67 insertions(+)
> 
> diff --git a/gdb/remote.c b/gdb/remote.c
> index 2bb962955b5..bc2cfed2595 100644
> --- a/gdb/remote.c
> +++ b/gdb/remote.c
> @@ -15681,6 +15681,8 @@ test_memory_tagging_functions ()
>    scoped_restore restore_memtag_support_
>      = make_scoped_restore (&config->support);
>  
> +  struct gdbarch *gdbarch = current_inferior ()->arch ();
> +
>    /* Test memory tagging packet support.  */
>    config->support = PACKET_SUPPORT_UNKNOWN;
>    SELF_CHECK (remote.supports_memory_tagging () == false);
> @@ -15747,6 +15749,71 @@ test_memory_tagging_functions ()
>    create_store_memtags_request (packet, 0xdeadbeef, 255, 1, tags);
>    SELF_CHECK (memcmp (packet.data (), expected.c_str (),
>  		      expected.length ()) == 0);
> +
> +  /* Test creating a qIsAddressTagged request.  */
> +  expected = "qIsAddressTagged:deadbeef";
> +  create_is_address_tagged_request (gdbarch, packet, 0xdeadbeef);
> +  SELF_CHECK (strcmp (packet.data (), expected.c_str ()) == 0);
> +
> +  /* Test error reply on qIsAddressTagged request.  */
> +  reply = "E00";
> +  strcpy (packet.data (), reply.c_str ());
> +  /* is_tagged must not change, hence it's tested too.  */
> +  bool is_tagged = false;
> +  SELF_CHECK (check_is_address_tagged_reply (&remote, packet, is_tagged) ==
> +	      false);
> +  SELF_CHECK (is_tagged == false);
> +
> +  /* Test 'tagged' as reply.  */
> +  reply = "01";
> +  strcpy (packet.data (), reply.c_str ());
> +  /* Because the byte is 01, is_tagged should be set to true.  */
> +  is_tagged = false;
> +  SELF_CHECK (check_is_address_tagged_reply (&remote, packet, is_tagged) ==
> +	      true);
> +  SELF_CHECK (is_tagged == true);
> +
> +  /* Test 'not tagged' as reply.  */
> +  reply = "00";
> +  strcpy (packet.data (), reply.c_str ());
> +  /* Because the byte is 00, is_tagged should be set to false.  */
> +  is_tagged = true;
> +  SELF_CHECK (check_is_address_tagged_reply (&remote, packet, is_tagged) ==
> +	      true);
> +  SELF_CHECK (is_tagged == false);
> +
> +  /* Test an invalid reply (neither 00 nor 01).  */
> +  reply = "04";
> +  strcpy (packet.data (), reply.c_str ());
> +  /* Because the byte is invalid is_tagged must not change.  */
> +  is_tagged = false;
> +  SELF_CHECK (check_is_address_tagged_reply (&remote, packet, is_tagged) ==
> +	      false);
> +  SELF_CHECK (is_tagged == false);
> +
> +  /* Test proper first byte truncation.  */
> +  reply = "0104A590001234006";
> +  strcpy (packet.data (), reply.c_str ());
> +  /* Because the first byte is 01, is_tagged should be set to true.  */
> +  is_tagged = false;
> +  SELF_CHECK (check_is_address_tagged_reply (&remote, packet, is_tagged) ==
> +	      true);
> +  SELF_CHECK (is_tagged == true);
> +
> +  /* Test empty reply.  */
> +  reply = "";
> +  strcpy (packet.data (), reply.c_str ());
> +  /* is_tagged must not change, hence it's tested too.  */
> +  is_tagged = true;
> +  /* On the previous tests, qIsAddressTagged packet was auto detected and set
> +     as supported.  But an empty reply means the packet is unsupported, so for
> +     testing the empty reply the support is reset to unknown state, otherwise
> +     packet_ok will complain.   */
> +  remote.m_features.m_protocol_packets[PACKET_qIsAddressTagged].support =
> +    PACKET_SUPPORT_UNKNOWN;
> +  SELF_CHECK (check_is_address_tagged_reply (&remote, packet, is_tagged) ==
> +	      false);
> +  SELF_CHECK (is_tagged == true);
>  }
>  
>  static void

Otherwise this is OK to me, pending matching documentation updates.

  reply	other threads:[~2024-04-18 10:39 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-17 21:04 [PATCH v5 0/8] Add another way to check tagged addresses on remote targets Gustavo Romero
2024-04-17 21:04 ` [PATCH v5 1/8] gdb: aarch64: Remove MTE address checking from get_memtag Gustavo Romero
2024-04-17 21:04 ` [PATCH v5 2/8] gdb: aarch64: Move MTE address check out of set_memtag Gustavo Romero
2024-04-17 21:04 ` [PATCH v5 3/8] gdb: aarch64: Remove MTE address checking from memtag_matches_p Gustavo Romero
2024-04-17 21:04 ` [PATCH v5 4/8] gdb: Use passed gdbarch instead of calling current_inferior Gustavo Romero
2024-04-17 21:04 ` [PATCH v5 5/8] gdb: Introduce is_address_tagged target hook Gustavo Romero
2024-04-17 21:04 ` [PATCH v5 6/8] gdb: Add qIsAddressTagged packet Gustavo Romero
2024-04-18 10:37   ` Luis Machado
2024-04-17 21:04 ` [PATCH v5 7/8] gdb/testsuite: Add unit tests for " Gustavo Romero
2024-04-18 10:39   ` Luis Machado [this message]
2024-04-17 21:04 ` [PATCH v5 8/8] gdb: Document " Gustavo Romero
2024-04-18  5:18   ` Eli Zaretskii

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=d2b0e0cf-90ab-42f8-a2f1-b68efe77c905@arm.com \
    --to=luis.machado@arm.com \
    --cc=eliz@gnu.org \
    --cc=gdb-patches@sourceware.org \
    --cc=gustavo.romero@linaro.org \
    --cc=thiago.bauermann@linaro.org \
    --cc=tom@tromey.com \
    /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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).