]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
selftests: ovpn: fail notification check on mismatch
authorRalf Lici <ralf@mandelbit.com>
Mon, 23 Mar 2026 14:32:26 +0000 (15:32 +0100)
committerAntonio Quartulli <antonio@openvpn.net>
Fri, 17 Apr 2026 08:54:03 +0000 (10:54 +0200)
compare_ntfs doesn't fail when expected and received notification
streams diverge.

Fix this bug by tracking the diff exit status explicitly and return it
to the caller so notification mismatches propagate as test failures.

Fixes: 77de28cd7cf1 ("selftests: ovpn: add notification parsing and matching")
Signed-off-by: Ralf Lici <ralf@mandelbit.com>
Signed-off-by: Antonio Quartulli <antonio@openvpn.net>
tools/testing/selftests/net/ovpn/common.sh

index 4c08f756e63ad15521b7d994b7233e158eb72391..c92415aaddfc2e45c7ceb73ac2a6a5d1962065de 100644 (file)
@@ -140,23 +140,35 @@ add_peer() {
 }
 
 compare_ntfs() {
+       local diff_rc=0
+       local diff_file
+
        if [ ${#tmp_jsons[@]} -gt 0 ]; then
                suffix=""
                [ "${SYMMETRIC_ID}" -eq 1 ] && suffix="${suffix}-symm"
                [ "$FLOAT" == 1 ] && suffix="${suffix}-float"
                expected="json/peer${1}${suffix}.json"
                received="${tmp_jsons[$1]}"
+               diff_file=$(mktemp)
 
                kill -TERM ${listener_pids[$1]} || true
                wait ${listener_pids[$1]} || true
                printf "Checking notifications for peer ${1}... "
                if diff <(jq -s "${JQ_FILTER}" ${expected}) \
-                       <(jq -s "${JQ_FILTER}" ${received}); then
+                       <(jq -s "${JQ_FILTER}" ${received}) \
+                       >"${diff_file}" 2>&1; then
                        echo "OK"
+               else
+                       diff_rc=$?
+                       echo "failed"
+                       cat "${diff_file}"
                fi
 
+               rm -f "${diff_file}" || true
                rm -f ${received} || true
        fi
+
+       return "${diff_rc}"
 }
 
 cleanup() {