Debian Codegraph @

coin/instructions/coin_module_test_qnx_start_emulator.yaml

raw
1 type: Group
2 instructions:
3 - type: Group
4 instructions:
5 - type: WriteFile
6 fileContents: |
7 #!/bin/bash
8 RESULT=1 # 0 upon success
9 TIMEOUT=240
10 COUNT=0
11 QEMUPID=0
12 QEMUIPADDR="{{.Env.QNX_QEMU_IPADDR}}"
13 mkqnximage --type=qemu --graphics=no --ip=${QEMUIPADDR} --build --run=-h </dev/null &>/dev/null & disown
14
15 while [[ "QEMUPID" -eq 0 ]]
16 do
17 QEMUPID=`pidof qemu-system-x86_64`
18
19 if [[ "QEMUPID" -eq 0 ]]; then
20 echo "QEMU not yet started, wait 1 sec."
21 COUNT=$((COUNT+1))
22 sleep 1
23 else
24 echo "QEMU running with PID: $QEMUPID"
25 fi
26
27 if [[ "COUNT" -eq "TIMEOUT" ]]; then
28 echo "Timeout waiting QEMU to start"
29 exit 1
30 fi
31 done
32
33 while :; do
34 echo "Waiting QEMU SSH coming up"
35 status=$(ssh -o PreferredAuthentications=publickey -o BatchMode=yes -o ConnectTimeout=1 ${QEMUIPADDR} echo ok 2>&1)
36 RESULT=$?
37 if [ $RESULT -eq 0 ]; then
38 echo "QEMU SSH Connected ok"
39 break
40 fi
41 if [ $RESULT -eq 255 ]; then
42 # connection refused also gets you here
43 if [[ $status == *"Permission denied"* ]] ; then
44 # permission denied indicates the ssh link is okay
45 echo "QEMU SSH server up"
46 RESULT=0
47 break
48 fi
49 fi
50 TIMEOUT=$((TIMEOUT-1))
51 if [ $TIMEOUT -eq 0 ]; then
52 echo "QEMU SSH timed out"
53 exit $RESULT
54 fi
55 sleep 1
56 done
57 exit $RESULT
58 filename: "{{.Env.QNX_QEMU}}/start_qnx_qemu.sh"
59 fileMode: 493
60 - type: ChangeDirectory
61 directory: "{{.Env.QNX_QEMU}}"
62 - type: ExecuteCommand
63 command: "{{.Env.QNX_QEMU}}/start_qnx_qemu.sh"
64 maxTimeInSeconds: 300
65 maxTimeBetweenOutput: 100
66 userMessageOnFailure: >
67 Failed to start QNX qemu, check logs.
68 disable_if:
69 condition: property
70 property: host.os
71 equals_value: Windows
72 enable_if:
73 condition: and
74 conditions:
75 - condition: property
76 property: target.os
77 equals_value: QNX
78 - condition: property
79 property: features
80 not_contains_value: DisableTests