LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH 4.17-rc2] selftests: Fix lib.mk run_tests target shell script
@ 2018-04-27 21:55 Mathieu Desnoyers
  2018-04-27 22:13 ` Shuah Khan
  0 siblings, 1 reply; 2+ messages in thread
From: Mathieu Desnoyers @ 2018-04-27 21:55 UTC (permalink / raw)
  To: Shuah Khan; +Cc: linux-kernel, Mathieu Desnoyers, linux-kselftest

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]

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Fixes: 1f87c7c15d7 ("selftests: lib.mk: change RUN_TESTS to print messages in TAP13 format")
CC: Shuah Khan <shuahkh@osg.samsung.com>
CC: linux-kselftest@vger.kernel.org
---
 tools/testing/selftests/lib.mk | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/tools/testing/selftests/lib.mk b/tools/testing/selftests/lib.mk
index 195e9d4739a9..c1b1a4dc6a96 100644
--- a/tools/testing/selftests/lib.mk
+++ b/tools/testing/selftests/lib.mk
@@ -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";	\
-- 
2.11.0


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH 4.17-rc2] selftests: Fix lib.mk run_tests target shell script
  2018-04-27 21:55 [PATCH 4.17-rc2] selftests: Fix lib.mk run_tests target shell script Mathieu Desnoyers
@ 2018-04-27 22:13 ` Shuah Khan
  0 siblings, 0 replies; 2+ messages in thread
From: Shuah Khan @ 2018-04-27 22:13 UTC (permalink / raw)
  To: Mathieu Desnoyers; +Cc: linux-kernel, linux-kselftest, Shuah Khan

On 04/27/2018 03:55 PM, Mathieu Desnoyers wrote:
> 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]
> 
> Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
> Fixes: 1f87c7c15d7 ("selftests: lib.mk: change RUN_TESTS to print messages in TAP13 format")
> CC: Shuah Khan <shuahkh@osg.samsung.com>
> CC: linux-kselftest@vger.kernel.org
> ---
>  tools/testing/selftests/lib.mk | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/tools/testing/selftests/lib.mk b/tools/testing/selftests/lib.mk
> index 195e9d4739a9..c1b1a4dc6a96 100644
> --- a/tools/testing/selftests/lib.mk
> +++ b/tools/testing/selftests/lib.mk
> @@ -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";	\
> 

Great. Applied to linux-kselftest fixes for 4.17-rc4

thanks,
-- Shuah

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-04-27 22:13 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-04-27 21:55 [PATCH 4.17-rc2] selftests: Fix lib.mk run_tests target shell script Mathieu Desnoyers
2018-04-27 22:13 ` Shuah Khan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).