Re: [PATCH v1] cyclictest: Generate optstring dynamically from long_options

Crystal Wood
2026-01-13T23:41:50Z

On Tue, 2026-01-13 at 12:14 +0100, Sebastian Andrzej Siewior wrote:
> On 2026-01-13 12:00:29 [+0200], Costa Shulyupin wrote:
> > On Tue, 13 Jan 2026 at 10:13, Sebastian Andrzej Siewior
> > <bigeasy@linutronix.de> wrote:
> > > GNU ARGP might be easier to parse and maintain in the long run
> > > especially if 20 other options are added.
> > > https://www.gnu.org/software/libc/manual/html_node/Argp-Example-4.html
> >
> > It looks impossible to port to ARGP without CLI change: cyclictest has
> > options with optional arguments (e.g., -a can mean 'use all CPUs' or
> > -a 0,2,4 means 'use specific CPUs'). ARGP handles these differently
> > than getopt_long.
>
> I see. It looked nice and I assumed it supports the same features. But
> if optional arguments to options are not supported then it is probably
> not doable.

It does support optional arguments (OPTION_ARG_OPTIONAL) but
rtla/cyclictest use nonstandard syntax: "-a foo" rather than "-afoo" or
"--arg=foo". We get away with this because there's no mixing of
argument and non-argument options to create ambiguity, and it's not
worth changing at this point.

-Crystal