[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <69778d2c-3ace-4fbe-a55f-297e280f8761@sirena.org.uk>
Date: Tue, 10 Jun 2025 16:38:25 +0100
From: Mark Brown <broonie@...nel.org>
To: Yeoreum Yun <yeoreum.yun@....com>
Cc: catalin.marinas@....com, pcc@...gle.com, will@...nel.org,
anshuman.khandual@....com, joey.gouly@....com,
yury.khrustalev@....com, maz@...nel.org, oliver.upton@...ux.dev,
frederic@...nel.org, shmeerali.kolothum.thodi@...wei.com,
akpm@...ux-foundation.org, surenb@...gle.com,
linux-arm-kernel@...ts.infradead.org, linux-kernel@...r.kernel.org,
linux-doc@...r.kernel.org
Subject: Re: [PATCH v5 5/6] kselftest/arm64/mte: refactor check_mmap_option
test
On Tue, Jun 10, 2025 at 04:01:43PM +0100, Yeoreum Yun wrote:
> Before add mtefar testcase on check_mmap_option.c,
> refactor check_mmap_option.
Please describe the intended refactoring here.
> +#define CHECK_ANON_MEM 0
> +#define CHECK_FILE_MEM 1
> +#define CHECK_CLEAR_PROT_MTE 2
> +
Perhaps use enums for this sort of thing?
> +{
> + static char test_name[TEST_NAME_MAX];
> + const char* check_type_str;
Coding style would usually be
const char *check_type_str;
> + snprintf(test_name, TEST_NAME_MAX,
> + "Check %s with %s mapping, %s mode, %s memory and %s\n",
> + check_type_str, mapping_str, sync_str, mem_type_str, tag_check_str);
sizeof(test_name).
> evaluate_test(check_anonymous_memory_mapping(USE_MMAP, MTE_SYNC_ERR, MAP_PRIVATE, TAG_CHECK_OFF),
> - "Check anonymous memory with private mapping, sync error mode, mmap memory and tag check off\n");
> + format_test_name(CHECK_ANON_MEM, USE_MMAP, MTE_SYNC_ERR, MAP_PRIVATE, TAG_CHECK_OFF));
Looking at this I can't help but think that the more common pattern for
test programs where we have an array of test parameters that we loop
through might make sense:
for (i = 0; i < ARRAY_SIZE(test_cases); i++) {
format_test_name(test_cases[i]);
switch (test_cases[i].test_type) {
case CHECK_ANON_MEM:
check_anonymous_memory_mapping(USE_MMAP, ...);
That seems a bit more legible and maintainable.
> mte_disable_pstate_tco();
The management of this could be added as a parameter in the test struct.
Download attachment "signature.asc" of type "application/pgp-signature" (489 bytes)
Powered by blists - more mailing lists