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

Cyril Hrubis chrubis@suse.cz
Tue Jan 6 11:02:20 CET 2026


Hi!
>  /*
>   * Validates exit status of child processes
>   */
> diff --git a/lib/tst_test.c b/lib/tst_test.c
> index 42a54621e..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;

For a third time, when we get here we asked for something that haven't
been tested for so we should tst_brk() here!

> +}
> +
>  static void do_setup(int argc, char *argv[])
>  {
>  	char *tdebug_env = getenv("LTP_ENABLE_DEBUG");
> -- 
> 2.52.0
> 

-- 
Cyril Hrubis
chrubis@suse.cz


More information about the ltp mailing list