On Fri 2025-02-14 11:20:00, Tamir Duberstein wrote:
> Convert the scanf() self-test to a KUnit test.
> 
> In the interest of keeping the patch reasonably-sized this doesn't
> refactor the tests into proper parameterized tests - it's all one big
> test case.
> 
> --- a/lib/test_scanf.c
> +++ b/lib/tests/scanf_kunit.c
> @@ -15,48 +13,35 @@
>  #include <linux/slab.h>
>  #include <linux/string.h>
>  
> -#include "../tools/testing/selftests/kselftest_module.h"
> -
>  #define BUF_SIZE 1024
>  
> -KSTM_MODULE_GLOBALS();
> -static char *test_buffer __initdata;
> -static char *fmt_buffer __initdata;
> -static struct rnd_state rnd_state __initdata;
> +static char *test_buffer;
> +static char *fmt_buffer;
> +static struct rnd_state rnd_state;
>  
> -typedef int (*check_fn)(const char *file, const int line, const void 
> *check_data,
> -                     const char *string, const char *fmt, int n_args, 
> va_list ap);
> +typedef void (*check_fn)(struct kunit *test, const char *file, const int 
> line,
> +                      const void *check_data, const char *string, const char 
> *fmt, int n_args,
> +                      va_list ap);
>  
> -static void __scanf(6, 0) __init
> -_test(const char *file, const int line, check_fn fn, const void *check_data, 
> const char *string,
> -     const char *fmt, int n_args, ...)
> +static void __scanf(7, 0)

This should be:

static void __scanf(7, 9)

Otherwise, the compilation with W=1 produces the warning reported by
the l...@intel.com kernel test robot, see
https://lore.kernel.org/r/202502160245.kurrybjr-...@intel.com

> +_test(struct kunit *test, const char *file, const int line, check_fn fn, 
> const void *check_data,
> +     const char *string, const char *fmt, int n_args, ...)
>  {
>       va_list ap, ap_copy;
>       int ret;

Otherwise, it looks good to me.

With the above fix:

Reviewed-by: Petr Mladek <pmla...@suse.com>
Tested-by: Petr Mladek <pmla...@suse.com>

Best Regards,
Petr

Reply via email to