Received: by 2002:a05:6358:51dd:b0:131:369:b2a3 with SMTP id 29csp1274250rwl; Thu, 10 Aug 2023 08:49:58 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEq3VxfXcmgEvuB+SDBcRl/Q9CNeTrw20rLf9v4YzJWzy/4ELbf10pc4NteiC9iZLnlMDeB X-Received: by 2002:a17:906:3cb1:b0:99c:af71:1c49 with SMTP id b17-20020a1709063cb100b0099caf711c49mr2243337ejh.23.1691682597571; Thu, 10 Aug 2023 08:49:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691682597; cv=none; d=google.com; s=arc-20160816; b=BdicPJnZ/Wjulcp4zTMBzP4VUGud/9LzBb2h1aN2hWKvRy73AUxyvhrAPtL/A377g+ uu+CYhF+hrtZYp4w0hZDu3zfjUvyWyveIJ7UGueE95mOmTDCOn8PndmRxk4C+gtmN33q gZR32DNDRlvBbCZXcrflItoY4gDvuRI7R571xXSZaUZo+z8SUHRt/2qx6gs7goEfRmtX Rj/WbgDjfoHP3xXxubl1bdP2g5XqvfyD080PNLo+R3yJ3y8TZ6VrbWOoLVQBEgbmIbXA Q3KSmWq1rxY985PVtIOddjqAwnx5PUZRYBzKKhNP81l3xn3k0euPmto/nVsXYzqWjmDC HrzA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=FriU4c2Lao1c9g+S/b4Cgqkvi5bccIniaoSIMdpiGL4=; fh=RAx9Ei+zMa3aQ0yzh4sF0oA1dY2Xx6Zhd9m22OXSH5Y=; b=J1Jas36DeLz7gPWdSlBUg+gO6mn7pkUE50HmUiDku0zunv57NblCzvBULof6pPgbBa pZ209Zr9jv6n1EjuJg5RU+g3qAENVTSVK0ZHqzBoqk2sOjRPaRrxy53IYij5WfOPVbw4 Y5xo1V3WYCCzw3kCFXQlAzuP8u0U9NI19ZR0sQHuVWeSwWsrKqHHfay1Q8xa971SMN/4 S/Msbyz6tWdlz0a48jdWWp+MYnpBc3vNXX8cki9b1HT2jzkzTDPBPOaYdu5kJLhACdF0 mdSbP8O53qiJzo68woOBVdy1yOKEIXIxXUS6OvMd5qroSWhQxT1ubS9EKnI4VUStxhGd gx8g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cirrus.com header.s=PODMain02222019 header.b=Ju13FzT+; 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=cirrus.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id lc28-20020a170906dffc00b0099caf27e61fsi1776491ejc.244.2023.08.10.08.49.32; Thu, 10 Aug 2023 08:49:57 -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=@cirrus.com header.s=PODMain02222019 header.b=Ju13FzT+; 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=cirrus.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230240AbjHJOY1 (ORCPT + 99 others); Thu, 10 Aug 2023 10:24:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39280 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234927AbjHJOYW (ORCPT ); Thu, 10 Aug 2023 10:24:22 -0400 Received: from mx0b-001ae601.pphosted.com (mx0b-001ae601.pphosted.com [67.231.152.168]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 65A4D2698; Thu, 10 Aug 2023 07:24:22 -0700 (PDT) Received: from pps.filterd (m0077474.ppops.net [127.0.0.1]) by mx0b-001ae601.pphosted.com (8.17.1.22/8.17.1.22) with ESMTP id 37ACi1nw013806; Thu, 10 Aug 2023 09:24:16 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cirrus.com; h= message-id:date:mime-version:subject:to:cc:references:from :in-reply-to:content-type:content-transfer-encoding; s= PODMain02222019; bh=FriU4c2Lao1c9g+S/b4Cgqkvi5bccIniaoSIMdpiGL4=; b= Ju13FzT+U0mpl0cJbuM5tDngRZ+u0Lf7/sc2iPeTyzOshd3ibjwU3xL0wVL81gQ/ 5BLC7SyXqeKket+sBq2pLmuqlDIPYDcnF9Xz4RM+zz0l8L7YhPhQeffudzEaOY1L dqcO60JPdLJz/rLVJvkm5lp5+QSCOb/ktDhsJVGyKh7mW9dSnAiZ71NChZpmVtYj dB8IrEbwNHfiTNkLSWnjmi+8uOqGsD+z85ELmVa2o4+7FXCmKqcENoDpl/XkPDgQ x9ZZUAD7+RkE+3iuCTs4MRWfKmahnylWbKCtrJfVDxmIklLLQbjUiz5eH8ZFivNl te52eHjj1UBebOV9vJRcQg== Received: from ediex01.ad.cirrus.com ([84.19.233.68]) by mx0b-001ae601.pphosted.com (PPS) with ESMTPS id 3s9juhvwbv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 10 Aug 2023 09:24:16 -0500 (CDT) Received: from ediex02.ad.cirrus.com (198.61.84.81) by ediex01.ad.cirrus.com (198.61.84.80) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.30; Thu, 10 Aug 2023 15:24:14 +0100 Received: from ediswmail.ad.cirrus.com (198.61.86.93) by anon-ediex02.ad.cirrus.com (198.61.84.81) with Microsoft SMTP Server id 15.2.1118.30 via Frontend Transport; Thu, 10 Aug 2023 15:24:14 +0100 Received: from [198.61.64.220] (EDIN4L06LR3.ad.cirrus.com [198.61.64.220]) by ediswmail.ad.cirrus.com (Postfix) with ESMTP id 1C0CC11AA; Thu, 10 Aug 2023 14:24:14 +0000 (UTC) Message-ID: <08e1bba0-5ccc-dac1-28c9-81e69c996337@opensource.cirrus.com> Date: Thu, 10 Aug 2023 15:24:13 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.14.0 Subject: Re: [PATCH v3 4/7] kunit: kunit-test: Test logging a line that exactly fills a fragment Content-Language: en-US To: Rae Moar CC: , , , , , References: <20230809155438.22470-1-rf@opensource.cirrus.com> <20230809155438.22470-5-rf@opensource.cirrus.com> From: Richard Fitzgerald In-Reply-To: Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 8bit X-Proofpoint-GUID: qXFC28PgDJ3irGmoQL1J25lZ-SAKqkcd X-Proofpoint-ORIG-GUID: qXFC28PgDJ3irGmoQL1J25lZ-SAKqkcd X-Proofpoint-Spam-Reason: safe X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,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 On 9/8/23 22:22, Rae Moar wrote: > On Wed, Aug 9, 2023 at 11:54 AM 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 well. > > 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 *test) >> #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 = kunit_kzalloc(test, sizeof(*suite.log), GFP_KERNEL); >> + KUNIT_ASSERT_NOT_ERR_OR_NULL(test, suite.log); >> + INIT_LIST_HEAD(suite.log); >> + frag = 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 = 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. I think ASSERT is appropriate here. This isn't testing anything (unless you don't trust memset). It's ensuring that the test data I generate is what I expect otherwise the following testing is invalid. This is redundant because the first 3 lines must produce the expected string, but I put it in to prove to myself that I can do math and decided to leave it in.