From patchwork Thu Apr 18 20:10:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gustavo Romero X-Patchwork-Id: 789875 Delivered-To: patch@linaro.org Received: by 2002:adf:e6ca:0:b0:346:15ad:a2a with SMTP id y10csp751393wrm; Thu, 18 Apr 2024 13:13:44 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVGWxjfRVXvtrzBFcmTzoRWWrbbDzoLwMX+df/cT1yJgdUMUSbtHn4xScDOd/lGxsJBFWA9/5omXXC8933b2bh8 X-Google-Smtp-Source: AGHT+IHXvcclt2gJJe5an8AUpEPWyy3AGt1YfcxcH9qHqle+hrt6rOXlQr3RmaulElCjau8Ye5JM X-Received: by 2002:ac8:5983:0:b0:437:b7bd:368a with SMTP id e3-20020ac85983000000b00437b7bd368amr1811242qte.19.1713471223872; Thu, 18 Apr 2024 13:13:43 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713471223; cv=pass; d=google.com; s=arc-20160816; b=nld+Wz0qS11Oxd/iq3bgiN32qI4xDps/h/ciTnePN2PuMCgt1JBhF28q/5L3GZG0QO ql3dW74Wv+IBen66HLrWtEBqHF81qgRy7opfqg2LeQxOONXRcQU43+azDY0B2d3Py09/ DuZd2JcMrfs5jJOYUZXB9qV6lOcUd+JYE0fQfJJeSFxuGWanEuXQlCSkuwfUCoesHpyk fxrVnFUR3si5xDKrRx5LaXn5V9PJyvPsXAsGQRCKrWc+q+Rz+MTCwNyfqagjNZYJSzc2 +00sZifoUUrZbw+MHny9hRBpsVr1/mdfIcpgmvZGO0jeFFGVY+awXd385I84DFKgMaHy BKww== 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=LvPqpPxdXMvMfni6zeyD9qO97KVpmC2OoORvKi1PFXo=; fh=PHP0XrDyWzrRvU96cs6sxWXpzsZ2PqUxQqbJpAaSNaA=; b=VlYAJ5aDSdta0vcyU8i4+2ydOqtZ0KNv26Ie3Xf84x3ARyKeipX2FqEEhn9/YnOP9n EX2mWEYdHlHO1Ma1m8ZaenINAAFsOMVwNg9VSVwW/dHWKmSUBqDN37xUx8ZdwZrxg5kH xj7PkSNKEkCfZyOYV6w5vSiW//IiWzmCfYwuG5hUDq6VutmqZY/Iyy8KrAkNyN0eC2Zw p13+yoGmnqgLW0lwm8rfv6s2Sxei8GCo56lRrzKYcn7JDvzqRlaghyC3M/I48i926lo4 h+/EqxDg/xTTUD7Sv36lUnnGkuLvqCH+M0CRTEbilwSfJz5u7zTYC+O1fOVCd7iaFiJC GHuQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=QiQwlPwL; arc=pass (i=1); spf=pass (google.com: domain of gdb-patches-bounces+patch=linaro.org@sourceware.org designates 8.43.85.97 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. [8.43.85.97]) by mx.google.com with ESMTPS id bp17-20020a05622a1b9100b0042ef110519bsi2173527qtb.783.2024.04.18.13.13.43 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Apr 2024 13:13:43 -0700 (PDT) Received-SPF: pass (google.com: domain of gdb-patches-bounces+patch=linaro.org@sourceware.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=QiQwlPwL; arc=pass (i=1); spf=pass (google.com: domain of gdb-patches-bounces+patch=linaro.org@sourceware.org designates 8.43.85.97 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 81D543861870 for ; Thu, 18 Apr 2024 20:13:43 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from mail-pl1-x636.google.com (mail-pl1-x636.google.com [IPv6:2607:f8b0:4864:20::636]) by sourceware.org (Postfix) with ESMTPS id D5572385DC3F for ; Thu, 18 Apr 2024 20:11:13 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D5572385DC3F 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 D5572385DC3F Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::636 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1713471076; cv=none; b=ByNbqP/Nr+u/wgzdCW4+xVqdcRohw/b6z2ukmqRKDGDSApkVa7QI2/Wga1MnfJvj3SnrxUh39OmbA8i7QS+fH1R7PSnCuWnXpEKztmT8uHQ2QuAmpb1Txa7zS/Yb8qilSwItSlbokhbdU/0+whgAjd0LvW/pnL/JrGwJEJ/bH7s= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1713471076; c=relaxed/simple; bh=+aYIy06p33cWuznN4M9G/ExjmM7xSbVaZPDrHjtMX/8=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=PQWytq0VWhUSRacaRg/khRcIrC34UG8QuzvG2WBxplvoezGir+Z/jLQx5rYABYi84xJrNE8XvvwhV1tD5dFe+Yas2JI22v28YHNy+Lu6ywF1jFkjtJNf8HEVunIfLGAdp21HWdniaZ2d3PyzLQ0f471367bkD01vEU355omEEDQ= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pl1-x636.google.com with SMTP id d9443c01a7336-1e4c4fb6af3so9686655ad.0 for ; Thu, 18 Apr 2024 13:11:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1713471072; x=1714075872; 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=LvPqpPxdXMvMfni6zeyD9qO97KVpmC2OoORvKi1PFXo=; b=QiQwlPwLKmJw7XMomx8t1/r8UKQRZUsZcNF++ZnX8KsiKDz/ziDuFdiK7lYUG8yHCv tNeSov3a/JF3LkgnaieNrYbuBOzRo4BB92lYyWE1B/HAq75I0ThQBiTIZBQyr7AfpOib kM5RV8s7uY6yyMXTy/qve9IFzrJhv70xo0xWvfQtjfLfjDFErlUEJTTQus5xzuW6jrFT IamFqlU01R6BO9Xka3t0R0Z65HRy6vvNV81CbohFb4g3a6D1bbSkPInILO8+s9mMRMff 4uBZi3ltQgV3JIiI0+4MRo20aI6eG8C/qOBmKlyDo+9+3dleCQzEeNG3GxswumqdE7bD A1Bg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713471072; x=1714075872; 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=LvPqpPxdXMvMfni6zeyD9qO97KVpmC2OoORvKi1PFXo=; b=ZjeD6jggOhADz6b1jAQEFD9cMGqLgx2NcsMf5v/F/ZKSn5j0NIABgzXBSq6+KX4LMX BeTRWbm9cJUzKdGVcc467lSYuhIiv6sQm4QTtugPHtRHzk5JliiHv+f9HJnaBvGlIqsY hl4Ns6jMiABnCHBttca6uVnJsYRxEWr/GCN+hj3m1ZpQ2iphXTN5s0F/x3vzleBAcskH 28Hp0gmxinszPyaPWs9Bz7vH1sL75EPQclcrRheFxe1r7wj+DB8tPw7+AfEEujg/7YLx kYPnsblEljJQGXWpv4fHb1BuCsfMGv94q948lzvZzr/ivdssM7Q4+0eJ9lhf6crkZQ1/ dPWA== X-Gm-Message-State: AOJu0YxApRZCusnTCZvcp2oAKnlRa5wFGrDxkxyYnYlsPTCWf1BKKmMZ kD2f/c7Eo9cGrRNwwBCfLDYX0a4QudpFnXFoxuLTPfgpMRUYrfnZxJmm2yJyocWhn+kuDPRSA/l m X-Received: by 2002:a17:902:ea12:b0:1e3:e6cb:a07f with SMTP id s18-20020a170902ea1200b001e3e6cba07fmr317668plg.26.1713471072388; Thu, 18 Apr 2024 13:11:12 -0700 (PDT) Received: from amd.. ([2804:7f0:b403:ad57:3e7c:3fff:fe7a:e83b]) by smtp.gmail.com with ESMTPSA id n18-20020a170903111200b001e0b5eee802sm1925524plh.123.2024.04.18.13.11.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Apr 2024 13:11:11 -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 v6 7/8] gdb/testsuite: Add unit tests for qIsAddressTagged packet Date: Thu, 18 Apr 2024 20:10:38 +0000 Message-Id: <20240418201039.236867-8-gustavo.romero@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240418201039.236867-1-gustavo.romero@linaro.org> References: <20240418201039.236867-1-gustavo.romero@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-13.1 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 unit tests for testing qIsAddressTagged packet request creation and reply checks. Signed-off-by: Gustavo Romero Tested-By: Luis Machado --- gdb/remote.c | 67 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) diff --git a/gdb/remote.c b/gdb/remote.c index 3d034bb1ef8..cfb54de157d 100644 --- a/gdb/remote.c +++ b/gdb/remote.c @@ -15682,6 +15682,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); @@ -15748,6 +15750,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 malformed reply of incorrect length. */ + reply = "0104A590001234006"; + strcpy (packet.data (), reply.c_str ()); + /* Because this is a malformed reply 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 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