From patchwork Tue Apr 16 14:07:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gustavo Romero X-Patchwork-Id: 789236 Delivered-To: patch@linaro.org Received: by 2002:a05:6000:dcf:b0:346:15ad:a2a with SMTP id dw15csp305194wrb; Tue, 16 Apr 2024 07:09:39 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWXm4xo9cYZE5hl44A8PHZ1p6BZBA8s8l6ebUUX4BuuuRHCrM+e9D4hYPTGDFaWiYoAupNZWnrDcv0TkNTdiYB4 X-Google-Smtp-Source: AGHT+IGFtTr6JSKQTUTdgcDJfU0+IpaLOtZKR6iGSzESyZvluCtPDwIdaf8KVocLLqIGZMDW1h62 X-Received: by 2002:a05:622a:58f:b0:434:584b:33ba with SMTP id c15-20020a05622a058f00b00434584b33bamr13688946qtb.51.1713276579668; Tue, 16 Apr 2024 07:09:39 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713276579; cv=pass; d=google.com; s=arc-20160816; b=P8XgKVblC5KQY2G8OAJgYwUZ/YRcjsyymKwd81Q9+XfKyKRT5+sg9a2wOaHZyl2DBU eimIFbN3NdJM7GMVLifTRfRQbkfkE81nMvN6hz+zZpn1uSI8AzeE7Qkjbmk1Ugwz4KgY lQVtI13cuxHdaKqXHsp2BguizJM8pN4/TnhdJeQoXE4xQ+V2A+/mBBprDCU/C9FHmKyY G8RdtXq/K2THgNumpvWy7cU3ZNh9CqGq/5oBMle2cjSPY6HA41D5p6y8shkCXapHdzsC pz3i77GWtap2VxzqMgLH1ZVCJHUY0y7mzcH+3BYTuhbotoAZzs+GdbUa/b89kCpbtc6U CKPg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature:arc-filter:dmarc-filter:delivered-to; bh=NIecbHfd61PBTmQ06xkZ27ONlrNYswqO8NJqiIAjj3Q=; fh=PHP0XrDyWzrRvU96cs6sxWXpzsZ2PqUxQqbJpAaSNaA=; b=lr/CgNhfKLIka1AY8LFYCbBhSk4qUElRQkn6L0uXV1gxOrsVxrXar5d1BYPUE2TkHx dPsk0OIsiffh5plVcvp3C8EkRagJKOEnnCsFb+p5WksVaCXXMdIQWrJuSx5l1fIga3r+ PEBww6VOSMyaofm/q+7+oN5SHD9yHq8ShBRQEvJYJuVxiWASpK2zyL6hVNERVeEKlBvY feYm/4h8a3XqaDJOJCmAsd/PCLkxxQ4F22RFVu/QNP5C+cteW/X34As5vk2bHARvfyw9 Ja+XwgT5RjSpVGQ/aY1Zr/fqrX+eHdiwsQmCGSosSClB2ec3r1NWpNQgoZ8nYpMai8qW E0xw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=KzhTpixF; arc=pass (i=1); spf=pass (google.com: domain of gdb-patches-bounces+patch=linaro.org@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gdb-patches-bounces+patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from server2.sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id h5-20020ac87d45000000b004369f4c005fsi9877331qtb.700.2024.04.16.07.09.39 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Apr 2024 07:09:39 -0700 (PDT) Received-SPF: pass (google.com: domain of gdb-patches-bounces+patch=linaro.org@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=KzhTpixF; arc=pass (i=1); spf=pass (google.com: domain of gdb-patches-bounces+patch=linaro.org@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gdb-patches-bounces+patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 4CB7B3858C53 for ; Tue, 16 Apr 2024 14:09:39 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from mail-pf1-x42a.google.com (mail-pf1-x42a.google.com [IPv6:2607:f8b0:4864:20::42a]) by sourceware.org (Postfix) with ESMTPS id 525FA3858C78 for ; Tue, 16 Apr 2024 14:08:00 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 525FA3858C78 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=linaro.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 525FA3858C78 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::42a ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1713276487; cv=none; b=JCQpvdyZI6vzwBwoqkbYBPC0ux5TqrtSvfptk0L+4hTq32z2/HoOurbNpcfk10m4evYT1bgPOqXeu+ml8SFIQmC926622ae7t7wAhLBdctdIRzkuVZJhBM7NRuLKchqHKBmYTQIu6lWVk+TWdT1vqVsvCys1vBBGGsyTtsMBJPY= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1713276487; c=relaxed/simple; bh=5JUNK7JchaPtTy/5e/gDv204PBOvA9bZ2y/G1rG+BjE=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=I0wafVUjeAIN6DkwNiS7LwbVQb9jvjIeEHkIUSOP8WPhkxtiGZ2vjguHYLRzEB6LVhqwxSbiifNzcrk3BjrszmfkXHIJsg8H5pOGlwbOnNt1NwEA3yB3oW2Q36icYDaPE/6a0dp4YvkVWOejchNbG3kbvy5QlWWCqWIOjJ2K9rY= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pf1-x42a.google.com with SMTP id d2e1a72fcca58-6ed0e9ccca1so4046574b3a.0 for ; Tue, 16 Apr 2024 07:08:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1713276479; x=1713881279; darn=sourceware.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=NIecbHfd61PBTmQ06xkZ27ONlrNYswqO8NJqiIAjj3Q=; b=KzhTpixFzQmo5Hri7y8aqI7gtIdfHNcCbhwDn7p9xeTWbBfd1PE+JO3Bj5vg9ORtjE GPULT4A+sTKhoLaUnUN0AUbZJYpV5cfUHCyCt/cA9PEuIBUyoOd5zDBGuWFJ864fTnRc Pz5JYgSFy/Jk4DbA+qTNV0sUlhNdKdi8Br+SyhKUmKlLRtc1AP+GrojlxCiZF7g3b81V XHVDJBypMSmU6J35LvgIxlsFBIbG/CNUCPf9Ufs02HpMqRf4Q6JdCgWoBQ0q3T3Q2PVb iuhgQtY0RHL04rX4f81MuWrDlM8SJrYU2jGALqDf8LapgBYi6NjGTJ+A/b18UndF3Vgn D+ag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713276479; x=1713881279; 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=NIecbHfd61PBTmQ06xkZ27ONlrNYswqO8NJqiIAjj3Q=; b=XfkJWOFDldrJuxuUISnFjbdP9onXIWA6db8It15Frx7VtFRhK6JoWIUPAnIqPQ1rjZ GghIgZjZVzJt0mln7pp6DOd7U8k1wmF2jGqXUjrafi5lVPeGLFWcIyIf1YL4nCQAt/6/ hwDBRBQNc0WdytcLhQIFU9mS9JX8XmxbnOsNkEjUaK/Cjj9ada9pYNIbepAEfKoSUxQl gN6ZA4fh7iKOYRmD3s7gzywFPDAwQ3azZxg8hWoS2pInZu0Gr1fXANnoT53uSMAwvLX0 lvP+YTc9Ro3irubFmcpo9eSHRJP+Ye7aJ1OuijUCzBThfQuAPrIT8eYYDTpwmFpA1Bw3 1LIA== X-Gm-Message-State: AOJu0YzLt8SXq3GEZD6CrneX6F/+fTwtyNOsMaRyH43cmKA2lCh4NH/w qHITXnkBFK72v5GbgzzkiTCSvZFopNs8QX+2bnYBf+B3EvbsYpxQu0k7G+8RraGpXnHpxduG5yo LGp4= X-Received: by 2002:a05:6a21:35c2:b0:1a7:a564:14db with SMTP id ba2-20020a056a2135c200b001a7a56414dbmr11693441pzc.24.1713276478578; Tue, 16 Apr 2024 07:07:58 -0700 (PDT) Received: from amd.. ([2804:7f0:b403:ad57:3e7c:3fff:fe7a:e83b]) by smtp.gmail.com with ESMTPSA id o3-20020a63e343000000b005f3d54c0a57sm8937473pgj.49.2024.04.16.07.07.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Apr 2024 07:07:58 -0700 (PDT) From: Gustavo Romero To: gdb-patches@sourceware.org Cc: luis.machado@arm.com, thiago.bauermann@linaro.org, eliz@gnu.org, tom@tromey.com, gustavo.romero@linaro.org Subject: [PATCH v4 7/8] gdb/testsuite: Add unittest for qIsAddressTagged packet Date: Tue, 16 Apr 2024 14:07:27 +0000 Message-Id: <20240416140728.198163-8-gustavo.romero@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240416140728.198163-1-gustavo.romero@linaro.org> References: <20240416140728.198163-1-gustavo.romero@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-12.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, 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: , Errors-To: gdb-patches-bounces+patch=linaro.org@sourceware.org Add unittests for testing qIsAddressTagged packet request creation and reply checks. Signed-off-by: Gustavo Romero --- gdb/remote.c | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/gdb/remote.c b/gdb/remote.c index 63799ac5e3f..42f34a03c95 100644 --- a/gdb/remote.c +++ b/gdb/remote.c @@ -15658,6 +15658,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); @@ -15724,6 +15726,46 @@ 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 empty reply on qIsAddressTagged request. */ + reply = "E00"; + /* is_tagged must not changed, hence it's tested too. */ + bool is_tagged = false; + strcpy (packet.data (), reply.c_str ()); + SELF_CHECK (check_is_address_tagged_reply (packet, &is_tagged) == false); + SELF_CHECK (is_tagged == false); + + /* Test if only the first byte (01) is correctly extracted from a long + numerical reply, with remaining garbage. */ + reply = "0104A590001234006mC0fe"; + /* Because the first byte is 01, is_tagged should be set to true. */ + is_tagged = false; + strcpy (packet.data (), reply.c_str ()); + SELF_CHECK (check_is_address_tagged_reply (packet, &is_tagged) == true); + SELF_CHECK (is_tagged == true); + + /* Test if only the first byte (00) is correctly extracted from a long + numerical reply, with remaining garbage. */ + reply = "0004A590001234006mC0fe"; + /* Because the first byte is 00, is_tagged should be set to false. */ + is_tagged = true; + strcpy (packet.data (), reply.c_str ()); + SELF_CHECK (check_is_address_tagged_reply (packet, &is_tagged) == true); + SELF_CHECK (is_tagged == false); + + /* Test if only the first byte, 04, is correctly extracted and recognized + as invalid (only 00 and 01 are valid replies). */ + reply = "0404A590001234006mC0fe"; + /* Because the first byte is invalid is_tagged must not change. */ + is_tagged = false; + strcpy (packet.data (), reply.c_str ()); + SELF_CHECK (check_is_address_tagged_reply (packet, &is_tagged) == false); + SELF_CHECK (is_tagged == false); } static void