[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <5db2944e-9d64-8faa-83d3-fd02fce583bd@redhat.com>
Date: Wed, 29 Jun 2022 13:34:54 +0200
From: David Hildenbrand <david@...hat.com>
To: Rebecca Mckeever <remckee0@...il.com>,
Mike Rapoport <rppt@...nel.org>, linux-mm@...ck.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH v4 2/4] memblock tests: add verbose output to memblock
tests
On 28.06.22 00:34, Rebecca Mckeever wrote:
> Add and use functions and macros for printing verbose testing output.
>
> If the Memblock simulator was compiled with VERBOSE=1:
> - prefix_push(): appends the given string to a prefix string that will be
> printed in test_fail() and test_pass*().
>
> - prefix_pop(): removes the last prefix from the prefix string.
>
> - prefix_reset(): clears the prefix string.
>
> - test_fail(): prints a message after a test fails containing the test
> number of the failing test and the prefix.
>
> - test_pass(): prints a message after a test passes containing its test
> number and the prefix.
>
> - test_print(): prints the given formatted output string.
>
> - test_pass_pop(): runs test_pass() followed by prefix_pop().
>
> - PREFIX_PUSH(): runs prefix_push(__func__).
>
> If the Memblock simulator was not compiled with VERBOSE=1, these
> functions/macros do nothing.
>
> Add the assert wrapper macros ASSERT_EQ(), ASSERT_NE(), and ASSERT_LT().
> If the assert condition fails, these macros call test_fail() before
> executing assert().
>
> Signed-off-by: Rebecca Mckeever <remckee0@...il.com>
[...]
>
> diff --git a/tools/testing/memblock/tests/common.c b/tools/testing/memblock/tests/common.c
> index 62d3191f7c9a..e55b2a8bf0ff 100644
> --- a/tools/testing/memblock/tests/common.c
> +++ b/tools/testing/memblock/tests/common.c
> @@ -4,8 +4,12 @@
>
> #define INIT_MEMBLOCK_REGIONS 128
> #define INIT_MEMBLOCK_RESERVED_REGIONS INIT_MEMBLOCK_REGIONS
> +#define PREFIXES_LEN_MAX 256
> +#define DELIM ": "
> +#define DELIM_LEN strlen(DELIM)
Why not simply
#define PREFIXES_MAX 15
static const char * __maybe_unused prefixes[PREFIXES_MAX];
static int nr_prefixes;
And then simply insert/clear the corresponding prefixes[] pointer and
update nr_prefixes?
When printing, you only have to walk prefixes from 0 ... nr_prefixes - 1
and print the values.
Avoids any string modifications.
Anyhow, this LGTM
Acked-by: David Hildenbrand <david@...hat.com>
--
Thanks,
David / dhildenb
Powered by blists - more mailing lists