[LTP] [PATCH 1/8] tst_test.c: Fix tst_check_cmd() use

Avinesh Kumar akumar@suse.de
Fri Nov 14 09:49:43 CET 2025


On Friday, November 7, 2025 11:29:32 AM CET Petr Vorel wrote:
> 9bb94efa39 changed tst_check_cmd() from int to bool. But it reverted the
> values (0 became true), which logical (false means not supported) than
nit:
I feel it should say:
which is more logical

> the original return codes from 257394e4e3. But then the only use of
> tst_check_cmd() needs to update to expect false instead of true.
> 
> Also document the return code in tst_private.h.
> 
> Fixes: 9bb94efa39 ("tst_cmd: Change tst_check_cmd() return type to int")
> Signed-off-by: Petr Vorel <pvorel@suse.cz>
> ---
> Fixing my own error.
> 
>  include/tst_private.h | 5 +++++
>  lib/tst_test.c        | 2 +-
>  2 files changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/include/tst_private.h b/include/tst_private.h
> index 87ec8829a1..482b68fba2 100644
> --- a/include/tst_private.h
> +++ b/include/tst_private.h
> @@ -1,5 +1,6 @@
>  // SPDX-License-Identifier: GPL-2.0-or-later
>  /*
> + * Copyright (c) Linux Test Project, 2020-2025
>   * Copyright (c) 2017-2019 Petr Vorel <pvorel@suse.cz>
>   *
>   * Internal helper functions for the shell library. Do not use directly
> @@ -41,9 +42,13 @@ char tst_kconfig_get(const char *confname);
>  /*
>   * If cmd argument is a single command, this function just checks command
>   * whether exists. If not, case breaks if brk_nosupp is defined.
> + *
>   * If cmd argument is a complex string ie 'mkfs.ext4 >= 1.43.0', this
>   * function checks command version whether meets this requirement.
>   * If not, case breaks if brk_nosupp is defined.
> + *
> + * return: true if command presented, optionally with high enough version, false
s/command presented/command is present
> + * otherwise.
>   */
>  bool tst_check_cmd(const char *cmd, const int brk_nosupp);
>  
> diff --git a/lib/tst_test.c b/lib/tst_test.c
> index da5314c502..bda66c4672 100644
> --- a/lib/tst_test.c
> +++ b/lib/tst_test.c
> @@ -1960,7 +1960,7 @@ static int run_tcase_on_fs(struct tst_fs *fs, const char *fs_type)
>  	tst_res(TINFO, "=== Testing on %s ===", fs_type);
>  	tdev.fs_type = fs_type;
>  
> -	if (fs->mkfs_ver && tst_check_cmd(fs->mkfs_ver, 0))
> +	if (fs->mkfs_ver && !tst_check_cmd(fs->mkfs_ver, 0))
>  		return TCONF;
>  
>  	if (fs->min_kver && check_kver(fs->min_kver, 0))
> 






More information about the ltp mailing list