diff mbox series

[net-next,2/2] kselftest: rtnetlink: add pause and pause on fail flag

Message ID bc57e9f08104ec59122ce97fa514a286981087e2.1694527251.git.dmendes@redhat.com (mailing list archive)
State Accepted
Delegated to: Netdev Maintainers
Headers show
Series kselftest: rtnetlink: add additional command line options | expand

Checks

Context Check Description
netdev/series_format success Posting correctly formatted
netdev/tree_selection success Clearly marked for net-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 9 this patch: 9
netdev/cc_maintainers warning 2 maintainers not CCed: linux-kselftest@vger.kernel.org shuah@kernel.org
netdev/build_clang success Errors and warnings before: 9 this patch: 9
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success net selftest script(s) already in Makefile
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 9 this patch: 9
netdev/checkpatch warning WARNING: line length of 81 exceeds 80 columns WARNING: line length of 82 exceeds 80 columns
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Daniel Mendes Sept. 12, 2023, 2:28 p.m. UTC
'Pause' prompts the user to press Enter to continue running tests
once one test has finished. Pause on fail on prompts the user to press
enter only when a test fails.

Modifications to kci_test_addrlft() and kci_test_ipsec_offload()
ensure that whenever end_test is called, [$ret -ne 0] indicates
failure. This allows end_test to really easily implement pause on fail
functionality.

Signed-off-by: Daniel Mendes <dmendes@redhat.com>
---
 tools/testing/selftests/net/rtnetlink.sh | 27 ++++++++++++++++++++----
 1 file changed, 23 insertions(+), 4 deletions(-)
diff mbox series

Patch

diff --git a/tools/testing/selftests/net/rtnetlink.sh b/tools/testing/selftests/net/rtnetlink.sh
index daaf1bcc10ac..ef52d34551cf 100755
--- a/tools/testing/selftests/net/rtnetlink.sh
+++ b/tools/testing/selftests/net/rtnetlink.sh
@@ -32,6 +32,8 @@  ALL_TESTS="
 
 devdummy="test-dummy0"
 VERBOSE=0
+PAUSE=no
+PAUSE_ON_FAIL=no
 
 # Kselftest framework requirement - SKIP code is 4.
 ksft_skip=4
@@ -112,6 +114,17 @@  end_test()
 {
 	echo "$*"
 	[ "${VERBOSE}" = "1" ] && echo
+
+	if [[ $ret -ne 0 ]] && [[ "${PAUSE_ON_FAIL}" = "yes" ]]; then
+		echo "Hit enter to continue"
+		read a
+	fi;
+
+	if [ "${PAUSE}" = "yes" ]; then
+		echo "Hit enter to continue"
+		read a
+	fi
+
 }
 
 
@@ -286,8 +299,8 @@  kci_test_addrlft()
 	sleep 5
 	run_cmd_grep "10.23.11." ip addr show dev "$devdummy"
 	if [ $? -eq 0 ]; then
-		end_test "FAIL: preferred_lft addresses remaining"
 		check_err 1
+		end_test "FAIL: preferred_lft addresses remaining"
 		return
 	fi
 
@@ -779,8 +792,8 @@  kci_test_ipsec_offload()
 	# does offload show up in ip output
 	lines=`ip x s list | grep -c "crypto offload parameters: dev $dev dir"`
 	if [ $lines -ne 2 ] ; then
-		end_test "FAIL: ipsec_offload SA offload missing from list output"
 		check_err 1
+		end_test "FAIL: ipsec_offload SA offload missing from list output"
 	fi
 
 	# use ping to exercise the Tx path
@@ -806,8 +819,8 @@  EOF
 	ip x p flush
 	lines=`grep -c "SA count=0" $sysfsf`
 	if [ $lines -ne 1 ] ; then
-		end_test "FAIL: ipsec_offload SA not removed from driver"
 		check_err 1
+		end_test "FAIL: ipsec_offload SA not removed from driver"
 	fi
 
 	# clean up any leftovers
@@ -1254,6 +1267,8 @@  usage: ${0##*/} OPTS
         -t <test>   Test(s) to run (default: all)
                     (options: $(echo $ALL_TESTS))
         -v          Verbose mode (show commands and output)
+        -P          Pause after every test
+        -p          Pause after every failing test before cleanup (for debugging)
 EOF
 }
 
@@ -1271,15 +1286,19 @@  for x in ip tc;do
 	fi
 done
 
-while getopts t:hv o; do
+while getopts t:hvpP o; do
 	case $o in
 		t) TESTS=$OPTARG;;
 		v) VERBOSE=1;;
+		p) PAUSE_ON_FAIL=yes;;
+		P) PAUSE=yes;;
 		h) usage; exit 0;;
 		*) usage; exit 1;;
 	esac
 done
 
+[ $PAUSE = "yes" ] && PAUSE_ON_FAIL="no"
+
 kci_test_rtnl
 
 exit $?