linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: David Hildenbrand <david@redhat.com>
To: Rebecca Mckeever <remckee0@gmail.com>,
	Mike Rapoport <rppt@kernel.org>,
	linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v4 2/4] memblock tests: add verbose output to memblock tests
Date: Wed, 29 Jun 2022 13:34:54 +0200	[thread overview]
Message-ID: <5db2944e-9d64-8faa-83d3-fd02fce583bd@redhat.com> (raw)
In-Reply-To: <883c28e34527fd4cdc55df97c791ed8b2e79538d.1656368930.git.remckee0@gmail.com>

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@gmail.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@redhat.com>

-- 
Thanks,

David / dhildenb



  parent reply	other threads:[~2022-06-29 11:35 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-27 22:34 [PATCH v4 0/4] memblock tests: add VERBOSE and MEMBLOCK_DEBUG Makefile options Rebecca Mckeever
2022-06-27 22:34 ` [PATCH v4 1/4] memblock tests: Makefile: add arguments to control verbosity Rebecca Mckeever
2022-06-27 22:34 ` [PATCH v4 2/4] memblock tests: add verbose output to memblock tests Rebecca Mckeever
2022-06-28  1:45   ` Huang, Shaoqin
2022-06-29 11:34   ` David Hildenbrand [this message]
2022-06-29 17:07     ` Rebecca Mckeever
2022-06-30 10:17       ` David Hildenbrand
2022-07-01  1:50         ` Rebecca Mckeever
2022-06-27 22:34 ` [PATCH v4 3/4] memblock tests: set memblock_debug to enable memblock_dbg() messages Rebecca Mckeever
2022-06-27 22:34 ` [PATCH v4 4/4] memblock tests: remove completed TODO items Rebecca Mckeever

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=5db2944e-9d64-8faa-83d3-fd02fce583bd@redhat.com \
    --to=david@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=remckee0@gmail.com \
    --cc=rppt@kernel.org \
    /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;
as well as URLs for NNTP newsgroup(s).