Files
ThreadX4TGFS/test/threadx/run_threadx_test.sh

49 lines
1.2 KiB
Bash
Executable File

#!/bin/bash
set -euo pipefail
simulator="$1"
isa="$2"
elf="$3"
if [ ! -x "$simulator" ]; then
echo "Simulator not found or not executable: $simulator" >&2
exit 2
fi
if [ ! -f "$elf" ]; then
echo "ELF not found: $elf" >&2
exit 2
fi
log_file=$(mktemp)
trap 'rm -f "$log_file"' EXIT
"$simulator" \
--isa="$isa" \
-f "$elf" \
-p tb.top.core.finish_condition=1 \
-m 10s \
| tee "$log_file"
summary_line=$(grep -F "**** Test Summary:" "$log_file" | tail -n 1 || true)
if [ -z "$summary_line" ]; then
echo "Missing ThreadX test summary in simulator output" >&2
exit 1
fi
read -r passed failed errors <<EOF_SUMMARY
$(echo "$summary_line" | sed -n 's/.*Tests Passed:[[:space:]]*\([0-9][0-9]*\)[[:space:]]*Tests Failed:[[:space:]]*\([0-9][0-9]*\)[[:space:]]*System Errors:[[:space:]]*\([0-9][0-9]*\).*/\1 \2 \3/p')
EOF_SUMMARY
if [ -z "${passed:-}" ] || [ -z "${failed:-}" ] || [ -z "${errors:-}" ]; then
echo "Could not parse ThreadX test summary: $summary_line" >&2
exit 1
fi
if [ "$failed" -ne 0 ] || [ "$errors" -ne 0 ]; then
echo "ThreadX regression reported failure: passed=$passed failed=$failed errors=$errors" >&2
exit 1
fi
exit 0