Re: [PATCH v10 2/9] revocable: Add KUnit test cases
From: Bartosz Golaszewski
Date: Mon May 11 2026 - 09:17:47 EST
On Fri, 8 May 2026 12:54:41 +0200, Tzung-Bi Shih <tzungbi@xxxxxxxxxx> said:
> Add KUnit test cases for the revocable API.
>
> The test cases cover the following scenarios:
>
> - Basic: Verifies that a consumer can successfully access the resource.
> - Revocation: Verifies that after the provider revokes the resource,
> the consumer correctly receives a NULL pointer on a subsequent access.
> - Try Access Macro: Same as "Revocation" but uses the macro level
> helpers.
> - Concurrent Access: Verifies multiple threads can access the resource.
>
> Signed-off-by: Tzung-Bi Shih <tzungbi@xxxxxxxxxx>
> ---
...
> +
> +config REVOCABLE_KUNIT_TEST
> + tristate "KUnit tests for revocable" if !KUNIT_ALL_TESTS
> + depends on KUNIT
> + default KUNIT_ALL_TESTS
> diff --git a/drivers/base/Makefile b/drivers/base/Makefile
> index bdf854694e39..5fd19abbc83e 100644
> --- a/drivers/base/Makefile
> +++ b/drivers/base/Makefile
> @@ -35,3 +35,6 @@ ccflags-$(CONFIG_DEBUG_DRIVER) := -DDEBUG
> # define_trace.h needs to know how to find our header
> CFLAGS_trace.o := -I$(src)
> obj-$(CONFIG_TRACING) += trace.o
> +
> +# KUnit test cases
> +obj-$(CONFIG_REVOCABLE_KUNIT_TEST) += revocable_test.o
> diff --git a/drivers/base/revocable_test.c b/drivers/base/revocable_test.c
Please move this under drivers/base/tests/ where the rest of kunit modules
live and name it revocable-test.c for consistency with the existing ones.
> new file mode 100644
> index 000000000000..bb776a747ff7
> --- /dev/null
> +++ b/drivers/base/revocable_test.c
> @@ -0,0 +1,405 @@
> +// SPDX-License-Identifier: GPL-2.0
> +/*
> + * Copyright 2026 Google LLC
> + *
> + * KUnit tests for the revocable API.
> + *
> + * The test cases cover the following scenarios:
> + *
> + * - Basic: Verifies that a consumer can successfully access the resource.
> + *
> + * - Revocation: Verifies that after the provider revokes the resource,
> + * the consumer correctly receives a NULL pointer on a subsequent access.
> + *
> + * - Try Access Macro: Same as "Revocation" but uses the macro level
> + * helpers.
> + *
> + * - Concurrent Access: Verifies multiple threads can access the resource.
> + */
> +
> +#include <kunit/test.h>
Add a newline here as do other kunit modules.
> +#include <linux/completion.h>
> +#include <linux/delay.h>
> +#include <linux/kthread.h>
> +#include <linux/refcount.h>
> +#include <linux/revocable.h>
> +
Otherwise looks good, with the above:
Reviewed-by: Bartosz Golaszewski <bartosz.golaszewski@xxxxxxxxxxxxxxxx>
Thanks,
Bartosz