Makefile+scripts: add unit test flake hunter

This commit adds a script to hunt flakes for a specific unit test with
trace logs. Also rename the make commands to make them more clear on
whether it's a unit test, itest, or paralleled itest.
This commit is contained in:
yyforyongyu
2025-02-24 18:47:44 +08:00
parent 5d3680a6f6
commit fa8527af09
2 changed files with 31 additions and 8 deletions

View File

@@ -0,0 +1,23 @@
#!/bin/bash
# Check if pkg and case variables are provided.
if [ $# -lt 2 ] || [ $# -gt 3 ]; then
echo "Usage: $0 <pkg> <case> [timeout]"
exit 1
fi
pkg=$1
case=$2
timeout=${3:-30s} # Default to 30s if not provided.
counter=0
# Run the command in a loop until it fails.
while output=$(go clean -testcache && make unit-debug log="stdlog trace" pkg=$pkg case=$case timeout=$timeout 2>&1); do
((counter++))
echo "Test $case passed, count: $counter"
done
# Only log the output when it fails.
echo "Test $case failed. Output:"
echo "$output"