selftests: Fix lib.mk run_tests target shell script
PATCH 1/1 selftests: Fix lib.mk run_tests target shell script
Within run_tests target, the whole script needs to be executed within the same shell and not as separate subshells, so the initial test_num variable set to 0 is still present when executing "test_num=echo $$test_num+1 | bc;".
Demonstration of the issue (make run_tests):
TAP version 13
(standard_in) 1: syntax error
selftests: basic_test
========================================
ok 1.. selftests: basic_test [PASS]
(standard_in) 1: syntax error
selftests: basic_percpu_ops_test
========================================
ok 1.. selftests: basic_percpu_ops_test [PASS]
(standard_in) 1: syntax error
selftests: param_test
========================================
ok 1.. selftests: param_test [PASS]
With fix applied:
TAP version 13
selftests: basic_test
========================================
ok 1..1 selftests: basic_test [PASS]
selftests: basic_percpu_ops_test
========================================
ok 1..2 selftests: basic_percpu_ops_test [PASS]
selftests: param_test
========================================
ok 1..3 selftests: param_test [PASS]
--- tools/testing/selftests/lib.mk | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
tools/testing/selftests/lib.mk +4 -4
@@ -20,10 +20,10 @@ all: $(TEST_GEN_PROGS) $(TEST_GEN_PROGS_EXTENDED) $(TEST_GEN_FILES) .ONESHELL: define RUN_TESTS - @export KSFT_TAP_LEVEL=`echo 1`; - @test_num=`echo 0`; - @echo "TAP version 13"; - @for TEST in $(1); do \ + @export KSFT_TAP_LEVEL=`echo 1`; \ + test_num=`echo 0`; \ + echo "TAP version 13"; \ + for TEST in $(1); do \ BASENAME_TEST=`basename $$TEST`; \ test_num=`echo $$test_num+1 | bc`; \ echo "selftests: $$BASENAME_TEST"; \
Signature · 6 lines
2.11.0 -- To unsubscribe from this list: send the line "unsubscribe linux-kselftest" in the body of a message to majordomo at vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 52 lines · Mathieu Desnoyers
Within
run_teststarget, the whole script needs to be executed within the same shell and not as separate subshells, so the initialtest_numvariable set to 0 is still present when executing "test_num=echo $$test_num+1 | bc;".Demonstration of the issue (make
run_tests):TAP version 13
(standard_in) 1: syntax error
selftests:basic_test
========================================
ok 1.. selftests:basic_test[PASS]
(standard_in) 1: syntax error
selftests:basic_percpu_ops_test
========================================
ok 1.. selftests:basic_percpu_ops_test[PASS]
(standard_in) 1: syntax error
selftests:param_test
========================================
ok 1.. selftests:param_test[PASS]With fix applied:
TAP version 13
selftests:basic_test
========================================
ok 1..1 selftests:basic_test[PASS]
selftests:basic_percpu_ops_test
========================================
ok 1..2 selftests:basic_percpu_ops_test[PASS]
selftests:param_test
========================================
ok 1..3 selftests:param_test[PASS]Signed-off-by Mathieu Desnoyers <mathieu.desnoyers at efficios.com>Fixes 1f87c7c15d7 ("selftests: lib.mk: change RUN_TESTS to print messages in TAP13 format")CC Shuah Khan <shuahkh at osg.samsung.com>CC linux-kselftest at vger.kernel.org--- tools/testing/selftests/lib.mk | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)tools/testing/selftests/lib.mk +0
-1@@ -20,10 +20,10 @@ all: $(TEST_GEN_PROGS) $(TEST_GEN_PROGS_EXTENDED) $(TEST_GEN_FILES) .ONESHELL: define RUN_TESTS - @export KSFT_TAP_LEVEL=`echo 1`;
tools/testing/selftests/lib.mk all: $(TEST_GEN_PROGS) $(TEST_GEN_PROGS_EXTENDED) $(TEST_GEN_FILES) · line 29
Quoted 10 lines
tools/testing/selftests/lib.mk +4
-3- @test_num=`echo 0`; - @echo "TAP version 13"; - @for TEST in $(1); do \ + @export KSFT_TAP_LEVEL=`echo 1`; \ + test_num=`echo 0`; \ + echo "TAP version 13"; \ + for TEST in $(1); do \ BASENAME_TEST=`basename $$TEST`; \ test_num=`echo $$test_num+1 | bc`; \ echo "selftests: $$BASENAME_TEST"; \
Great. Applied to linux-kselftest fixes for 4.17-rc4
thanks,
-- Shuah
--
To unsubscribe from this list: send the line "unsubscribe linux-kselftest" in the body of a message to majordomo at vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html