From: Robin Murphy <robin.murphy@arm.com>
To: Mostafa Saleh <smostafa@google.com>
Cc: iommu@lists.linux.dev, linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org, will@kernel.org, joro@8bytes.org,
jgg@ziepe.ca, praan@google.com, Jason Gunthorpe <jgg@nvidia.com>
Subject: Re: [PATCH v5 4/4] iommu/io-pgtable-arm-selftests: Use KUnit
Date: Wed, 15 Oct 2025 14:51:15 +0100 [thread overview]
Message-ID: <b48193a4-a37b-41ba-b4ba-8b5c67d812bd@arm.com> (raw)
In-Reply-To: <aO9vI1aEhnyZx1PL@google.com>
On 2025-10-15 10:53 am, Mostafa Saleh wrote:
[...]
>>> + KUNIT_FAIL(test, ""); \
>>> + kunit_err(test, "selftest: test failed for fmt idx %d\n", (i)); \
>>
>> This looks suspect - AFAICS open-coded kunit_err() is intended for test
>> infrastucture errors (like the allocation in the next hunk below), while for
>> an actual test report message it seems it should just be:
>>
>> KUNIT_FAIL(test, "selftest: test failed for fmt idx %d\n", (i));
>
> I see, I used kunit_err, as KUNIT_FAIL adds extra information which was
> noisy to be printed more than once as:
> # arm_lpae_do_selftests: EXPECTATION FAILED at drivers/iommu/io-pgtable-arm-selftests.c:91
> I will check if there is a better way to do this.
But isn't that exactly what we want? The tests should not fail, but if
they ever do then inevitably you're going to be asked to debug it from
nothing more than a dmesg snippet in a forwarded email. Loud and
detailed is good ;)
If anything we can trim the generic message to just the minimal useful
information about the format, if KUnit can now provide the rest of the
attribution for us. Ultimately we should aim to log all the test
conditions together in one place (and probably only upon a failure, such
that normal successful runs are quiet), but that can be a job for the
future follow-up refactoring.
[...]
>>> + dev = kunit_device_register(test, "io-pgtable-test");
>>> + KUNIT_EXPECT_NOT_ERR_OR_NULL(test, dev);
>>
>> Conversely, this is infrastructure, not an actual test of expected
>> io-pgtable behaviour, so I think just:
>>
>> cfg.iommu_dev = kunit_device_register(test, "io-pgtable-test");
>> if (IS_ERR(cfg.iommu_dev))
>> return;
>>
>> (it doesn't return NULLs either)
>>
>
> Yes, I was not sure about this one, when checking the code base, every test
> handles kunit_device_register() failure differently, this seemed the
> most strict one so I used it, I will update that in the next version.
Yeah, my impression is that those have likely been copied from the
lib/kunit/ code where it is actually testing its own API. I've now sent
a patch for the example in the docs...
Cheers,
Robin.
next prev parent reply other threads:[~2025-10-15 13:51 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-29 15:49 [PATCH v5 0/4] Move io-pgtable-arm selftest to KUnit Mostafa Saleh
2025-09-29 15:49 ` [PATCH v5 1/4] iommu/io-pgtable-arm: Simplify error prints for selftests Mostafa Saleh
2025-10-14 11:09 ` Robin Murphy
2025-10-15 9:41 ` Mostafa Saleh
2025-09-29 15:49 ` [PATCH v5 2/4] iommu/io-pgtable-arm: Move selftests to a separate file Mostafa Saleh
2025-09-29 15:49 ` [PATCH v5 3/4] iommu/io-pgtable-arm-selftests: Modularize the test Mostafa Saleh
2025-09-29 15:49 ` [PATCH v5 4/4] iommu/io-pgtable-arm-selftests: Use KUnit Mostafa Saleh
2025-10-14 13:43 ` Robin Murphy
2025-10-15 9:53 ` Mostafa Saleh
2025-10-15 13:51 ` Robin Murphy [this message]
2025-10-15 15:10 ` Jason Gunthorpe
2025-10-16 17:17 ` Robin Murphy
2025-10-16 17:25 ` Jason Gunthorpe
2025-10-17 13:04 ` Mostafa Saleh
2025-10-17 14:13 ` Jason Gunthorpe
2025-10-17 17:59 ` Mostafa Saleh
2025-10-13 9:32 ` [PATCH v5 0/4] Move io-pgtable-arm selftest to KUnit Mostafa Saleh
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=b48193a4-a37b-41ba-b4ba-8b5c67d812bd@arm.com \
--to=robin.murphy@arm.com \
--cc=iommu@lists.linux.dev \
--cc=jgg@nvidia.com \
--cc=jgg@ziepe.ca \
--cc=joro@8bytes.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=praan@google.com \
--cc=smostafa@google.com \
--cc=will@kernel.org \
/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).