Received: by 2002:a05:6358:51dd:b0:131:369:b2a3 with SMTP id 29csp368740rwl; Wed, 9 Aug 2023 16:11:36 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHU3VdHc2nWLhjFZEmuKrmKyPUZgYls1vs0LeHQbfdVVP2TsZpF3i/FqGE+unmAgccIhoJy X-Received: by 2002:a05:6a00:3a10:b0:686:ec1d:18e5 with SMTP id fj16-20020a056a003a1000b00686ec1d18e5mr653306pfb.28.1691622695714; Wed, 09 Aug 2023 16:11:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691622695; cv=none; d=google.com; s=arc-20160816; b=KXiTL9j88YAHbhSATPPM/netd8B3aPJxAN7lCzg03cF/205t43x1r2z6P3fqkn2FCM mZlJZPUoAOx3xPMFsjHepxs2DbGnkf5xXll2V2V6jJLrP0+f3dPYO/apUku43OSds4RR kz2fL51tLDyRPGOOg6y44LgDzEGuc4OTxjDVIShXMVXp0319AFH7uBFJxkps18k0QPTP JmOJKXwVkeddFschToe5PvL3jFoBwjRnFP4QA1+Yxxz4EFmCjyBxpNBEI2He6NiJcxYg ePqolOK4xfF19iKw9WzVcYSz1e6lcJqH5o5YT1pdvZDaDGNENBBAhQ3/OFtFECHTltJE ETWg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=OzDUu1hDm/ATiZnfZV5ckNUxU989e7rnsufB9B73ynU=; fh=8UDfi8xBJ790SZyvmkQ8i9XlHyHv9fuRECSK+7qBwQM=; b=SUA57DOl/XR4nW96POQQJZDh0xMHPyrF51Y0thx165I6N/pVhSyvTyDfez9nZFgawF rX+jxq183O/fmaWA+Gh/foXea4brkCXH0MMHYd6WsfLfhq+7bXFKvJyiyCCHbpqDOPJT vpM0jjRHslNOwfb86exCWBBfITTA65PWcqZ0G58arMofg3kVI5s6HWEatKJOJG1R4ko0 Jc62AfMomoAuyKXBG+tkSrrgpmso52rnQlA0jCbC0EYJ9BtYI0Gkf9emQUR/3r6gs4pg Oomq9PGJMDvX3qQCCBJSz/u8ueNEmkvVAvReygeGBohx289mFpJPv2xLKW9Zb8Mc63yz iX/Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=45JFkSEf; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id cv7-20020a056a0044c700b00687080947e0si241417pfb.42.2023.08.09.16.11.23; Wed, 09 Aug 2023 16:11:35 -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=@google.com header.s=20221208 header.b=45JFkSEf; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230003AbjHIVWn (ORCPT + 99 others); Wed, 9 Aug 2023 17:22:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47774 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229906AbjHIVWm (ORCPT ); Wed, 9 Aug 2023 17:22:42 -0400 Received: from mail-wm1-x329.google.com (mail-wm1-x329.google.com [IPv6:2a00:1450:4864:20::329]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 713D91724 for ; Wed, 9 Aug 2023 14:22:41 -0700 (PDT) Received: by mail-wm1-x329.google.com with SMTP id 5b1f17b1804b1-3fe32ec7201so9265e9.1 for ; Wed, 09 Aug 2023 14:22:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1691616160; x=1692220960; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=OzDUu1hDm/ATiZnfZV5ckNUxU989e7rnsufB9B73ynU=; b=45JFkSEfRo/3zF5ZBKajbQu58vncVRAXgsXnR20SR1i7M37MN7xPRj3J9CFsBOmVkW 1v0+QL7pGJjiQjREGXvrw2oQYlXFdFbH4frzGia+82I3fiKtd7BcKEQDpejcMeuOPKBh 7A7YFETwRa9MdVSxsK79ZFmKJe/d11S+P4dY40XlJWc4XGxos5+xfHTF4fJ3HUOc5yzC PI4cWFoQ7oXI7ZwGpEFFyZaOTTEflW6q6t7nyU/GxvCl7ZBJxWH8k0Ej5VOnwDEJY5KE IKofP1UXUHv43uL7NBCso9lgoKqa7LbDrKFJ5SG/0+gwCeQc3wj0v9UziVZglupNRbnU 53YA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691616160; x=1692220960; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=OzDUu1hDm/ATiZnfZV5ckNUxU989e7rnsufB9B73ynU=; b=KFYHorIC5c9tuJkYbCWBpmOnT32mtnKWCYteFDOaoEN4FJzWKp4ssO1VNtqZwWfdgn rqx4UsDr+/0wc+Lfj10WUyCBgy/9NTXpms+6DYOC7q/S6/U/MlBpoX/2LmEvFe09HOno s3geQ0kC3qOdWo00P+9OihkoLXfGT+6MpsGJvaTGNJtzbWfJKRoSceuOtM5lvdm8G8bj +dVCChTaEPAH/YiRFatHYZJeJ6ZHfe3Qe3DRe954k/PxQq6/AHhPtn1BnyP2cJAAs9jc lyqe2wnrDYVplSm2N5AX3MjFx7801/os+ATZt9sc0od88e3oPBWSPBb0QdkfVzEJGPF/ Nleg== X-Gm-Message-State: AOJu0YwFBdep7v+iIz87WUmWhq+YPChbjOxNr2lwvmOM9aXwPY7t0xcT lqiPJ/bnM+C0JnN2LJa+stBmKkTs85ZxkEKmP+GdFg== X-Received: by 2002:a05:600c:500c:b0:3f6:f4b:d4a6 with SMTP id n12-20020a05600c500c00b003f60f4bd4a6mr154162wmr.7.1691616159907; Wed, 09 Aug 2023 14:22:39 -0700 (PDT) MIME-Version: 1.0 References: <20230809155438.22470-1-rf@opensource.cirrus.com> <20230809155438.22470-5-rf@opensource.cirrus.com> In-Reply-To: <20230809155438.22470-5-rf@opensource.cirrus.com> From: Rae Moar Date: Wed, 9 Aug 2023 17:22:28 -0400 Message-ID: Subject: Re: [PATCH v3 4/7] kunit: kunit-test: Test logging a line that exactly fills a fragment To: Richard Fitzgerald Cc: brendan.higgins@linux.dev, davidgow@google.com, linux-kselftest@vger.kernel.org, kunit-dev@googlegroups.com, linux-kernel@vger.kernel.org, patches@opensource.cirrus.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS, USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL 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 On Wed, Aug 9, 2023 at 11:54=E2=80=AFAM Richard Fitzgerald wrote: > > If a log string is the exact length of a log fragment buffer > kunit_log_append() should now exactly fill that fragment without > extending the log. > > Signed-off-by: Richard Fitzgerald Hello! This test looks good to me. I have tested it and it seems to be working wel= l. I appreciate all of the assert and expect statements. I do have one comment below. Although, I would be happy to set this as reviewed by me after that comment is responded to. Thanks! -Rae > --- > lib/kunit/kunit-test.c | 37 +++++++++++++++++++++++++++++++++++++ > 1 file changed, 37 insertions(+) > > diff --git a/lib/kunit/kunit-test.c b/lib/kunit/kunit-test.c > index c0ee33a8031e..9ac81828d018 100644 > --- a/lib/kunit/kunit-test.c > +++ b/lib/kunit/kunit-test.c > @@ -763,12 +763,49 @@ static void kunit_log_extend_test_2(struct kunit *t= est) > #endif > } > > +static void kunit_log_frag_sized_line_test(struct kunit *test) > +{ > +#ifdef CONFIG_KUNIT_DEBUGFS > + struct kunit_suite suite; > + struct kunit_log_frag *frag, *src; > + > + suite.log =3D kunit_kzalloc(test, sizeof(*suite.log), GFP_KERNEL)= ; > + KUNIT_ASSERT_NOT_ERR_OR_NULL(test, suite.log); > + INIT_LIST_HEAD(suite.log); > + frag =3D kunit_kzalloc(test, sizeof(*frag), GFP_KERNEL); > + KUNIT_ASSERT_NOT_ERR_OR_NULL(test, frag); > + kunit_init_log_frag(frag); > + list_add_tail(&frag->list, suite.log); > + > + src =3D kunit_kzalloc(test, sizeof(*src), GFP_KERNEL); > + KUNIT_ASSERT_NOT_ERR_OR_NULL(test, src); > + memset(src->buf, 'x', sizeof(src->buf) - 2); > + KUNIT_ASSERT_EQ(test, strlen(src->buf), sizeof(src->buf) - 2); Should this be an EXPECT instead? It doesn't seem like the test needs to fail immediately if this fails. Let me know what you think. > + > + /* Log a string that exactly fills the fragment */ > + kunit_log_append(suite.log, "%s\n", src->buf); > + KUNIT_EXPECT_TRUE(test, list_is_singular(suite.log)); > + KUNIT_EXPECT_EQ(test, strlen(frag->buf), sizeof(frag->buf) - 1); > + strlcat(src->buf, "\n", sizeof(src->buf)); > + KUNIT_EXPECT_STREQ(test, frag->buf, src->buf); > + > + /* Logging another string should extend the log */ > + kunit_log_append(suite.log, "Next\n"); > + KUNIT_EXPECT_EQ(test, list_count_nodes(suite.log), 2); > + frag =3D list_last_entry(suite.log, struct kunit_log_frag, list); > + KUNIT_EXPECT_STREQ(test, frag->buf, "Next\n"); > +#else > + kunit_skip(test, "only useful when debugfs is enabled"); > +#endif > +} > + > static struct kunit_case kunit_log_test_cases[] =3D { > KUNIT_CASE(kunit_log_init_frag_test), > KUNIT_CASE(kunit_log_test), > KUNIT_CASE(kunit_log_newline_test), > KUNIT_CASE(kunit_log_extend_test_1), > KUNIT_CASE(kunit_log_extend_test_2), > + KUNIT_CASE(kunit_log_frag_sized_line_test), > {} > }; > > -- > 2.30.2 >