automated: linux: pi-stress: allow user-specified baseline

Previously, the pi-stress script dynamically computed the baseline
(minimum inversion value) across all iterations. This patch adds support
for a new `-x` option that lets users manually specify a fixed
`user_baseline` value.

Using a fixed baseline is preferred over percentage-based thresholds in
this context, as it offers more consistent and predictable
evaluation—especially in controlled benchmarking environments or when
comparing results across different systems and runs. Percentages can be
misleading if the dynamic baseline fluctuates due to noise or system
conditions.

This change improves flexibility and repeatability in post-processing
and performance analysis.

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 362f8ce..86a9b94 100755
--- a/automated/linux/pi-stress/pi-stress.sh
+++ b/automated/linux/pi-stress/pi-stress.sh
@@ -17,21 +17,21 @@
 RR="false"
 BACKGROUND_CMD=""
 ITERATIONS=1
-PTHRESHOLD="10"
+USER_BASELINE=""
 
 usage() {
-    echo "Usage: $0 [-D runtime] [-m <true|false>] [-r <true|false>] [-w background_cmd] [-i iterations] [-p procent threshold]" 1>&2
+    echo "Usage: $0 [-D runtime] [-m <true|false>] [-r <true|false>] [-w background_cmd] [-i iterations] [-x user baseline]" 1>&2
     exit 1
 }
 
-while getopts ":D:m:r:w:i:p:" opt; do
+while getopts ":D:m:r:w:i:x:" opt; do
     case "${opt}" in
         D) DURATION="${OPTARG}" ;;
         m) MLOCKALL="${OPTARG}" ;;
         r) RR="${OPTARG}" ;;
         w) BACKGROUND_CMD="${OPTARG}" ;;
         i) ITERATIONS="${OPTARG}" ;;
-        p) PTHRESHOLD="${OPTARG}" ;;
+        x) USER_BASELINE="${OPTARG}" ;;
         *) usage ;;
     esac
 done
@@ -92,14 +92,17 @@
     fi
 
     # Find the minimum inversion
-    max_inversion=$(sort -n "${max_inversions_file}" | tail -n1)
-    echo "Calculated max_inversion: ${max_inversion}"
-    threshold=$(echo "$max_inversion * (1 - (${PTHRESHOLD}/100))" | bc -l)
-    echo "Threshold: $threshold (i.e., within -${PTHRESHOLD}%)"
+    if [ -n "${USER_BASELINE}" ]; then
+        max_inversion="${USER_BASELINE}"
+        echo "Using user-provided user_baseline: ${max_inversion}"
+    else
+        max_inversion=$(sort -n "${max_inversions_file}" | tail -n1)
+        echo "Calculated max_inversion: ${max_inversion}"
+    fi
 
     fail_count=0
     while read -r val; do
-        is_less=$(echo "$val < $threshold" | bc -l)
+        is_less=$(echo "$val < $max_inversion" | bc -l)
         if [ "$is_less" -eq 1 ]; then
             fail_count=$((fail_count + 1))
         fi
diff --git a/automated/linux/pi-stress/pi-stress.yaml b/automated/linux/pi-stress/pi-stress.yaml
index 3081844..2215964 100644
--- a/automated/linux/pi-stress/pi-stress.yaml
+++ b/automated/linux/pi-stress/pi-stress.yaml
@@ -41,11 +41,11 @@
     ARTIFACTORIAL_URL: "https://archive.validation.linaro.org/artifacts/team/qa/"
     ARTIFACTORIAL_TOKEN: ""
     ITERATIONS: 1
-    PTHRESHOLD: "10"
+    USER_BASELINE: ""
 
 run:
     steps:
         - cd automated/linux/pi-stress
-        - ./pi-stress.sh -D "${DURATION}" -m "${MLOCKALL}" -r "${RR}" -i "${ITERATIONS}" -w "${BACKGROUND_CMD}" -p "${PTHRESHOLD}"
+        - ./pi-stress.sh -D "${DURATION}" -m "${MLOCKALL}" -r "${RR}" -i "${ITERATIONS}" -w "${BACKGROUND_CMD}" -x "${USER_BASELINE}"
         - ../../utils/upload-to-artifactorial.sh -a "output/pi-stress.json" -u "${ARTIFACTORIAL_URL}" -t "${ARTIFACTORIAL_TOKEN}"
         - ../../utils/send-to-lava.sh ./output/result.txt