From patchwork Tue Oct 18 19:05:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Maira Canal X-Patchwork-Id: 4299 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp2118529wrs; Tue, 18 Oct 2022 12:12:15 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6P0t064NM4MJVGRXhEfs0QMU3/tz3cuhgMWZ3SiBYCsgDdUy/W36l5f5908ZOqa2B+PDM7 X-Received: by 2002:a17:906:8479:b0:78d:cf17:2d70 with SMTP id hx25-20020a170906847900b0078dcf172d70mr3610264ejc.319.1666120334921; Tue, 18 Oct 2022 12:12:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666120334; cv=none; d=google.com; s=arc-20160816; b=rruDCwXUTwbeTW0+2eWypAwj7DPd+08oBFZFJxKXHkMx+3L8oG0SNkAKDZ0v8u9s5q fNgaUN5cwDYu2qG2OiF6ogtgwAjadovvRb4CUUhuFeQ+/sROm7r3JdJ15377GzrlInJx wrKrFTvMG5uH6zHFDoF8VSSSWsgLWJFTCXDh90BcWrVoG/F9fbfwIyd1GRDha7gAIUC7 0nyQ5flMa6vei9Kg5K/dq1T5kxbEpHzyJNeslotmkCTThLdHm9gM7BvFxhdbRidFCLku XPtoswlSiddHDbaSBRDJseYStRTRwcm1oBedJCNt/ult/tgLxTj/ceXcNdoBIKR9J15Q xuPA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=oNS2cRYbPwhpQLJT2T21VpVilWkHcFkDX3rXCxR5jbE=; b=W/1MYU6rXPtZF8lfX+vUXasnw+X9WEPfoA74xLtb0ioObLeg745j5fyWte6HN9ve9f ekE1G6PWwOrBgfk0w2zLFgAwV4Lmi56A5gsZsrAuTSrm0PyuUCNsarCHEPtnoHkUsSgE 6MKCWiWA67FQ4zUVpKJ8vfeXHf5KQXw5TlJugFbBzPOtpXGottrhmTIekSkZzi68k3C6 uAweK14rKIdxVylv7dvKhH/to0KhNQ39Ub59DU3gN3ALxZU62O7UlZFB96Z23TZL+x7J ZzXW9U63W3pE27/xlCUKcHiPgygsNUyh9GV3hLTL/rj/9w80jyBfgMOqllVHEAveHL2d xV3w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@riseup.net header.s=squak header.b=CQpW61fS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=riseup.net Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e19-20020a50a693000000b004597f82e556si10921659edc.201.2022.10.18.12.11.48; Tue, 18 Oct 2022 12:12:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@riseup.net header.s=squak header.b=CQpW61fS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=riseup.net Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229727AbiJRTHb (ORCPT + 99 others); Tue, 18 Oct 2022 15:07:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33854 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230203AbiJRTHN (ORCPT ); Tue, 18 Oct 2022 15:07:13 -0400 Received: from mx1.riseup.net (mx1.riseup.net [198.252.153.129]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1F4366E8B4; Tue, 18 Oct 2022 12:07:13 -0700 (PDT) Received: from fews2.riseup.net (fews2-pn.riseup.net [10.0.1.84]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "mail.riseup.net", Issuer "R3" (not verified)) by mx1.riseup.net (Postfix) with ESMTPS id 4MsNdr3KxPzDq7Y; Tue, 18 Oct 2022 19:07:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=riseup.net; s=squak; t=1666120032; bh=0pG8SvKuzdedA/Y6PPMpy9eA/KJ5S97Kj4xvsRk+czU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CQpW61fStySQQlxj/Nz39yzJbX9p3Vi7MmcwyEfAPH+GrQQVjQ2XA/kc8u9ycCbGd 2U6pJ14qCf1QE0f7XC2eP4GZALr86MsPywBDwbmXLjNw95MMM89U5PehE+1RqZvdfp 3bLPvU00lCx5vE27aviPrrwWfLwoRtkY0b/rgaVk= X-Riseup-User-ID: ADBAE9E1CC5094326A555961F1F164C13DA8A9E3F3DC4BF6EB6B7A25EBB74410 Received: from [127.0.0.1] (localhost [127.0.0.1]) by fews2.riseup.net (Postfix) with ESMTPSA id 4MsNdl5BnJz214Q; Tue, 18 Oct 2022 19:07:07 +0000 (UTC) From: =?utf-8?q?Ma=C3=ADra_Canal?= To: Brendan Higgins , davidgow@google.com, Daniel Latypov , airlied@gmail.com, daniel@ffwll.ch, davem@davemloft.net, kuba@kernel.org, jose.exposito89@gmail.com, javierm@redhat.com Cc: andrealmeid@riseup.net, melissa.srw@gmail.com, siqueirajordao@riseup.net, Isabella Basso , magalilemes00@gmail.com, tales.aparecida@gmail.com, linux-kselftest@vger.kernel.org, kunit-dev@googlegroups.com, linux-kernel@vger.kernel.org, =?utf-8?q?Ma?= =?utf-8?q?=C3=ADra_Canal?= Subject: [PATCH v6 2/3] kunit: Add KUnit memory block assertions to the example_all_expect_macros_test Date: Tue, 18 Oct 2022 16:05:40 -0300 Message-Id: <20221018190541.189780-3-mairacanal@riseup.net> In-Reply-To: <20221018190541.189780-1-mairacanal@riseup.net> References: <20221018190541.189780-1-mairacanal@riseup.net> MIME-Version: 1.0 X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747053796449575076?= X-GMAIL-MSGID: =?utf-8?q?1747053796449575076?= Augment the example_all_expect_macros_test with the KUNIT_EXPECT_MEMEQ and KUNIT_EXPECT_MEMNEQ macros by creating a test with memory block assertions. Signed-off-by: MaĆ­ra Canal Reviewed-by: Daniel Latypov Reviewed-by: David Gow --- lib/kunit/kunit-example-test.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/kunit/kunit-example-test.c b/lib/kunit/kunit-example-test.c index f8fe582c9e36..66cc4e2365ec 100644 --- a/lib/kunit/kunit-example-test.c +++ b/lib/kunit/kunit-example-test.c @@ -86,6 +86,9 @@ static void example_mark_skipped_test(struct kunit *test) */ static void example_all_expect_macros_test(struct kunit *test) { + const u32 array1[] = { 0x0F, 0xFF }; + const u32 array2[] = { 0x1F, 0xFF }; + /* Boolean assertions */ KUNIT_EXPECT_TRUE(test, true); KUNIT_EXPECT_FALSE(test, false); @@ -109,6 +112,10 @@ static void example_all_expect_macros_test(struct kunit *test) KUNIT_EXPECT_STREQ(test, "hi", "hi"); KUNIT_EXPECT_STRNEQ(test, "hi", "bye"); + /* Memory block assertions */ + KUNIT_EXPECT_MEMEQ(test, array1, array1, sizeof(array1)); + KUNIT_EXPECT_MEMNEQ(test, array1, array2, sizeof(array1)); + /* * There are also ASSERT variants of all of the above that abort test * execution if they fail. Useful for memory allocations, etc.