Re: [PATCH v5 2/2] scanf: break kunit into test cases
From: Geert Uytterhoeven
Date: Mon Feb 10 2025 - 11:27:28 EST
Hi Tamir,
On Mon, 10 Feb 2025 at 16:00, Tamir Duberstein <tamird@xxxxxxxxx> wrote:
> Use `suite_init` and move some tests into `scanf_test_cases`. This
> gives us nicer output in the event of a failure.
>
> Reviewed-by: David Gow <davidgow@xxxxxxxxxx>
> Signed-off-by: Tamir Duberstein <tamird@xxxxxxxxx>
Thanks for your patch!
> --- a/lib/scanf_kunit.c
> +++ b/lib/scanf_kunit.c
> @@ -4,19 +4,14 @@
> */
>
> #include <kunit/test.h>
> -#include <linux/bitops.h>
> -#include <linux/kernel.h>
> #include <linux/module.h>
> -#include <linux/overflow.h>
> -#include <linux/printk.h>
> #include <linux/prandom.h>
> -#include <linux/slab.h>
> -#include <linux/string.h>
> +#include <linux/sprintf.h>
>
> #define BUF_SIZE 1024
>
> -static char *test_buffer;
> -static char *fmt_buffer;
> +static char test_buffer[BUF_SIZE];
> +static char fmt_buffer[BUF_SIZE];
Why? This wastes 2 KiB of memory when the test is not running.
> static struct rnd_state rnd_state;
>
> typedef void (*check_fn)(struct kunit *test, const void *check_data, const char *string,
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@xxxxxxxxxxxxxx
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds