automated: linux: pi-stress: add generic pass/fail logic
Enhance the pi-stress test to automatically determine a PASS or
FAIL result based on collected inversion measurements.
This change:
- Adds logic to parse the inversion values from output.
- Calculates the minimum observed inversion.
- Sets a threshold at 110% of the minimum inversion.
- Counts the number of runs that exceed this threshold.
- Fails the test if more than half the iterations exceed the threshold.
This enables automated evaluation of pi-stress results without
manual inspection, making the test more suitable for continuous
integration environments.
Signed-off-by: Anders Roxell <anders.roxell@linaro.org>
diff --git a/automated/linux/pi-stress/pi-stress.sh b/automated/linux/pi-stress/pi-stress.sh
index dfa935f..892be6e 100755
--- a/automated/linux/pi-stress/pi-stress.sh
+++ b/automated/linux/pi-stress/pi-stress.sh
@@ -76,3 +76,45 @@
fi
cat "${TMP_RESULT_FILE}" | tee -a "${RESULT_FILE}"
done
+
+if [ "${ITERATIONS}" -gt 2 ]; then
+ max_inversions_file="${OUTPUT}/max_inversions.txt"
+
+ # Extract all inversion values into a file
+ grep "inversion" "${RESULT_FILE}" | grep "^iteration-" | awk '{ print $(NF-1) }' |tee "${max_inversions_file}"
+
+ if [ ! -s "${max_inversions_file}" ]; then
+ echo "No inversion values found!"
+ report_fail "rt-tests-pi-stress"
+ exit 1
+ fi
+
+ # Find the minimum inversion
+ min_inversion=$(sort -n "${max_inversions_file}" | head -n1)
+
+ threshold=$(echo "$min_inversion * 1.10" | bc -l)
+
+ echo "Minimum max inversion: $min_inversion"
+ echo "Threshold (min * 1.10): $threshold"
+
+ # Count how many inversions exceed threshold
+ fail_count=0
+ while read -r val; do
+ is_greater=$(echo "$val > $threshold" | bc -l)
+ if [ "$is_greater" -eq 1 ]; then
+ fail_count=$((fail_count + 1))
+ fi
+ done < "${max_inversions_file}"
+
+ fail_limit=$((ITERATIONS / 2))
+
+ echo "Max allowed failures: $fail_limit"
+ echo "Actual failures: $fail_count"
+ echo "Number of max inversions above 110% of min: $fail_count"
+
+ if [ "$fail_count" -ge "$fail_limit" ]; then
+ report_fail "rt-tests-pi-stress"
+ else
+ report_pass "rt-tests-pi-stress"
+ fi
+fi