linux-kselftest.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Gow <davidgow@google.com>
To: "Maíra Canal" <mairacanal@riseup.net>
Cc: Brendan Higgins <brendanhiggins@google.com>,
	Daniel Latypov <dlatypov@google.com>,
	airlied@gmail.com, daniel@ffwll.ch, davem@davemloft.net,
	kuba@kernel.org, jose.exposito89@gmail.com, javierm@redhat.com,
	andrealmeid@riseup.net, melissa.srw@gmail.com,
	siqueirajordao@riseup.net, Isabella Basso <isabbasso@riseup.net>,
	magalilemes00@gmail.com, tales.aparecida@gmail.com,
	linux-kselftest@vger.kernel.org, kunit-dev@googlegroups.com,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v6 0/3] Introduce KUNIT_EXPECT_MEMEQ and KUNIT_EXPECT_MEMNEQ macros
Date: Wed, 19 Oct 2022 14:53:42 +0800	[thread overview]
Message-ID: <CABVgOSmzP9BQyusYL8btZLkCBmnMss26Rx8oF==VpVs82rH5hw@mail.gmail.com> (raw)
In-Reply-To: <20221018190541.189780-1-mairacanal@riseup.net>

[-- Attachment #1: Type: text/plain, Size: 3416 bytes --]

On Wed, Oct 19, 2022 at 3:06 AM Maíra Canal <mairacanal@riseup.net> wrote:
>
> Currently, in order to compare memory blocks in KUnit, the KUNIT_EXPECT_EQ or
> KUNIT_EXPECT_FALSE macros are used in conjunction with the memcmp function,
> such as:
>   KUNIT_EXPECT_EQ(test, memcmp(foo, bar, size), 0);
>
> Although this usage produces correct results for the test cases, if the
> expectation fails the error message is not very helpful, indicating only the
> return of the memcmp function.
>
> Therefore, create a new set of macros KUNIT_EXPECT_MEMEQ and
> KUNIT_EXPECT_MEMNEQ that compare memory blocks until a determined size. In
> case of expectation failure, those macros print the hex dump of the memory
> blocks, making it easier to debug test failures for memory blocks.
>
> The v6 has some changes on the first patch, due to rebase on top of Linux 6.1,
> specially the renaming of KUNIT_ASSERTION macro to _KUNIT_FAILED
> (97d453bc4007d4ac148c2ba89904026612b91ec9). Moreover, the DRM KUnit tests were
> mainlined in 6.1.
>
> The first patch of the series introduces the KUNIT_EXPECT_MEMEQ and
> KUNIT_EXPECT_MEMNEQ. The second patch adds an example of memory block
> expectations on the kunit-example-test.c. And the last patch replaces the
> KUNIT_EXPECT_EQ for KUNIT_EXPECT_MEMEQ on the existing occurrences.
>
> Best Regards,
> - Maíra Canal
>
> v1 -> v2: https://lore.kernel.org/linux-kselftest/2a0dcd75-5461-5266-2749-808f638f4c50@riseup.net/T/#m402cc72eb01fb3b88d6706cf7d1705fdd51e5da2
>
> - Change "determinated" to "specified" (Daniel Latypov).
> - Change the macro KUNIT_EXPECT_ARREQ to KUNIT_EXPECT_MEMEQ, in order to make
> it easier for users to infer the right size unit (Daniel Latypov).
> - Mark the different bytes on the failure message with a <> (Daniel Latypov).
> - Replace a constant number of array elements for ARRAY_SIZE() (André Almeida).
> - Rename "array" and "expected" variables to "array1" and "array2" (Daniel Latypov).
>
> v2 -> v3: https://lore.kernel.org/linux-kselftest/20220802212621.420840-1-mairacanal@riseup.net/T/#t
>
> - Make the bytes aligned at output.
> - Add KUNIT_SUBSUBTEST_INDENT to the output for the indentation (Daniel Latypov).
> - Line up the trailing \ at macros using tabs (Daniel Latypov).
> - Line up the params to the functions (Daniel Latypov).
> - Change "Increament" to "Augment" (Daniel Latypov).
> - Use sizeof() for array sizes (Daniel Latypov).
> - Add Daniel Latypov's tags.
>
> v3 -> v4: https://lore.kernel.org/linux-kselftest/CABVgOSm_59Yr82deQm2C=18jjSv_akmn66zs4jxx3hfziXPeHg@mail.gmail.com/T/#t
>
> - Fix wrapped lines by the mail client (David Gow).
> - Mention on documentation that KUNIT_EXPECT_MEMEQ is not recommended for
> structured data (David Gow).
> - Add Muhammad Usama Anjum's tag.
>
> v4 -> v5: https://lore.kernel.org/linux-kselftest/20220808125237.277126-1-mairacanal@riseup.net/
>
> - Rebase on top of drm-misc-next.
> - Add David Gow's tags.
>
> v5 -> v6: https://lore.kernel.org/linux-kselftest/20220921014515.113062-1-mairacanal@riseup.net/
>
> - Rebase on top of Linux 6.1.
> - Change KUNIT_ASSERTION macro to _KUNIT_FAILED.
>

Thanks a bunch for rebasing this. It works well here, and I'm planning
to use it in some tests I'm writing!

One minor formatting comment on patch 1/3, otherwise this whole series
is good to go.

Cheers,
-- David

[-- Attachment #2: S/MIME Cryptographic Signature --]
[-- Type: application/pkcs7-signature, Size: 4003 bytes --]

      parent reply	other threads:[~2022-10-19  6:54 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-18 19:05 [PATCH v6 0/3] Introduce KUNIT_EXPECT_MEMEQ and KUNIT_EXPECT_MEMNEQ macros Maíra Canal
2022-10-18 19:05 ` [PATCH v6 1/3] kunit: " Maíra Canal
2022-10-18 21:12   ` Daniel Latypov
2022-10-19  6:53   ` David Gow
2022-10-18 19:05 ` [PATCH v6 2/3] kunit: Add KUnit memory block assertions to the example_all_expect_macros_test Maíra Canal
2022-10-18 19:05 ` [PATCH v6 3/3] kunit: Use KUNIT_EXPECT_MEMEQ macro Maíra Canal
2022-10-19  6:53 ` David Gow [this message]

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='CABVgOSmzP9BQyusYL8btZLkCBmnMss26Rx8oF==VpVs82rH5hw@mail.gmail.com' \
    --to=davidgow@google.com \
    --cc=airlied@gmail.com \
    --cc=andrealmeid@riseup.net \
    --cc=brendanhiggins@google.com \
    --cc=daniel@ffwll.ch \
    --cc=davem@davemloft.net \
    --cc=dlatypov@google.com \
    --cc=isabbasso@riseup.net \
    --cc=javierm@redhat.com \
    --cc=jose.exposito89@gmail.com \
    --cc=kuba@kernel.org \
    --cc=kunit-dev@googlegroups.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=magalilemes00@gmail.com \
    --cc=mairacanal@riseup.net \
    --cc=melissa.srw@gmail.com \
    --cc=siqueirajordao@riseup.net \
    --cc=tales.aparecida@gmail.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;
as well as URLs for NNTP newsgroup(s).