From patchwork Tue Oct 25 23:10:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Maira Canal X-Patchwork-Id: 11001 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp1266155wru; Tue, 25 Oct 2022 16:13:50 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4kBvMUA5+jdVPpJVYZzRMNfK0pwpjfWi+nflmAMpDHGZ75Nmv/deJfvsz9VMvypceyKQYf X-Received: by 2002:a05:6a00:1491:b0:563:8844:3f31 with SMTP id v17-20020a056a00149100b0056388443f31mr40208769pfu.31.1666739629952; Tue, 25 Oct 2022 16:13:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666739629; cv=none; d=google.com; s=arc-20160816; b=aAMlMIUasp7wDMGxaLQvFFibgTqfyIVz238qNzURDOHC+UwqxkesjQB0jcO/NGnrSX 4hT7otJ9CO39aPKp4ZGu2Z/XPrRuMqpTLu/xRgHdd8cu9tCxHOTgUYJgff36Av/GMGQQ rFNHJkDDJeJWkeAiPaX9X9CB4/z4CBULHLcajsjKXiQgDZOBVLS2eeJni1tBJY+Olp9v fC+ytokxOG1Zhvg+EWxyKQlkB+lXLX/ESgCLtRzxsgyD0Y7E1/vW7XQhS/pjfKjIVYA+ +6I29kdEZaA54b9NHpNwuiGJ9tJeNwuRWXvJQL/He4ulb9e3VMR86++7zxETlJuoY/ei ayYg== 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=yoxQWlaGM752Q9CZt1fEnrsJTyOLLEvttoZehFozaxJFcRJBc9Yu9Y0WdYLHArvH3E 0oXIcnWYayuUoOhyewQn2nrMP83SdND2Rl+gqL8o4VXP4s56QEJokYhbN1lg7jsZBk4X sFmf3tT8PbMYM0vd5mc7XLKnZFakKw0xNdxyvmn2SWcgj3gNw3Y5vLhEDAkHCa51hkhg Jv3an5Sk6Lo6aomgwQiRkOKUUjEQG6VKuwB9GGRpiFWnHHMsIhQuILS6hwdTjXrCRVNR E04nwY6CG8kPDSBOBFow44DsQscdxt5tVHVrrwRQC8Bd42B2lEbqJJ8gmGsJicy/M7Or 3+4w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@riseup.net header.s=squak header.b=L+97ygHV; 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 x31-20020a056a00189f00b0056beba0b31dsi5284128pfh.8.2022.10.25.16.13.07; Tue, 25 Oct 2022 16:13:49 -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=L+97ygHV; 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 S232226AbiJYXLh (ORCPT + 99 others); Tue, 25 Oct 2022 19:11:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34570 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231877AbiJYXLd (ORCPT ); Tue, 25 Oct 2022 19:11:33 -0400 Received: from mx1.riseup.net (mx1.riseup.net [198.252.153.129]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 49374F985F; Tue, 25 Oct 2022 16:11:32 -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 4MxnkW1xkfzDqXG; Tue, 25 Oct 2022 23:11:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=riseup.net; s=squak; t=1666739491; bh=0pG8SvKuzdedA/Y6PPMpy9eA/KJ5S97Kj4xvsRk+czU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=L+97ygHVOrcJgHp+kqYQzkvQainx4kkspCGs6oru6Re7hXqPybXHsNqKkmno28R1h cZgFUyVvsX8m+SWmF9aN0QK10M7m1ZFjiMkI4hZTCKff3SzFewYLkgPRR4WxZPOO+8 cKX1jkY3IBiFoRhqc1w5a6ley5SF+hqam5ffKwlY= X-Riseup-User-ID: BA211A02475AF8302F99CDD671E8C4FFCD96BC6BF9AD6432FBEECEB7D89BC16A Received: from [127.0.0.1] (localhost [127.0.0.1]) by fews2.riseup.net (Postfix) with ESMTPSA id 4MxnkP2mV9z214Q; Tue, 25 Oct 2022 23:11:25 +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 v7 2/3] kunit: Add KUnit memory block assertions to the example_all_expect_macros_test Date: Tue, 25 Oct 2022 20:10:42 -0300 Message-Id: <20221025231043.115295-3-mairacanal@riseup.net> In-Reply-To: <20221025231043.115295-1-mairacanal@riseup.net> References: <20221025231043.115295-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, URIBL_BLOCKED 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?1747703174160357463?= X-GMAIL-MSGID: =?utf-8?q?1747703174160357463?= 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.