From: Christian König <christian.koenig@amd.com>
To: Jason Gunthorpe <jgg@nvidia.com>,
David Airlie <airlied@gmail.com>,
dri-devel@lists.freedesktop.org, intel-gfx@lists.freedesktop.org,
Jani Nikula <jani.nikula@linux.intel.com>,
Joonas Lahtinen <joonas.lahtinen@linux.intel.com>,
linaro-mm-sig@lists.linaro.org, linux-media@vger.kernel.org,
Rodrigo Vivi <rodrigo.vivi@intel.com>,
Simona Vetter <simona@ffwll.ch>,
Sumit Semwal <sumit.semwal@linaro.org>,
Tvrtko Ursulin <tursulin@ursulin.net>
Cc: patches@lists.linux.dev
Subject: Re: [PATCH 0/5] Replace the dmabuf custom test framework with kunit
Date: Mon, 2 Mar 2026 12:43:34 +0100 [thread overview]
Message-ID: <7c30f527-abc4-43a9-a11c-9233015b0a59@amd.com> (raw)
In-Reply-To: <0-v1-0a349a394eff+14110-dmabuf_kunit_jgg@nvidia.com>
On 3/1/26 19:57, Jason Gunthorpe wrote:
> Using kunit to write tests for new work on dmabuf is coming up:
>
> https://lore.kernel.org/all/26-v1-b5cab63049c0+191af-dmabuf_map_type_jgg@nvidia.com/
>
> Replace the custom test framework with kunit to avoid maintaining two
> concurrent test frameworks.
Oh, yes that was on my todo list for like an eternity as well.
No idea when or even if I have time to review that, but feel free to add my Acked-by should that go upstream.
Regards,
Christian.
>
> The conversion minimizes code changes and uses simple pattern-oriented
> reworks to reduce the chance of breaking any tests. Aside from adding the
> kunit_test_suite() boilerplate, the conversion follows a number of
> patterns:
>
> Test failures without cleanup. For example:
> if (!ptr)
> return -ENOMEM;
> Becomes:
> KUNIT_ASSERT_NOT_NULL(test, ptr);
>
> In kunit ASSERT longjumps out of the test.
>
> Check for error, fail and cleanup:
> if (err) {
> pr_err("msg\n");
> goto cleanup;
> }
> Becomes:
> if (err) {
> KUNIT_FAIL(test, "msg");
> goto cleanup;
> }
> Preserve the existing failure messages and cleanup code.
>
> Cases where the test returns err but prints no message:
> if (err)
> goto cleanup;
> Becomes:
> if (err) {
> KUNIT_FAIL(test, "msg");
> goto cleanup;
> }
> Use KUNIT_FAIL to retain the 'cleanup on err' behavior.
>
> Overall, the conversion is straightforward.
>
> The result can be run with kunit.py:
>
> $ tools/testing/kunit/kunit.py run --build_dir build_kunit_x86_64 --arch x86_64 --kunitconfig ./drivers/dma-buf/.kunitconfig
> [20:37:23] Configuring KUnit Kernel ...
> [20:37:23] Building KUnit Kernel ...
> Populating config with:
> $ make ARCH=x86_64 O=build_kunit_x86_64 olddefconfig
> Building with:
> $ make all compile_commands.json scripts_gdb ARCH=x86_64 O=build_kunit_x86_64 --jobs=20
> [20:37:29] Starting KUnit Kernel (1/1)...
> [20:37:29] ============================================================
> Running tests with:
> $ qemu-system-x86_64 -nodefaults -m 1024 -kernel build_kunit_x86_64/arch/x86/boot/bzImage -append 'kunit.enable=1 console=ttyS0 kunit_shutdown=reboot' -no-reboot -nographic -accel kvm -accel hvf -accel tcg -serial stdio -bios qboot.rom
> [20:37:30] ================ dma-buf-resv (5 subtests) =================
> [20:37:30] [PASSED] test_sanitycheck
> [20:37:30] ===================== test_signaling ======================
> [20:37:30] [PASSED] kernel
> [20:37:30] [PASSED] write
> [20:37:30] [PASSED] read
> [20:37:30] [PASSED] bookkeep
> [20:37:30] ================= [PASSED] test_signaling ==================
> ...
> [20:37:35] Testing complete. Ran 50 tests: passed: 49, skipped: 1
> [20:37:35] Elapsed time: 12.635s total, 0.001s configuring, 6.551s building, 6.017s running
>
> One test that requires two CPUs is skipped since the default VM has a
> single CPU and cannot run the test.
>
> All other usual ways to run kunit work as well, and all tests are placed
> in a module to provide more options for how they are run.
>
> AI was used to do the large scale semantic search and replaces described
> above, then everything was hand checked. AI also deduced the issue with
> test_race_signal_callback() in a couple of seconds from the kunit
> crash (!!), again was hand checked though I am not so familiar with this
> test to be fully certain this is the best answer.
>
> Jason Gunthorpe (5):
> dma-buf: Change st-dma-resv.c to use kunit
> dma-buf: Change st-dma-fence.c to use kunit
> dma-buf: Change st-dma-fence-unwrap.c to use kunit
> dma-buf: Change st-dma-fence-chain.c to use kunit
> dma-buf: Remove the old selftest
>
> drivers/dma-buf/.kunitconfig | 2 +
> drivers/dma-buf/Kconfig | 11 +-
> drivers/dma-buf/Makefile | 5 +-
> drivers/dma-buf/selftest.c | 167 ---------------
> drivers/dma-buf/selftest.h | 30 ---
> drivers/dma-buf/selftests.h | 16 --
> drivers/dma-buf/st-dma-fence-chain.c | 217 +++++++++----------
> drivers/dma-buf/st-dma-fence-unwrap.c | 290 +++++++++++---------------
> drivers/dma-buf/st-dma-fence.c | 200 ++++++++----------
> drivers/dma-buf/st-dma-resv.c | 145 +++++++------
> drivers/gpu/drm/i915/Kconfig.debug | 2 +-
> 11 files changed, 394 insertions(+), 691 deletions(-)
> create mode 100644 drivers/dma-buf/.kunitconfig
> delete mode 100644 drivers/dma-buf/selftest.c
> delete mode 100644 drivers/dma-buf/selftest.h
> delete mode 100644 drivers/dma-buf/selftests.h
>
>
> base-commit: 41dae5ac5e157b0bb260f381eb3df2f4a4610205
next prev parent reply other threads:[~2026-03-02 11:43 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-01 18:57 [PATCH 0/5] Replace the dmabuf custom test framework with kunit Jason Gunthorpe
2026-03-01 18:57 ` [PATCH 1/5] dma-buf: Change st-dma-resv.c to use kunit Jason Gunthorpe
2026-03-03 3:50 ` Claude review: " Claude Code Review Bot
2026-03-01 18:57 ` [PATCH 2/5] dma-buf: Change st-dma-fence.c " Jason Gunthorpe
2026-03-03 3:50 ` Claude review: " Claude Code Review Bot
2026-03-01 18:57 ` [PATCH 3/5] dma-buf: Change st-dma-fence-unwrap.c " Jason Gunthorpe
2026-03-03 3:50 ` Claude review: " Claude Code Review Bot
2026-03-01 18:57 ` [PATCH 4/5] dma-buf: Change st-dma-fence-chain.c " Jason Gunthorpe
2026-03-03 3:50 ` Claude review: " Claude Code Review Bot
2026-03-01 18:57 ` [PATCH 5/5] dma-buf: Remove the old selftest Jason Gunthorpe
2026-03-03 3:50 ` Claude review: " Claude Code Review Bot
2026-03-02 11:43 ` Christian König [this message]
2026-03-02 13:01 ` [PATCH 0/5] Replace the dmabuf custom test framework with kunit Jason Gunthorpe
2026-03-02 13:58 ` Christian König
2026-03-03 3:50 ` Claude review: " Claude Code Review Bot
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=7c30f527-abc4-43a9-a11c-9233015b0a59@amd.com \
--to=christian.koenig@amd.com \
--cc=airlied@gmail.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=intel-gfx@lists.freedesktop.org \
--cc=jani.nikula@linux.intel.com \
--cc=jgg@nvidia.com \
--cc=joonas.lahtinen@linux.intel.com \
--cc=linaro-mm-sig@lists.linaro.org \
--cc=linux-media@vger.kernel.org \
--cc=patches@lists.linux.dev \
--cc=rodrigo.vivi@intel.com \
--cc=simona@ffwll.ch \
--cc=sumit.semwal@linaro.org \
--cc=tursulin@ursulin.net \
/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