summaryrefslogtreecommitdiffstats
path: root/coin/instructions/coin_module_test_qnx_start_emulator.yaml
blob: 8e50313a882693e8b6e9cd96e498e56ce88d8719 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
type: Group
instructions:
  - type: Group
    instructions:
      - type: WriteFile
        fileContents: |
            #!/bin/bash
            RESULT=1 # 0 upon success
            TIMEOUT=60
            COUNT=0
            QEMUPID=0
            QEMUIPADDR="{{.Env.QNX_QEMU_IPADDR}}"
            mkqnximage --type=qemu --graphics=no --ip=${QEMUIPADDR} --build --run=-h </dev/null &>/dev/null & disown

            while [[ "QEMUPID" -eq 0 ]]
            do
                QEMUPID=`pidof qemu-system-x86_64`

                if [[ "QEMUPID" -eq 0 ]]; then
                    echo "QEMU not yet started, wait 1 sec."
                    COUNT=$((COUNT+1))
                    sleep 1
                else
                    echo "QEMU running with PID: $QEMUPID"
                fi

                if [[ "COUNT" -eq "TIMEOUT" ]]; then
                    echo "Timeout waiting QEMU to start"
                    exit 1
                fi
            done

            while :; do
                echo "Waiting QEMU SSH coming up"
                status=$(ssh -o BatchMode=yes -o ConnectTimeout=1 ${QEMUIPADDR} echo ok 2>&1)
                RESULT=$?
                if [ $RESULT -eq 0 ]; then
                    echo "QEMU SSH Connected ok"
                    break
                fi
                if [ $RESULT -eq 255 ]; then
                    # connection refused also gets you here
                    if [[ $status == *"Permission denied"* ]] ; then
                        # permission denied indicates the ssh link is okay
                        echo "QEMU SSH server up"
                        RESULT=0
                        break
                    fi
                fi
                TIMEOUT=$((TIMEOUT-1))
                if [ $TIMEOUT -eq 0 ]; then
                    echo "QEMU SSH timed out"
                    exit $RESULT
                fi
                sleep 1
            done
            exit $RESULT
        filename: "{{.Env.QNX_QEMU}}/start_qnx_qemu.sh"
        fileMode: 755
      - type: ChangeDirectory
        directory: "{{.Env.QNX_QEMU}}"
      - type: ExecuteCommand
        command: "chmod 755 {{.Env.QNX_QEMU}}/start_qnx_qemu.sh"
        maxTimeInSeconds: 10
        maxTimeBetweenOutput: 10
        userMessageOnFailure: >
          Failed to change file permission.
        disable_if:
          condition: property
          property: host.os
          equals_value: Windows
      - type: ExecuteCommand
        command: "{{.Env.QNX_QEMU}}/start_qnx_qemu.sh"
        maxTimeInSeconds: 100
        maxTimeBetweenOutput: 100
        userMessageOnFailure: >
          Failed to start QNX qemu, check logs.
        disable_if:
          condition: property
          property: host.os
          equals_value: Windows
    enable_if:
      condition: and
      conditions:
        - condition: property
          property: target.osVersion
          equals_value: QNX_710
        - condition: property
          property: features
          not_contains_value: DisableTests