From 7ca6be805c9fa4083b7e4de7f28162fca6a4a090 Mon Sep 17 00:00:00 2001 From: Cyril Hrubis Date: Wed, 12 Oct 2016 11:55:29 +0200 Subject: [PATCH] tst_test.sh: Add sanity checks Given that when the test is executed the path to the LTP test is in PATH and that the filename of the script is in $0 we can as well grep the test source to look for common mistakes on runtime. This just adds a check if the test calls tst_run function, but the possibilities are much greater. Signed-off-by: Cyril Hrubis --- testcases/lib/tst_test.sh | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/testcases/lib/tst_test.sh b/testcases/lib/tst_test.sh index e24d5346ab5..5da7eee4c29 100644 --- a/testcases/lib/tst_test.sh +++ b/testcases/lib/tst_test.sh @@ -400,3 +400,9 @@ tst_run() tst_do_exit } + +if TST_TEST_PATH=$(which $0) 2>/dev/null; then + if ! grep -q tst_run "$TST_TEST_PATH"; then + tst_brk TBROK "Test $0 must call tst_run!" + fi +fi