diff mbox series

[2/2] tst_test.sh: Warn about setup/cleanup function not loaded

Message ID 20200518130132.19312-2-pvorel@suse.cz
State Changes Requested
Headers show
Series [1/2] tst_test.sh: Fix calling not yet loaded cleanup function | expand

Commit Message

Petr Vorel May 18, 2020, 1:01 p.m. UTC
Inspired by regression fixed by previous commit.

Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
 testcases/lib/tst_test.sh | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

Comments

Joerg Vehlow May 19, 2020, 5:10 a.m. UTC | #1
Hi Petr,

this looks good, just one small typo. And I guess I would raise this to 
TBROK, but that
is just my personal preference :)

Am 18.05.2020 um 15:01 schrieb Petr Vorel:
> +		if type "$TST_CLEANUP" >/dev/null 2>&1; then
> +			$TST_CLEANUP
> +		else
> +			tst_res TWARN "cleanup function set (TST_SETUP='$TST_CLEANUP'), but not found (test bug)"
This should probably be TST_CLEANUP=....


Jörg
Petr Vorel May 19, 2020, 6:43 a.m. UTC | #2
Hi Jörg,

> this looks good, just one small typo. And I guess I would raise this to
> TBROK, but that
> is just my personal preference :)
Yes, it could be. I thought TBROK would be for setup (tests results are probably
invalid without setup) and TWARN for cleanup (well, cleanup is important, but
results are valid, see other TWARN in tst_test.sh). But I want to be consistent
=> use TBROK.

> Am 18.05.2020 um 15:01 schrieb Petr Vorel:
> > +		if type "$TST_CLEANUP" >/dev/null 2>&1; then
> > +			$TST_CLEANUP
> > +		else
> > +			tst_res TWARN "cleanup function set (TST_SETUP='$TST_CLEANUP'), but not found (test bug)"
> This should probably be TST_CLEANUP=....
Thanks!

Kind regards,
Petr
diff mbox series

Patch

diff --git a/testcases/lib/tst_test.sh b/testcases/lib/tst_test.sh
index aa74ad761..cd5bdeae7 100644
--- a/testcases/lib/tst_test.sh
+++ b/testcases/lib/tst_test.sh
@@ -30,7 +30,11 @@  _tst_do_exit()
 
 	if [ -n "$TST_SETUP_STARTED" -a -n "$TST_RUN_STARTED" -a \
 		-n "$TST_CLEANUP" -a -z "$TST_NO_CLEANUP" ]; then
-		$TST_CLEANUP
+		if type "$TST_CLEANUP" >/dev/null 2>&1; then
+			$TST_CLEANUP
+		else
+			tst_res TWARN "cleanup function set (TST_SETUP='$TST_CLEANUP'), but not found (test bug)"
+		fi
 	fi
 
 	if [ "$TST_NEEDS_DEVICE" = 1 -a "$TST_DEVICE_FLAG" = 1 ]; then
@@ -585,6 +589,11 @@  tst_run()
 	if [ -n "$TST_SETUP" ]; then
 		TST_SETUP_STARTED=1
 		$TST_SETUP
+		if type "$TST_SETUP" >/dev/null 2>&1; then
+			$TST_SETUP
+		else
+			tst_res TWARN "setup function set (TST_SETUP='$TST_SETUP'), but not found (test bug)"
+		fi
 	fi
 
 	#TODO check that test reports some results for each test function call