From: Vsevolod Stakhov Date: Sat, 18 Oct 2025 14:32:31 +0000 (+0100) Subject: [Test] Fix integer expression errors in ASAN log checker X-Git-Tag: 3.14.0~65 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=86373fcfdf8d582ea3c75ee13062ac5c90fed9a7;p=thirdparty%2Frspamd.git [Test] Fix integer expression errors in ASAN log checker Replace grep -c with wc -l to avoid malformed output when grep returns results with filenames or multiple lines. The grep -c command was producing output like "0\n0" instead of a single integer, causing bash comparison failures. Use wc -l with tr to ensure clean integer values, and add error suppression to comparison operators for robustness. --- diff --git a/test/integration/scripts/check-asan-logs.sh b/test/integration/scripts/check-asan-logs.sh index ce87860c50..a5afdfd6c6 100755 --- a/test/integration/scripts/check-asan-logs.sh +++ b/test/integration/scripts/check-asan-logs.sh @@ -25,8 +25,9 @@ for log_file in $ASAN_LOGS; do echo "----------------------------------------" # Count memory leaks - LEAKS=$(grep -c "LeakSanitizer" "$log_file" 2>/dev/null || echo "0") - if [ "$LEAKS" -gt 0 ]; then + LEAKS=$(grep "LeakSanitizer" "$log_file" 2>/dev/null | wc -l | tr -d ' ') + LEAKS=${LEAKS:-0} + if [ "$LEAKS" -gt 0 ] 2>/dev/null; then echo " Memory leaks detected: $LEAKS" TOTAL_LEAKS=$((TOTAL_LEAKS + LEAKS)) @@ -35,8 +36,9 @@ for log_file in $ASAN_LOGS; do fi # Count other errors - ERRORS=$(grep -c "ERROR: AddressSanitizer" "$log_file" 2>/dev/null || echo "0") - if [ "$ERRORS" -gt 0 ]; then + ERRORS=$(grep "ERROR: AddressSanitizer" "$log_file" 2>/dev/null | wc -l | tr -d ' ') + ERRORS=${ERRORS:-0} + if [ "$ERRORS" -gt 0 ] 2>/dev/null; then echo " AddressSanitizer errors: $ERRORS" TOTAL_ERRORS=$((TOTAL_ERRORS + ERRORS)) @@ -45,14 +47,16 @@ for log_file in $ASAN_LOGS; do fi # Check for heap-use-after-free - UAF=$(grep -c "heap-use-after-free" "$log_file" 2>/dev/null || echo "0") - if [ "$UAF" -gt 0 ]; then + UAF=$(grep "heap-use-after-free" "$log_file" 2>/dev/null | wc -l | tr -d ' ') + UAF=${UAF:-0} + if [ "$UAF" -gt 0 ] 2>/dev/null; then echo " Heap-use-after-free: $UAF" fi # Check for heap-buffer-overflow - OVERFLOW=$(grep -c "heap-buffer-overflow" "$log_file" 2>/dev/null || echo "0") - if [ "$OVERFLOW" -gt 0 ]; then + OVERFLOW=$(grep "heap-buffer-overflow" "$log_file" 2>/dev/null | wc -l | tr -d ' ') + OVERFLOW=${OVERFLOW:-0} + if [ "$OVERFLOW" -gt 0 ] 2>/dev/null; then echo " Heap-buffer-overflow: $OVERFLOW" fi