From: Mike Rapoport <rppt@kernel.org>
To: Rebecca Mckeever <remckee0@gmail.com>
Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org,
David Hildenbrand <david@redhat.com>
Subject: Re: [PATCH v3 2/4] memblock tests: add verbose output to memblock tests
Date: Wed, 22 Jun 2022 23:30:10 -0500 [thread overview]
Message-ID: <YrPsUrJ5R5UaIGBS@kernel.org> (raw)
In-Reply-To: <004e021cc3cb7be8749361b3b1cb324459b9cb9f.1655889641.git.remckee0@gmail.com>
On Wed, Jun 22, 2022 at 04:29:07AM -0500, Rebecca Mckeever wrote:
> Add and use functions 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 the test functions.
> 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.
>
> If the Memblock simulator was not compiled with VERBOSE=1, these
> functions 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>
> ---
> tools/testing/memblock/tests/alloc_api.c | 241 ++++++++----
> .../memblock/tests/alloc_helpers_api.c | 135 +++++--
> tools/testing/memblock/tests/alloc_nid_api.c | 371 ++++++++++++------
> tools/testing/memblock/tests/basic_api.c | 365 ++++++++++++-----
> tools/testing/memblock/tests/common.c | 58 +++
> tools/testing/memblock/tests/common.h | 54 +++
> 6 files changed, 880 insertions(+), 344 deletions(-)
>
> diff --git a/tools/testing/memblock/tests/alloc_api.c b/tools/testing/memblock/tests/alloc_api.c
> index d1aa7e15c18d..96df033d4300 100644
> --- a/tools/testing/memblock/tests/alloc_api.c
> +++ b/tools/testing/memblock/tests/alloc_api.c
...
> @@ -729,6 +820,12 @@ static int alloc_no_memory_check(void)
>
> int memblock_alloc_checks(void)
> {
> + static const char func_testing[] = "memblock_alloc";
> +
> + prefix_reset();
> + prefix_push(func_testing);
> + test_print("Running %s tests...\n", func_testing);
Why not
test_print("Running memblock_alloc tests...\n");
?
(applies to other cases below)
> +
> reset_memblock_attributes();
> dummy_physical_memory_init();
...
> diff --git a/tools/testing/memblock/tests/alloc_helpers_api.c b/tools/testing/memblock/tests/alloc_helpers_api.c
> index 963a966db461..f6eaed540427 100644
> --- a/tools/testing/memblock/tests/alloc_helpers_api.c
> +++ b/tools/testing/memblock/tests/alloc_helpers_api.c
...
> @@ -378,6 +423,12 @@ static int alloc_from_min_addr_cap_check(void)
>
> int memblock_alloc_helpers_checks(void)
> {
> + static const char func_testing[] = "memblock_alloc_from";
> +
> + prefix_reset();
> + prefix_push(func_testing);
> + test_print("Running %s tests...\n", func_testing);
> +
> reset_memblock_attributes();
> dummy_physical_memory_init();
>
> diff --git a/tools/testing/memblock/tests/alloc_nid_api.c b/tools/testing/memblock/tests/alloc_nid_api.c
> index 6390206e50e1..601f4a7ee30d 100644
> --- a/tools/testing/memblock/tests/alloc_nid_api.c
> +++ b/tools/testing/memblock/tests/alloc_nid_api.c
...
> @@ -1150,6 +1263,12 @@ static int alloc_try_nid_low_max_check(void)
>
> int memblock_alloc_nid_checks(void)
> {
> + static const char func_testing[] = "memblock_alloc_try_nid";
> +
> + prefix_reset();
> + prefix_push(func_testing);
> + test_print("Running %s tests...\n", func_testing);
> +
> reset_memblock_attributes();
> dummy_physical_memory_init();
>
> @@ -1170,5 +1289,7 @@ int memblock_alloc_nid_checks(void)
>
> dummy_physical_memory_cleanup();
>
> + prefix_pop();
> +
> return 0;
> }
> diff --git a/tools/testing/memblock/tests/basic_api.c b/tools/testing/memblock/tests/basic_api.c
> index a7bc180316d6..f223a9a57be7 100644
> --- a/tools/testing/memblock/tests/basic_api.c
> +++ b/tools/testing/memblock/tests/basic_api.c
> @@ -4,21 +4,30 @@
> #include "basic_api.h"
>
> #define EXPECTED_MEMBLOCK_REGIONS 128
> +#define FUNC_ADD "memblock_add"
> +#define FUNC_RESERVE "memblock_reserve"
> +#define FUNC_REMOVE "memblock_remove"
> +#define FUNC_FREE "memblock_free"
>
> static int memblock_initialization_check(void)
> {
> - assert(memblock.memory.regions);
> - assert(memblock.memory.cnt == 1);
> - assert(memblock.memory.max == EXPECTED_MEMBLOCK_REGIONS);
> - assert(strcmp(memblock.memory.name, "memory") == 0);
> + prefix_push(__func__);
>
> - assert(memblock.reserved.regions);
> - assert(memblock.reserved.cnt == 1);
> - assert(memblock.memory.max == EXPECTED_MEMBLOCK_REGIONS);
> - assert(strcmp(memblock.reserved.name, "reserved") == 0);
> + ASSERT_NE(memblock.memory.regions, NULL);
> + ASSERT_EQ(memblock.memory.cnt, 1);
> + ASSERT_EQ(memblock.memory.max, EXPECTED_MEMBLOCK_REGIONS);
> + ASSERT_EQ(strcmp(memblock.memory.name, "memory"), 0);
>
> - assert(!memblock.bottom_up);
> - assert(memblock.current_limit == MEMBLOCK_ALLOC_ANYWHERE);
> + ASSERT_NE(memblock.reserved.regions, NULL);
> + ASSERT_EQ(memblock.reserved.cnt, 1);
> + ASSERT_EQ(memblock.memory.max, EXPECTED_MEMBLOCK_REGIONS);
> + ASSERT_EQ(strcmp(memblock.reserved.name, "reserved"), 0);
> +
> + ASSERT_EQ(memblock.bottom_up, false);
> + ASSERT_EQ(memblock.current_limit, MEMBLOCK_ALLOC_ANYWHERE);
> +
> + test_pass();
> + prefix_pop();
>
> return 0;
> }
> @@ -40,14 +49,19 @@ static int memblock_add_simple_check(void)
> .size = SZ_4M
> };
>
> + prefix_push(__func__);
> +
> reset_memblock_regions();
> memblock_add(r.base, r.size);
>
> - assert(rgn->base == r.base);
> - assert(rgn->size == r.size);
> + ASSERT_EQ(rgn->base, r.base);
> + ASSERT_EQ(rgn->size, r.size);
> +
> + ASSERT_EQ(memblock.memory.cnt, 1);
> + ASSERT_EQ(memblock.memory.total_size, r.size);
>
> - assert(memblock.memory.cnt == 1);
> - assert(memblock.memory.total_size == r.size);
> + test_pass();
> + prefix_pop();
>
> return 0;
> }
> @@ -69,18 +83,27 @@ static int memblock_add_node_simple_check(void)
> .size = SZ_16M
> };
>
> + prefix_pop();
> + prefix_push("memblock_add_node");
> + prefix_push(__func__);
I think there is no need to change the prefix from memblock_add to
memblock_add_node here.
ok 3 : memblock_add: memblock_add_node_simple_check: passed
provides enough information.
> +
> reset_memblock_regions();
> memblock_add_node(r.base, r.size, 1, MEMBLOCK_HOTPLUG);
>
> - assert(rgn->base == r.base);
> - assert(rgn->size == r.size);
> + ASSERT_EQ(rgn->base, r.base);
> + ASSERT_EQ(rgn->size, r.size);
> #ifdef CONFIG_NUMA
> - assert(rgn->nid == 1);
> + ASSERT_EQ(rgn->nid, 1);
> #endif
> - assert(rgn->flags == MEMBLOCK_HOTPLUG);
> + ASSERT_EQ(rgn->flags, MEMBLOCK_HOTPLUG);
> +
> + ASSERT_EQ(memblock.memory.cnt, 1);
> + ASSERT_EQ(memblock.memory.total_size, r.size);
>
> - assert(memblock.memory.cnt == 1);
> - assert(memblock.memory.total_size == r.size);
> + test_pass();
> + prefix_pop();
> + prefix_pop();
> + prefix_push(FUNC_ADD);
>
> return 0;
> }
--
Sincerely yours,
Mike.
next prev parent reply other threads:[~2022-06-23 4:30 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-22 9:29 [PATCH v3 0/4] memblock tests: add VERBOSE and MEMBLOCK_DEBUG Makefile options Rebecca Mckeever
2022-06-22 9:29 ` [PATCH v3 1/4] memblock tests: add user-provided arguments to Makefile Rebecca Mckeever
2022-06-23 3:47 ` Mike Rapoport
2022-06-23 4:45 ` Rebecca Mckeever
2022-06-23 4:52 ` Mike Rapoport
2022-06-22 9:29 ` [PATCH v3 2/4] memblock tests: add verbose output to memblock tests Rebecca Mckeever
2022-06-22 10:32 ` Huang, Shaoqin
2022-06-23 0:45 ` Rebecca Mckeever
2022-06-23 1:29 ` Huang, Shaoqin
2022-06-23 3:10 ` Rebecca Mckeever
2022-06-23 4:05 ` Mike Rapoport
2022-06-23 4:56 ` Rebecca Mckeever
2022-06-23 5:04 ` Mike Rapoport
2022-06-23 7:57 ` Rebecca Mckeever
2022-06-23 13:11 ` Mike Rapoport
2022-06-23 3:37 ` Ira Weiny
2022-06-23 7:25 ` Rebecca Mckeever
2022-06-23 4:30 ` Mike Rapoport [this message]
2022-06-23 6:30 ` Rebecca Mckeever
2022-06-23 14:40 ` Mike Rapoport
2022-06-24 7:18 ` Rebecca Mckeever
2022-06-22 9:29 ` [PATCH v3 4/4] memblock tests: remove completed TODO items Rebecca Mckeever
2022-06-22 10:00 ` [PATCH v3 0/4] memblock tests: add VERBOSE and MEMBLOCK_DEBUG Makefile options David Hildenbrand
2022-06-22 14:17 ` Mike Rapoport
2022-06-23 1:01 ` Rebecca Mckeever
2022-06-23 3:30 ` Ira Weiny
2022-06-23 4:20 ` Rebecca Mckeever
2022-06-23 4:38 ` Mike Rapoport
2022-06-23 5:48 ` Ira Weiny
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=YrPsUrJ5R5UaIGBS@kernel.org \
--to=rppt@kernel.org \
--cc=david@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=remckee0@gmail.com \
/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).