[LTP] [PATCH v2 2/2] tst_test.sh: Convert only TBROK/TCONF to TWARN in cleanup

Andrea Cervesato andrea.cervesato@suse.com
Thu Dec 18 13:43:41 CET 2025


Hi!

On Tue Feb 11, 2025 at 9:57 PM CET, Petr Vorel wrote:
> Second attempt to convert only TBROK/TCONF to TWARN in cleanup().
>
> Also print original message to help find function call with wrong
> parameter.
>
> Fixes: 55bfa08e17 ("tst_test.sh/tst_brk(): Convert only TBROK to TWARN in cleanup")
> Signed-off-by: Petr Vorel <pvorel@suse.cz>
> ---
> New in v2.
>
>  testcases/lib/tst_test.sh | 14 ++++++++++----
>  1 file changed, 10 insertions(+), 4 deletions(-)
>
> diff --git a/testcases/lib/tst_test.sh b/testcases/lib/tst_test.sh
> index 5a6e34473f..0747f7aaf4 100644
> --- a/testcases/lib/tst_test.sh
> +++ b/testcases/lib/tst_test.sh
> @@ -126,11 +126,17 @@ tst_brk()
>  	local res=$1
>  	shift
>  
> -	if [ "$res" != TBROK -a "$res" != TCONF ]; then
> -		tst_res TBROK "tst_brk can be called only with TBROK or TCONF ($res)"
> -	elif [ "$TST_TBROK_TO_TWARN" = 1 ]; then
> -		tst_res TWARN "$@"
> +	if [ "$TST_TBROK_TO_TWARN" = 1 ]; then
> +		if [ "$res" != TBROK -a "$res" != TCONF ]; then
> +			tst_res TWARN "tst_brk can be called only with TBROK or TCONF ($res, msg: '$@')"
> +		else
> +			tst_res TWARN "$@"
> +		fi
>  		return
> +	fi
> +
> +	if [ "$res" != TBROK -a "$res" != TCONF ]; then
> +		tst_res TBROK "tst_brk can be called only with TBROK or TCONF ($res, msg: '$@')"
>  	else
>  		tst_res "$res" "$@"
>  	fi

Here there's a bit of code duplication. For instance, we can save the
message inside a variable, as well as the T-flag, the use it accordingly
to TST_TBROK_TO_TWARN.


-- 
Andrea Cervesato
SUSE QE Automation Engineer Linux
andrea.cervesato@suse.com



More information about the ltp mailing list