Debian Codegraph @

coin/instructions/vxworks_testrunner.yaml

raw
1 type: Group
2 instructions:
3 - type: WriteFile
4 filename: "{{.AgentWorkingDir}}/coin_vxworks_qemu_runner.sh"
5 fileMode: 493
6 fileContents: |
7 #!/bin/bash
8 quoted_args=`python3 -c 'import sys, shlex; print(shlex.join(sys.argv[2:]))' "$@"`
9
10 testdir="$(dirname $1)"
11 testexecutable="$1"
12 echo RUNNING via serial: "$quoted_args"
13 echo "cmd rtp exec -p 200 -t 0x01000000 -u 0x1000000 $testexecutable -- $quoted_args" > /home/qt/work/vx.sh
14 echo "cmd echo \"qtest_in_vxworks_complete: $?\"" >> /home/qt/work/vx.sh
15 #rtp exec Execute a process.
16 # -p : specify the initial task priority
17 # 200 is high, 255 max
18 # -t : task options for the RTPs initial task
19 # 0x01000000 turn on coprocessor
20 # -u : specify the size of the process task stack
21 # -- : mark the end of "rtp exec" options.
22
23 # qtest_in_vxworks_complete echo is used to detect test process completion as it will
24 # be echoed after test process ends normally or crashes when normal log lines are not present.
25
26 # Check that emulator is functioning
27 ( echo "cmd echo \"health check\"" > /tmp/guest.in ) & pid=$!
28 ( sleep 5 && kill -HUP $pid ) 2>/dev/null & watcher=$!
29 wait $pid 2>/dev/null && pkill -HUP -P $watcher
30
31 if [[ "$?" -eq "0" ]]; then
32 read -t 5 echoline</tmp/guest.out
33 read -t 1 testline</tmp/guest.out
34 fi
35
36 if [[ -z "$testline" ]]; then
37 echo "Restarting stuck emulator"
38 pkill qemu-system
39 rm /tmp/guest.in /tmp/guest.out
40 mkfifo /tmp/guest.in /tmp/guest.out
41 /bin/bash /home/qt/vxworks_qemu_launcher.sh $VXWORKS_EMULATOR_TYPE
42 sleep 1
43 /bin/bash /home/qt/work/coin_vxworks_vars.sh
44 sleep 1
45 else
46 echo "Emulator responding"
47 fi
48
49 # Empty output
50 while read -t 1 line; do
51 echo $line
52 done < /tmp/guest.out
53
54 echo "cmd cd $testdir" > /tmp/guest.in
55 sleep 1
56 echo "</home/qt/work/vx.sh" > /tmp/guest.in
57
58 while read -t 600 line; do
59 echo "$line"
60 if echo "$line" | /usr/bin/grep -q "qtest_in_vxworks_complete"
61 then
62 read -t 1 line</tmp/guest.out
63 echo "$line"
64 exitcode=$(echo "$line" | sed -nr 's/qtest_in_vxworks_complete: (-?[0-9]+)/\1/gp' | tr -d '\r')
65 exit $exitcode
66 fi
67
68 # Handle crashes
69 if echo "$line" | /usr/bin/grep -qE "(SIGSEGV)|(SIGABRT)|(S_rtpLib_[A-Z_]+)"
70 then
71 # Empty output pipe
72 while read -t 1 line; do
73 echo $line
74 done < /tmp/guest.out
75 echo "Test crashed"
76 pkill qemu-system # Kill emulator to force restart on next test start
77 exit 1
78 fi
79 done < /tmp/guest.out