qtbase/coin/instructions/vxworks_testrunner.yaml
Toni Saario 1a5499ce5f Coin: Extend VxWorks restart matching to RTPLib errors
Running many tests on the VxWorks in the emulator without
restarting it between can cause exhaustion of some
resources and cause an RTP spawn fail in some tests.

This change will restart the emulator in such cases, which
allows the test to try again on fresh boot.

Change-Id: I5ad715f243867d43b055271d6bc61ca4ccb3089b
Reviewed-by: Simo Fält <simo.falt@qt.io>
Reviewed-by: Michał Łoś <michal.los@siili.com>
(cherry picked from commit 5be7a9773e106f9675e8d57121c298539f4ce343)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-02-21 14:52:54 +00:00

80 lines
2.9 KiB
YAML

type: Group
instructions:
- type: WriteFile
filename: "{{.AgentWorkingDir}}/coin_vxworks_qemu_runner.sh"
fileMode: 493
fileContents: |
#!/bin/bash
quoted_args=`python3 -c 'import sys, shlex; print(shlex.join(sys.argv[2:]))' "$@"`
testdir="$(dirname $1)"
testexecutable="$1"
echo RUNNING via serial: "$quoted_args"
echo "cmd rtp exec -p 200 -t 0x01000000 -u 0x1000000 $testexecutable -- $quoted_args" > /home/qt/work/vx.sh
echo "cmd echo \"qtest_in_vxworks_complete: $?\"" >> /home/qt/work/vx.sh
#rtp exec Execute a process.
# -p : specify the initial task priority
# 200 is high, 255 max
# -t : task options for the RTPs initial task
# 0x01000000 turn on coprocessor
# -u : specify the size of the process task stack
# -- : mark the end of "rtp exec" options.
# qtest_in_vxworks_complete echo is used to detect test process completion as it will
# be echoed after test process ends normally or crashes when normal log lines are not present.
# Check that emulator is functioning
( echo "cmd echo \"health check\"" > /tmp/guest.in ) & pid=$!
( sleep 5 && kill -HUP $pid ) 2>/dev/null & watcher=$!
wait $pid 2>/dev/null && pkill -HUP -P $watcher
if [[ "$?" -eq "0" ]]; then
read -t 5 echoline</tmp/guest.out
read -t 1 testline</tmp/guest.out
fi
if [[ -z "$testline" ]]; then
echo "Restarting stuck emulator"
pkill qemu-system
rm /tmp/guest.in /tmp/guest.out
mkfifo /tmp/guest.in /tmp/guest.out
/bin/bash /home/qt/vxworks_qemu_launcher.sh $VXWORKS_EMULATOR_TYPE
sleep 1
/bin/bash /home/qt/work/coin_vxworks_vars.sh
sleep 1
else
echo "Emulator responding"
fi
# Empty output
while read -t 1 line; do
echo $line
done < /tmp/guest.out
echo "cmd cd $testdir" > /tmp/guest.in
sleep 1
echo "</home/qt/work/vx.sh" > /tmp/guest.in
while read -t 600 line; do
echo "$line"
if echo "$line" | /usr/bin/grep -q "qtest_in_vxworks_complete"
then
read -t 1 line</tmp/guest.out
echo "$line"
exitcode=$(echo "$line" | sed -nr 's/qtest_in_vxworks_complete: (-?[0-9]+)/\1/gp' | tr -d '\r')
exit $exitcode
fi
# Handle crashes
if echo "$line" | /usr/bin/grep -qE "(SIGSEGV)|(SIGABRT)|(S_rtpLib_[A-Z_]+)"
then
# Empty output pipe
while read -t 1 line; do
echo $line
done < /tmp/guest.out
echo "Test crashed"
pkill qemu-system # Kill emulator to force restart on next test start
exit 1
fi
done < /tmp/guest.out