Files
marte-benchmark-suite/scenarios/S01_timing_display/validate.sh
T
2026-08-27 11:12:22 +02:00

116 lines
3.2 KiB
Bash
Executable File

#!/usr/bin/env bash
set -u
if [ "$#" -ne 1 ]; then
printf "Uso: %s <run.log>\n" "$0" >&2
exit 2
fi
RUN_LOG="$1"
if [ ! -f "$RUN_LOG" ]; then
printf "LOG ASSENTE: %s\n" "$RUN_LOG" >&2
exit 3
fi
START_LINES="$(
grep -Ec \
'^\[Information - RealTimeLoader\.cpp:[0-9]+\]: Started application in state State1[[:space:]]*$' \
"$RUN_LOG" || true
)"
COUNTER_SAMPLES="$(
grep -Ec \
'^\[Information - LoggerBroker\.cpp:[0-9]+\]: Counter \[0:0\]:[0-9]+[[:space:]]*$' \
"$RUN_LOG" || true
)"
CYCLE_TIME_SAMPLES="$(
grep -Ec \
'^\[Information - LoggerBroker\.cpp:[0-9]+\]: State1_Thread1_CycleTime \[0:0\]:[0-9]+[[:space:]]*$' \
"$RUN_LOG" || true
)"
SIGINT_LINES="$(
grep -Ec \
'^\[Information - Bootstrap\.cpp:[0-9]+\]: Application recieved SIGINT\.[[:space:]]*$' \
"$RUN_LOG" || true
)"
STOP_OK_LINES="$(
grep -Ec \
'^\[Information - Bootstrap\.cpp:[0-9]+\]: Application successfully stopped\.[[:space:]]*$' \
"$RUN_LOG" || true
)"
FATAL_ERROR_LINES="$(
grep -Ec '^\[FatalError - ' "$RUN_LOG" || true
)"
ERROR_LINES="$(
grep -Ec '^\[Error - ' "$RUN_LOG" || true
)"
NO_ERROR_LINES="$(
grep -Ec '^\[NoError - ' "$RUN_LOG" || true
)"
DOUBLE_STOP_LINES="$(
grep -Fc \
'Could not stop the RealTimeApplication. Was it ever started?' \
"$RUN_LOG" || true
)"
LAST_COUNTER="$(
grep -E \
'^\[Information - LoggerBroker\.cpp:[0-9]+\]: Counter \[0:0\]:[0-9]+[[:space:]]*$' \
"$RUN_LOG" |
tail -n 1 |
awk -F: '{gsub(/[[:space:]]/, "", $NF); print $NF}'
)"
printf "============================================================\n"
printf "VALIDAZIONE PRECISA S01\n"
printf "============================================================\n"
printf "Log: %s\n" "$RUN_LOG"
printf "Avvii di State1: %s\n" "$START_LINES"
printf "Campioni Counter reali: %s\n" "$COUNTER_SAMPLES"
printf "Ultimo Counter: %s\n" "${LAST_COUNTER:-non disponibile}"
printf "Campioni CycleTime reali: %s\n" "$CYCLE_TIME_SAMPLES"
printf "SIGINT ricevuti: %s\n" "$SIGINT_LINES"
printf "Stop riusciti: %s\n" "$STOP_OK_LINES"
printf "Righe FatalError reali: %s\n" "$FATAL_ERROR_LINES"
printf "Righe Error reali: %s\n" "$ERROR_LINES"
printf "Righe NoError: %s\n" "$NO_ERROR_LINES"
printf "Anomalie doppio arresto: %s\n" "$DOUBLE_STOP_LINES"
FUNCTIONAL_OK=0
if [ "$START_LINES" -ge 1 ] &&
[ "$COUNTER_SAMPLES" -ge 50 ] &&
[ "$CYCLE_TIME_SAMPLES" -ge 50 ]; then
FUNCTIONAL_OK=1
fi
printf "\n============================================================\n"
printf "CLASSIFICAZIONE\n"
printf "============================================================\n"
if [ "$FUNCTIONAL_OK" -eq 1 ]; then
printf "[VERIFICATO] Funzionamento S01 e produzione dei segnali.\n"
else
printf "[NON DIMOSTRATO] Funzionamento S01 non sufficientemente provato.\n"
exit 20
fi
if [ "$SIGINT_LINES" -ge 1 ] &&
[ "$STOP_OK_LINES" -ge 1 ] &&
[ "$FATAL_ERROR_LINES" -eq 0 ] &&
[ "$ERROR_LINES" -eq 0 ]; then
printf "[VERIFICATO] Shutdown privo di Error e FatalError.\n"
exit 0
fi
printf "[DA VERIFICARE] Funzionalità riuscita, ma shutdown con anomalia.\n"
exit 10