]> git.ipfire.org Git - thirdparty/chrony.git/commitdiff
test: indicate failed sync stats
authorMiroslav Lichvar <mlichvar@redhat.com>
Thu, 14 Nov 2024 12:40:43 +0000 (13:40 +0100)
committerMiroslav Lichvar <mlichvar@redhat.com>
Thu, 14 Nov 2024 12:43:18 +0000 (13:43 +0100)
test/simulation/test.common

index 42a2917b7d15f58d4707bbe3c881a5b3fe9d8d7e..604df61ae6744eaf1c491eaafaff422c92e0a30b 100644 (file)
@@ -239,7 +239,7 @@ check_config_h() {
 
 # Check if the clock was well synchronized
 check_sync() {
-       local i sync_time max_time_error max_freq_error ret=0
+       local i msg sync_time max_time_error max_freq_error r ret=0
        local rms_time_error rms_freq_error
 
        test_message 2 1 "checking clock sync time, max/rms time/freq error:"
@@ -254,17 +254,37 @@ check_sync() {
                rms_time_error=$(get_stat 'RMS offset' $i)
                rms_freq_error=$(get_stat 'RMS frequency' $i)
 
-               test_message 3 0 "node $i: $sync_time $(printf '%.2e %.2e %.2e %.2e' \
-                       $max_time_error $max_freq_error $rms_time_error $rms_freq_error)"
+               r=0
+               msg="$sync_time"
+               if ! check_stat $sync_time $min_sync_time $max_sync_time; then
+                       msg+="!"
+                       r=1
+               fi
+               msg+="$(printf ' %.2e' $max_time_error)"
+               if ! check_stat $max_time_error 0.0 $time_max_limit; then
+                       msg+="!"
+                       r=1
+               fi
+               msg+="$(printf ' %.2e' $max_freq_error)"
+               if ! check_stat $max_freq_error 0.0 $freq_max_limit; then
+                       msg+="!"
+                       r=1
+               fi
+               msg+="$(printf ' %.2e' $rms_time_error)"
+               if ! check_stat $rms_time_error 0.0 $time_rms_limit; then
+                       msg+="!"
+                       r=1
+               fi
+               msg+="$(printf ' %.2e' $rms_freq_error)"
+               if ! check_stat $rms_freq_error 0.0 $freq_rms_limit; then
+                       msg+="!"
+                       r=1
+               fi
 
-               check_stat $sync_time $min_sync_time $max_sync_time && \
-                       check_stat $max_time_error 0.0 $time_max_limit && \
-                       check_stat $max_freq_error 0.0 $freq_max_limit && \
-                       check_stat $rms_time_error 0.0 $time_rms_limit && \
-                       check_stat $rms_freq_error 0.0 $freq_rms_limit && \
-                       test_ok || test_bad
+               test_message 3 0 "node $i: $msg"
 
-               [ $? -eq 0 ] || ret=1
+               [ $r -eq 0 ] || ret=1
+               [ $r -eq 0 ] && test_ok || test_bad
        done
 
        return $ret