Hi Ilpo, On 11/3/2023 2:54 AM, Ilpo Järvinen wrote: > On Thu, 2 Nov 2023, Reinette Chatre wrote: >> On 10/24/2023 2:26 AM, Ilpo Järvinen wrote: >> ... >>> diff --git a/tools/testing/selftests/resctrl/resctrl.h b/tools/testing/selftests/resctrl/resctrl.h >>> index ec6efd36f60a..e017adf1390d 100644 >> >>> @@ -233,25 +183,26 @@ int main(int argc, char **argv) >>> case 't': >>> token = strtok(optarg, ","); >>> >>> - mbm_test = false; >>> - mba_test = false; >>> - cmt_test = false; >>> - cat_test = false; >>> + if (!test_param_seen) { >>> + for (i = 0; i < ARRAY_SIZE(resctrl_tests); i++) >>> + resctrl_tests[i]->disabled = true; >>> + tests = 0; >>> + test_param_seen = true; >>> + } >>> while (token) { >>> - if (!strncmp(token, MBM_STR, sizeof(MBM_STR))) { >>> - mbm_test = true; >>> - tests++; >>> - } else if (!strncmp(token, MBA_STR, sizeof(MBA_STR))) { >>> - mba_test = true; >>> - tests++; >>> - } else if (!strncmp(token, CMT_STR, sizeof(CMT_STR))) { >>> - cmt_test = true; >>> - tests++; >>> - } else if (!strncmp(token, CAT_STR, sizeof(CAT_STR))) { >>> - cat_test = true; >>> - tests++; >>> - } else { >>> - printf("invalid argument\n"); >>> + bool found = false; >>> + >>> + for (i = 0; i < ARRAY_SIZE(resctrl_tests); i++) { >>> + if (!strcasecmp(token, resctrl_tests[i]->name)) { >>> + if (resctrl_tests[i]->disabled) >>> + tests++; >>> + resctrl_tests[i]->disabled = false; >>> + found = true; >>> + } >>> + } >> >> Could providing multiple "-t" result in the test count not >> matching the number of tests run? > > bool test_param_seen covers the case with more than one -t parameter. > Because of it, the code above resets tests and ->disabled only when the > first -t is encountered. tests++ is only done when ->disabled is set from > true to false. > > I don't see how they could get out of sync but if you had a more specific > case in mind, just let me know. > Thank you for your detailed explanation. I can now see how this is safeguarded. Reinette