]> git.ipfire.org Git - thirdparty/rspamd.git/commitdiff
[Test] Fix AWK syntax error in integration test analysis
authorVsevolod Stakhov <vsevolod@rspamd.com>
Fri, 17 Oct 2025 13:26:34 +0000 (14:26 +0100)
committerVsevolod Stakhov <vsevolod@rspamd.com>
Fri, 17 Oct 2025 13:26:34 +0000 (14:26 +0100)
Add default values for count variables to prevent division errors
when jq returns empty results

test/integration/scripts/integration-test.sh

index bac73364e14ee3be1c43007e3f16fa7ef424fcd1..c362cc7f99d1a09e4bc8d37c52ebf48c713d5f85 100755 (executable)
@@ -192,6 +192,11 @@ if [ "$TOTAL" -eq 0 ]; then
     exit 1
 fi
 
+# Ensure counts are numeric (default to 0 if empty)
+FUZZY_COUNT=${FUZZY_COUNT:-0}
+BAYES_SPAM_COUNT=${BAYES_SPAM_COUNT:-0}
+BAYES_HAM_COUNT=${BAYES_HAM_COUNT:-0}
+
 # Calculate percentages using awk
 FUZZY_RATE=$(awk "BEGIN {printf \"%.1f\", ($FUZZY_COUNT / $TOTAL) * 100}")
 BAYES_SPAM_RATE=$(awk "BEGIN {printf \"%.1f\", ($BAYES_SPAM_COUNT / $TOTAL) * 100}")