[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ffdeb9a9-c066-19c-9898-c2bdf632cef1@linux.intel.com>
Date: Fri, 3 Nov 2023 11:54:59 +0200 (EET)
From: Ilpo Järvinen <ilpo.jarvinen@...ux.intel.com>
To: Reinette Chatre <reinette.chatre@...el.com>
cc: linux-kselftest@...r.kernel.org, Shuah Khan <shuah@...nel.org>,
Shaopeng Tan <tan.shaopeng@...fujitsu.com>,
Maciej Wieczór-Retman
<maciej.wieczor-retman@...el.com>,
Fenghua Yu <fenghua.yu@...el.com>,
LKML <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH 18/24] selftests/resctrl: Introduce generalized test
framework
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.
--
i.
Powered by blists - more mailing lists