Linux Kernel Selftest development
 help / color / mirror / Atom feed
From: Richard Fitzgerald <rf@opensource.cirrus.com>
To: Rae Moar <rmoar@google.com>
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>
Subject: Re: [PATCH v3 4/7] kunit: kunit-test: Test logging a line that exactly fills a fragment
Date: Thu, 10 Aug 2023 15:24:13 +0100	[thread overview]
Message-ID: <08e1bba0-5ccc-dac1-28c9-81e69c996337@opensource.cirrus.com> (raw)
In-Reply-To: <CA+GJov5tw2kCmy=Qrnw4EK9Dr91MXAsOmai0XFz-2tfgZ724vg@mail.gmail.com>

On 9/8/23 22:22, Rae Moar wrote:
> On Wed, Aug 9, 2023 at 11:54 AM Richard Fitzgerald
> <rf@opensource.cirrus.com> 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 <rf@opensource.cirrus.com>
> 
> 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.

  reply	other threads:[~2023-08-10 14:24 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-09 15:54 [PATCH v3 0/7] kunit: Add dynamically-extending log Richard Fitzgerald
2023-08-09 15:54 ` [PATCH v3 1/7] kunit: Replace fixed-size log with dynamically-extending buffer Richard Fitzgerald
2023-08-09 21:10   ` Rae Moar
2023-08-10 14:00     ` Richard Fitzgerald
2023-08-09 15:54 ` [PATCH v3 2/7] kunit: kunit-test: Add test cases for extending log buffer Richard Fitzgerald
2023-08-09 21:10   ` Rae Moar
2023-08-10 14:18     ` Richard Fitzgerald
2023-08-09 15:54 ` [PATCH v3 3/7] kunit: Handle logging of lines longer than the fragment buffer size Richard Fitzgerald
2023-08-10 14:38   ` David Gow
2023-08-10 15:09     ` Richard Fitzgerald
2023-08-11  8:27       ` David Gow
2023-08-10 22:41     ` Rae Moar
2023-08-09 15:54 ` [PATCH v3 4/7] kunit: kunit-test: Test logging a line that exactly fills a fragment Richard Fitzgerald
2023-08-09 21:22   ` Rae Moar
2023-08-10 14:24     ` Richard Fitzgerald [this message]
2023-08-09 15:54 ` [PATCH v3 5/7] kunit: kunit-test: Add test cases for logging very long lines Richard Fitzgerald
2023-08-10 22:58   ` Rae Moar
2023-08-09 15:54 ` [PATCH v3 6/7] kunit: kunit-test: Add test of logging only a newline Richard Fitzgerald
2023-08-10 23:02   ` Rae Moar
2023-08-09 15:54 ` [PATCH v3 7/7] kunit: Don't waste first attempt to format string in kunit_log_append() Richard Fitzgerald
2023-08-10 23:53   ` Rae Moar
2023-08-11  8:27   ` David Gow

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=08e1bba0-5ccc-dac1-28c9-81e69c996337@opensource.cirrus.com \
    --to=rf@opensource.cirrus.com \
    --cc=brendan.higgins@linux.dev \
    --cc=davidgow@google.com \
    --cc=kunit-dev@googlegroups.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=patches@opensource.cirrus.com \
    --cc=rmoar@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox