[LTP] [PATCH v7 2/4] tst_test.c: Add tst_cmd_present check if a command is present

Petr Vorel pvorel@suse.cz
Fri Jan 9 20:17:04 CET 2026


Hi Wei,

...
> +++ b/lib/tst_test.c
> @@ -1375,6 +1375,24 @@ 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;
> +
> +	if (!cmd || cmd[0] == '\0')
> +		tst_brk(TBROK, "Invalid cmd");
I'd still prefer tst_brk_() as I described at v6, but that can be done as a
separate change. I keep my RBT :).

Kind regards,
Petr

> +
> +	while (pcmd->cmd) {
> +		if (!strcmp(pcmd->cmd, cmd))
> +			return pcmd->present;
> +
> +		pcmd++;
> +	}
> +
> +	tst_brk(TBROK, "'%s' not checked", cmd);
> +	return false;
> +}
> +
>  static void do_setup(int argc, char *argv[])
>  {
>  	char *tdebug_env = getenv("LTP_ENABLE_DEBUG");


More information about the ltp mailing list