diff mbox series

[v4,3/3] tst_test.sh: Exit when setup declared but not defined

Message ID 20201217144424.19414-4-pvorel@suse.cz
State Accepted
Headers show
Series shell API setup/cleanup checks | expand

Commit Message

Petr Vorel Dec. 17, 2020, 2:44 p.m. UTC
It can lead to fail positive when just warn about
TST_SETUP declared but not defined (or cmd not found).

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

Comments

Cyril Hrubis Jan. 7, 2021, 10:07 a.m. UTC | #1
Hi!
Looks good, Reviewed-by: Cyril Hrubis <chrubis@suse.cz>
diff mbox series

Patch

diff --git a/testcases/lib/tst_test.sh b/testcases/lib/tst_test.sh
index dbf1d2a97..1b05c1036 100644
--- a/testcases/lib/tst_test.sh
+++ b/testcases/lib/tst_test.sh
@@ -586,7 +586,11 @@  tst_run()
 	[ -n "$TST_NEEDS_MODULE" ] && tst_require_module "$TST_NEEDS_MODULE"
 
 	if [ -n "$TST_SETUP" ]; then
-		$TST_SETUP
+		if type $TST_SETUP >/dev/null 2>/dev/null; then
+			$TST_SETUP
+		else
+			tst_brk TBROK "TST_SETUP=$TST_SETUP declared, but function not defined (or cmd not found)"
+		fi
 	fi
 
 	#TODO check that test reports some results for each test function call