]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
selftests/vsock: add check_result() for pass/fail counting
authorBobby Eshleman <bobbyeshleman@meta.com>
Sat, 8 Nov 2025 16:00:58 +0000 (08:00 -0800)
committerJakub Kicinski <kuba@kernel.org>
Wed, 12 Nov 2025 14:19:39 +0000 (06:19 -0800)
Add check_result() function to reuse logic for incrementing the
pass/fail counters. This function will get used by different callers as
we add different types of tests in future patches (namely, namespace and
non-namespace tests will be called at different places, and re-use this
function).

Reviewed-by: Simon Horman <horms@kernel.org>
Signed-off-by: Bobby Eshleman <bobbyeshleman@meta.com>
Reviewed-by: Stefano Garzarella <sgarzare@redhat.com>
Link: https://patch.msgid.link/20251108-vsock-selftests-fixes-and-improvements-v4-7-d5e8d6c87289@meta.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
tools/testing/selftests/vsock/vmtest.sh

index bd231467c66b3bf7e83a2b8d0e5b3aaa3584ba3e..2dd9bbb8c4a9dd32f7726c8cbe335a2508b12225 100755 (executable)
@@ -79,6 +79,26 @@ die() {
        exit "${KSFT_FAIL}"
 }
 
+check_result() {
+       local rc arg
+
+       rc=$1
+       arg=$2
+
+       cnt_total=$(( cnt_total + 1 ))
+
+       if [[ ${rc} -eq ${KSFT_PASS} ]]; then
+               cnt_pass=$(( cnt_pass + 1 ))
+               echo "ok ${cnt_total} ${arg}"
+       elif [[ ${rc} -eq ${KSFT_SKIP} ]]; then
+               cnt_skip=$(( cnt_skip + 1 ))
+               echo "ok ${cnt_total} ${arg} # SKIP"
+       elif [[ ${rc} -eq ${KSFT_FAIL} ]]; then
+               cnt_fail=$(( cnt_fail + 1 ))
+               echo "not ok ${cnt_total} ${arg} # exit=${rc}"
+       fi
+}
+
 vm_ssh() {
        ssh -q -o UserKnownHostsFile=/dev/null -p ${SSH_HOST_PORT} localhost "$@"
        return $?
@@ -530,17 +550,7 @@ cnt_total=0
 for arg in "${ARGS[@]}"; do
        run_test "${arg}"
        rc=$?
-       if [[ ${rc} -eq $KSFT_PASS ]]; then
-               cnt_pass=$(( cnt_pass + 1 ))
-               echo "ok ${cnt_total} ${arg}"
-       elif [[ ${rc} -eq $KSFT_SKIP ]]; then
-               cnt_skip=$(( cnt_skip + 1 ))
-               echo "ok ${cnt_total} ${arg} # SKIP"
-       elif [[ ${rc} -eq $KSFT_FAIL ]]; then
-               cnt_fail=$(( cnt_fail + 1 ))
-               echo "not ok ${cnt_total} ${arg} # exit=$rc"
-       fi
-       cnt_total=$(( cnt_total + 1 ))
+       check_result "${rc}" "${arg}"
 done
 
 terminate_pidfiles "${pidfile}"