All of lore.kernel.org
 help / color / mirror / Atom feed
From: Petr Vorel <pvorel@suse.cz>
To: Wei Gao <wegao@suse.com>
Cc: ltp@lists.linux.it
Subject: Re: [LTP] [PATCH v5 1/3] lib: Add support option for .needs_cmds
Date: Wed, 7 Jan 2026 09:05:45 +0100	[thread overview]
Message-ID: <20260107080545.GC727950@pevik> (raw)
In-Reply-To: <aT-5tkQkM_g2VZ35@autotest-wegao.qe.prg2.suse.org>

> On Fri, Dec 12, 2025 at 12:16:18PM +0100, Petr Vorel wrote:
> > > Hi!
> > > > diff --git a/lib/tst_test.c b/lib/tst_test.c
> > > > index da5314c50..67553f65d 100644
> > > > --- a/lib/tst_test.c
> > > > +++ b/lib/tst_test.c
> > > > @@ -1365,6 +1365,19 @@ static const char *default_fs_type(void)
> > > >  	return tst_dev_fs_type();
> > > >  }

> > > > +bool tst_cmd_present(const char *cmd)
> > > > +{
> > > > +	struct tst_cmd *pcmd = tst_test->needs_cmds;
> > > > +
> > > > +	while (pcmd->cmd) {
> > > > +		if (!strcmp(pcmd->cmd, cmd))
> > > > +			return pcmd->present;
> > > > +
> > > > +		pcmd++;
> > > > +	}
> > > > +	return false;

> > > Once again, we should tst_brk(TBROK, "Unexpected command '%s'", cmd) here since we asked for
> > > something that we haven't checked for!

> > Good point. I'm sorry to overlook this in my review.

> > Also, strictly speaking tst_cmd_present() is only defined, not used. The commit
> > is about changing .needs_cmds from char array (string) to struct tst_cmd.
> > Therefore it could be in a separate commit. We don't have to be too strict, but
> > given how many tests needed to be adapted adding tst_cmd_present() is somehow
> > buried with other changes.

> Thanks all for detail feedback. Let's me give some explaination why skip
> tst_brk in above function:
> tst_cmd_present will be used in latest ioctl_loop01.c and it should not
> use tst_brk otherwise we will brk out of test in setup() too early.
> The new support needs_cmds.optional in current patch is used for support 
> tst_cmd_present scenario in ioctl_loop01.c.
> Correct me if any mistake.

> ioctl_loop01.c code:
> static void setup(void)
> {
>         parted_sup = tst_cmd_present("parted");  <=====

> .....
>         if (parted_sup)
>                 SAFE_CMD(cmd_parted, NULL, NULL);  <===

>         sprintf(partscan_path, "/sys/block/loop%d/loop/partscan", dev_num);
> }

And also:

static struct tst_test test = {
	...
	.needs_cmds = (struct tst_cmd[]) {
		{.cmd = "parted", .optional = 1},
		{}

Therefore IMHO you are wrong.

+	while (pcmd->cmd) {
+		if (!strcmp(pcmd->cmd, cmd))
We always match this for programs which we checked via .needs_cmds (regardless
true or false return).
+			return pcmd->present;
+
+		pcmd++;
+	}

If we get here that means that we ask in tst_cmd_present("...") for program we
did not add .needs_cmds. That's why Cyril asked for tst_brk().
+	return false;

Kind regards,
Petr

> > Kind regards,
> > Petr

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

  parent reply	other threads:[~2026-01-07  8:06 UTC|newest]

Thread overview: 100+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-26  8:50 [LTP] [PATCH v1 0/2] new cmd support option for needs_cmds Wei Gao via ltp
2025-09-26  8:50 ` [LTP] [PATCH v1 1/2] lib: Add support option for .needs_cmds Wei Gao via ltp
2025-09-26  9:31   ` Cyril Hrubis
2025-09-26  8:50 ` [LTP] [PATCH v1 2/2] ioctl_loop01.c: Update to new .needs_cmds struct Wei Gao via ltp
2025-09-26  9:32   ` Cyril Hrubis
2025-09-28 23:26 ` [LTP] [PATCH v1 0/2] new cmd support option for needs_cmds Wei Gao via ltp
2025-09-28 23:26   ` [LTP] [PATCH v2 1/2] lib: Add support option for .needs_cmds Wei Gao via ltp
2025-09-30 13:36     ` Petr Vorel
2025-10-10  6:32       ` Wei Gao via ltp
2025-10-10  6:45     ` [LTP] [PATCH v3 0/4] new cmd support option for needs_cmds Wei Gao via ltp
2025-10-10  6:45       ` [LTP] [PATCH v3 1/4] lib: Add support option for .needs_cmds Wei Gao via ltp
2025-10-10  9:13         ` Petr Vorel
2025-10-10  9:45           ` Petr Vorel
2025-10-10  6:45       ` [LTP] [PATCH v3 2/4] ioctl_loop01.c: Update to new .needs_cmds struct Wei Gao via ltp
2025-10-10  6:45       ` [LTP] [PATCH v3 3/4] Update test cases use new needs_cmds Wei Gao via ltp
2025-10-10  6:45       ` [LTP] [PATCH v3 4/4] tst_run_shell.c: Add new function handle " Wei Gao via ltp
2025-10-17 10:09       ` [LTP] [PATCH v4 0/3] new cmd support option for needs_cmds Wei Gao via ltp
2025-10-17 10:09         ` [LTP] [PATCH v4 1/3] lib: Add support option for .needs_cmds Wei Gao via ltp
2025-10-17 14:35           ` Petr Vorel
2025-10-20  1:22             ` Wei Gao via ltp
2025-10-20 13:21               ` Petr Vorel
2025-10-21  3:42                 ` Wei Gao via ltp
2025-10-22  9:23                 ` Li Wang via ltp
2025-10-22 14:19                   ` Wei Gao via ltp
2025-10-17 15:37           ` Petr Vorel
2025-10-20  1:24             ` Wei Gao via ltp
2025-10-20 13:33           ` Petr Vorel
2025-10-21  3:17             ` Wei Gao via ltp
2025-10-17 10:09         ` [LTP] [PATCH v4 2/3] Update test cases use new needs_cmds Wei Gao via ltp
2025-10-17 10:09         ` [LTP] [PATCH v4 3/3] tst_run_shell.c: Add new function handle " Wei Gao via ltp
2025-10-17 15:30           ` Petr Vorel
2025-10-17 15:41           ` Petr Vorel
2025-10-20  1:41             ` Wei Gao via ltp
2025-11-07  0:30       ` [LTP] [PATCH v4 0/4] new cmd support option for needs_cmds Wei Gao via ltp
2025-11-07  0:30         ` [LTP] [PATCH v4 1/4] tst_cmd.c: Check brk_nosupp when tst_get_path failed Wei Gao via ltp
2025-11-07 10:33           ` Petr Vorel
2025-11-07  0:30         ` [LTP] [PATCH v4 2/4] lib: Add support option for .needs_cmds Wei Gao via ltp
2025-11-07  0:30         ` [LTP] [PATCH v4 3/4] ioctl_loop01.c: Add new support .needs_cmds Wei Gao via ltp
2025-11-07 11:04           ` Petr Vorel
2025-11-08 12:58             ` Wei Gao via ltp
2025-11-07  0:30         ` [LTP] [PATCH v4 4/4] shell_loader_cmd.sh: New test case check needs_cmds Wei Gao via ltp
2025-11-07 11:41           ` Petr Vorel
2025-11-10  2:47         ` [LTP] [PATCH v5 0/3] new cmd support option for needs_cmds Wei Gao via ltp
2025-11-10  2:47           ` [LTP] [PATCH v5 1/3] lib: Add support option for .needs_cmds Wei Gao via ltp
2025-11-11 11:06             ` Petr Vorel
2025-12-12 10:30             ` Cyril Hrubis
2025-12-12 11:16               ` Petr Vorel
2025-12-15  7:33                 ` Wei Gao via ltp
2025-12-15  9:36                   ` Petr Vorel
2025-12-15 10:59                     ` Wei Gao via ltp
2025-12-17 13:18                       ` Petr Vorel
2026-01-07  8:05                   ` Petr Vorel [this message]
2025-11-10  2:47           ` [LTP] [PATCH v5 2/3] ioctl_loop01.c: Add new support .needs_cmds Wei Gao via ltp
2025-11-11 11:14             ` Petr Vorel
2025-11-10  2:47           ` [LTP] [PATCH v5 3/3] shell_loader_cmd.sh: New test case check needs_cmds Wei Gao via ltp
2025-11-11 10:41             ` Wei Gao via ltp
2025-11-11 11:15             ` Petr Vorel
2025-12-23  2:08           ` [LTP] [PATCH v6 0/4] new cmd support option for needs_cmds Wei Gao via ltp
2025-12-23  2:08             ` [LTP] [PATCH v6 1/4] lib: Add support option for .needs_cmds Wei Gao via ltp
2026-01-05 13:48               ` Petr Vorel
2026-01-06 10:01               ` Cyril Hrubis
2025-12-23  2:08             ` [LTP] [PATCH v6 2/4] tst_test.c: Add tst_cmd_present check if a command is present Wei Gao via ltp
2026-01-05 13:52               ` Petr Vorel
2026-01-06 10:02               ` Cyril Hrubis
2026-01-07  6:16                 ` Wei Gao via ltp
2026-01-07  8:09                   ` Petr Vorel
2026-01-07  8:27                     ` Petr Vorel
2026-01-07  9:59                       ` Cyril Hrubis
2026-01-09  6:11                         ` Wei Gao via ltp
2026-01-12 11:05                         ` Petr Vorel
2026-01-07  9:56                   ` Cyril Hrubis
2025-12-23  2:08             ` [LTP] [PATCH v6 3/4] ioctl_loop01.c: Add new support .needs_cmds Wei Gao via ltp
2026-01-05 13:56               ` Petr Vorel
2025-12-23  2:08             ` [LTP] [PATCH v6 4/4] shell_loader_cmd.sh: New test case check needs_cmds Wei Gao via ltp
2026-01-05 13:57               ` Petr Vorel
2026-01-09  6:16             ` [LTP] [PATCH v7 0/4] new cmd support option for needs_cmds Wei Gao via ltp
2026-01-09  6:16               ` [LTP] [PATCH v7 1/4] lib: Add support option for .needs_cmds Wei Gao via ltp
2026-01-09 19:15                 ` Petr Vorel
2026-01-09 19:21                   ` Petr Vorel
2026-01-16 14:03                 ` Li Wang via ltp
2026-01-19 14:51                 ` Cyril Hrubis
2026-01-20  6:42                   ` Petr Vorel
2026-01-09  6:16               ` [LTP] [PATCH v7 2/4] tst_test.c: Add tst_cmd_present check if a command is present Wei Gao via ltp
2026-01-09 19:17                 ` Petr Vorel
2026-01-12 11:08                   ` Petr Vorel
2026-01-16 13:58                 ` Li Wang via ltp
2026-01-19 13:17                 ` Cyril Hrubis
2026-01-09  6:16               ` [LTP] [PATCH v7 3/4] ioctl_loop01.c: Add new support .needs_cmds Wei Gao via ltp
2026-01-16 13:25                 ` Li Wang via ltp
2026-01-17 13:16                   ` Wei Gao via ltp
2026-01-19  3:00                     ` Li Wang via ltp
2026-01-19  5:34                       ` Wei Gao via ltp
2026-01-19  6:27                         ` Li Wang via ltp
2026-01-19 14:57                 ` Cyril Hrubis
2026-01-21 13:08                 ` Cyril Hrubis
2026-01-09  6:16               ` [LTP] [PATCH v7 4/4] shell_loader_cmd.sh: New test case check needs_cmds Wei Gao via ltp
2026-01-21 13:09                 ` Cyril Hrubis
2026-01-21 13:11                   ` Petr Vorel
2025-09-28 23:26   ` [LTP] [PATCH v2 2/2] ioctl_loop01.c: Update to new .needs_cmds struct Wei Gao via ltp
2025-09-30 13:12     ` Petr Vorel

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=20260107080545.GC727950@pevik \
    --to=pvorel@suse.cz \
    --cc=ltp@lists.linux.it \
    --cc=wegao@suse.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.