Skip to contentSkip to conversation

selftests/bpf: exit with error code if test failed

PATCH In review Hangbin Liu 3 participants 4 messages Mar 17, 2022 – Mar 21, 2022

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 selftests/bpf: exit with error code if test failed

The test_lirc_mode2.sh test exit with 0 even test failed. Fix it by exiting with an error code.

Fixes 6bdd533cee9a ("bpf: add selftest for lirc_mode2 type program")
---
 tools/testing/selftests/bpf/test_lirc_mode2.sh | 2 ++
 1 file changed, 2 insertions(+)
tools/testing/selftests/bpf/test_lirc_mode2.sh +2 -0
index ec4e15948e40..420dc86362f5 100755
@@ -36,3 +36,5 @@ then
 		echo -e ${GREEN}"PASS: $TYPE"${NC}
 	fi
 fi
+
+exit $ret
Signature · 1 line
2.35.1
maintainer
#1 lore raw
Quoted 14 lines · Hangbin Liu

The test_lirc_mode2.sh test exit with 0 even test failed. Fix it by exiting with an error code.

Fixes 6bdd533cee9a ("bpf: add selftest for lirc_mode2 type program")
---
  tools/testing/selftests/bpf/test_lirc_mode2.sh | 2 ++
  1 file changed, 2 insertions(+)
tools/testing/selftests/bpf/test_lirc_mode2.sh +0 -0
index ec4e15948e40..420dc86362f5 100755

tools/testing/selftests/bpf/test_lirc_mode2.sh then · line 40

Quoted 5 lines
tools/testing/selftests/bpf/test_lirc_mode2.sh +2 -0
@@ -36,3 +36,5 @@ then
  		echo -e ${GREEN}"PASS: $TYPE"${NC}
  	fi
  fi
+
+exit $ret

nit: Shouldn't this also exit with error if no test_lirc_mode2_user was run?

#2 lore raw

PATCH v2 1/1 selftests/bpf/test_lirc_mode2.sh: exit with proper code

In reply to Hangbin Liu

When test_lirc_mode2_user exec failed, the test report failed but still exit with 0. Fix it by exiting with an error code.

Another issue is for the LIRCDEV checking. With bash -n, we need to quote the variable, or it will always be true. So if test_lirc_mode2_user was not run, just exit with skip code.

Fixes 6bdd533cee9a ("bpf: add selftest for lirc_mode2 type program")
---
 tools/testing/selftests/bpf/test_lirc_mode2.sh | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
tools/testing/selftests/bpf/test_lirc_mode2.sh +4 -1
index ec4e15948e40..5252b91f48a1 100755
@@ -3,6 +3,7 @@
 
 # Kselftest framework requirement - SKIP code is 4.
 ksft_skip=4
+ret=$ksft_skip
 
 msg="skip all tests:"
 if [ $UID != 0 ]; then
@@ -25,7 +26,7 @@ do
 	fi
 done
 
-if [ -n $LIRCDEV ];
+if [ -n "$LIRCDEV" ];
 then
 	TYPE=lirc_mode2
 	./test_lirc_mode2_user $LIRCDEV $INPUTDEV
@@ -36,3 +37,5 @@ then
 		echo -e ${GREEN}"PASS: $TYPE"${NC}
 	fi
 fi
+
+exit $ret
Signature · 1 line
2.35.1
#3 lore raw

Re: [PATCHv2 bpf] selftests/bpf/test_lirc_mode2.sh: exit with proper code

This patch was applied to bpf/bpf-next.git (master) by Daniel Borkmann <[email protected]>:

Hello:

This patch was applied to bpf/bpf-next.git (master) by Daniel Borkmann <[email protected]>:

Quoted 8 lines · On Mon, 21 Mar 2022 10:41:49 +0800 you wrote:

When test_lirc_mode2_user exec failed, the test report failed but still exit with 0. Fix it by exiting with an error code.

Another issue is for the LIRCDEV checking. With bash -n, we need to quote the variable, or it will always be true. So if test_lirc_mode2_user was not run, just exit with skip code.

[...]

Here is the summary with links:
- [PATCHv2,bpf] selftests/bpf/test_lirc_mode2.sh: exit with proper code

    https://git.kernel.org/bpf/bpf-next/c/ec80906b0fbd

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html