[PATCH v5 5/6] kselftest/arm64/mte: refactor check_mmap_option test

Yeoreum Yun yeoreum.yun at arm.com
Wed Jun 11 02:34:49 PDT 2025


Hi Mark,

>
> > 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?

Thank. I'll changed to enum.

>
> > +{
> > +	static char test_name[TEST_NAME_MAX];
> > +	const char* check_type_str;
>
> Coding style would usually be
>
> 	const char *check_type_str;
>

Sorry for my typo... :(

> > +	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).

Okay.

>
> >  	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.

I see, I'll repsin and send it again.

Thanks!

--
Sincerely,
Yeoreum Yun



More information about the linux-arm-kernel mailing list