From: Avinesh Kumar <akumar@suse.de>
To: Cyril Hrubis <chrubis@suse.cz>
Cc: ltp@lists.linux.it
Subject: Re: [LTP] [PATCH] Add tst_get_max_clocks() routine based on tst_kconfig_check()
Date: Fri, 05 Sep 2025 16:58:46 +0200 [thread overview]
Message-ID: <6198941.lOV4Wx5bFT@thinkpad> (raw)
In-Reply-To: <aLrFpxYykjYbDUAO@yuki.lan>
On Friday, September 5, 2025 1:12:39 PM CEST Cyril Hrubis wrote:
> Hi!
> > +int tst_get_max_clocks(void)
> > +{
> > + static const char * const kconf_aux[] = {"CONFIG_POSIX_AUX_CLOCKS=y", NULL};
> > +
> > + if (!tst_kconfig_check(kconf_aux))
> > + return MAX_CLOCKS + MAX_AUX_CLOCKS;
> > + else
> > + return MAX_CLOCKS;
> > +}
> > diff --git a/testcases/kernel/syscalls/clock_adjtime/clock_adjtime02.c b/testcases/kernel/syscalls/clock_adjtime/clock_adjtime02.c
> > index 0c5e6ac21..ba62bf716 100644
> > --- a/testcases/kernel/syscalls/clock_adjtime/clock_adjtime02.c
> > +++ b/testcases/kernel/syscalls/clock_adjtime/clock_adjtime02.c
> > @@ -76,11 +76,11 @@ struct test_case {
> >
> > struct test_case tc[] = {
> > {
> > - .clktype = TST_MAX_CLOCKS,
> > + .clktype = 0,
> > .exp_err = EINVAL,
> > },
> > {
> > - .clktype = TST_MAX_CLOCKS + 1,
> > + .clktype = 0,
> > .exp_err = EINVAL,
> > },
> > {
> > @@ -223,6 +223,9 @@ static void setup(void)
> > tc[i].lowlimit /= hz;
> > }
> > }
> > +
> > + tc[0].clktype = tst_get_max_clocks();
> > + tc[1].clktype = tst_get_max_clocks() + 1;
>
> We usually frown upon hardcoded array indexes. There are couple of ways
> how to avoid that. The easiest is probably to store a pointers to clock
> types instead of the values in the test_case structure. Have a look at
> how we pass the fd in accept01.c for an example.
>
>
Hi Cyril,
Thank you for suggesting the right approach. I have sent v2.
Regards,
Avinesh
--
Mailing list info: https://lists.linux.it/listinfo/ltp
prev parent reply other threads:[~2025-09-05 14:59 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-05 8:46 [LTP] [PATCH] Add tst_get_max_clocks() routine based on tst_kconfig_check() Avinesh Kumar
2025-09-05 11:12 ` Cyril Hrubis
2025-09-05 14:58 ` Avinesh Kumar [this message]
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=6198941.lOV4Wx5bFT@thinkpad \
--to=akumar@suse.de \
--cc=chrubis@suse.cz \
--cc=ltp@lists.linux.it \
/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