Files
fpc-msgbase/run_tests.sh
Ken Johnson 94dcd27005 Add corruption-resilience fuzz tests
New tests/adversarial/ suite covers each driver plus mb.kludge with
crafted-input scenarios: empty files, truncated headers, garbage
payloads, oversized length fields, infinite-loop bait.  The
invariant under test is graceful degradation: no crash, no hang,
no OOM.  Every allocation caps, every loop terminates, every
unreadable record returns False cleanly.

Coverage:
  test_fuzz_jam       7 cases  (.JHR/.JDT/.JDX/.JLR corruption)
  test_fuzz_squish    5 cases  (clen underflow, 2 GB clen, garbage idx)
  test_fuzz_hudson    3 cases  (bundle-file corruption)
  test_fuzz_goldbase  2 cases
  test_fuzz_pcboard   2 cases
  test_fuzz_msg       4 cases  (50 MB no-NUL body, strange names)
  test_fuzz_kludge    3 cases  (100 K CRs, 1 M CRs, legit round-trip)

run_tests.sh builds and runs them after the happy-path suite.
All 26 fuzz cases pass; all 47 existing tests still pass.
2026-04-19 06:44:34 -07:00

81 lines
2.0 KiB
Bash
Executable File

#!/bin/bash
#
# run_tests.sh - build and run every test against the native
# x86_64-linux target. Tests that don't need network / FS features
# that are linux-specific should also work on other native hosts,
# but we only run them here.
#
# Exits non-zero on any failure.
set -e
FPCNATIVE=/opt/fpcup/fpc/bin/x86_64-linux/fpc
TGT=x86_64-linux
cd "$(dirname "$0")"
mkdir -p "units/$TGT" "exe/$TGT"
compile() {
local src=$1
echo " compile $(basename "$src")"
"$FPCNATIVE" -Mobjfpc -Sh -Sgic \
-Fusrc -Fusrc/formats -Fusrc/wc_sdk -Futests \
-FUunits/"$TGT" -FEexe/"$TGT" \
"$src" >/tmp/ma_test_build.$$.log 2>&1 || {
cat /tmp/ma_test_build.$$.log
rm -f /tmp/ma_test_build.$$.log
exit 1
}
rm -f /tmp/ma_test_build.$$.log
}
run() {
local name=$1
echo " run $name"
rm -rf "/tmp/ma_$name"
"./exe/$TGT/$name"
}
echo "Building tests..."
compile tests/test_read.pas
compile tests/test_roundtrip.pas
compile tests/test_roundtrip_attrs.pas
compile tests/test_lock.pas
compile tests/test_wildcat.pas
compile tests/test_write_existing.pas
compile tests/test_pack.pas
compile tests/test_hwm.pas
compile tests/test_consumer_round1.pas
compile tests/adversarial/test_fuzz_jam.pas
compile tests/adversarial/test_fuzz_squish.pas
compile tests/adversarial/test_fuzz_msg.pas
compile tests/adversarial/test_fuzz_hudson.pas
compile tests/adversarial/test_fuzz_goldbase.pas
compile tests/adversarial/test_fuzz_pcboard.pas
compile tests/adversarial/test_fuzz_kludge.pas
echo
echo "Running happy-path tests..."
run test_read
run test_roundtrip
run test_roundtrip_attrs
run test_lock
run test_wildcat
run test_write_existing
run test_pack
run test_hwm
run test_consumer_round1
echo
echo "Running adversarial / corruption-resilience tests..."
run test_fuzz_jam
run test_fuzz_squish
run test_fuzz_msg
run test_fuzz_hudson
run test_fuzz_goldbase
run test_fuzz_pcboard
run test_fuzz_kludge
echo
echo "All tests passed."