Fix coredump for swrast
[platform/upstream/mesa.git] / .gitlab-ci / crosvm-init.sh
1 #!/bin/sh
2
3 set -e
4
5 VSOCK_STDOUT=$1
6 VSOCK_STDERR=$2
7 VM_TEMP_DIR=$3
8
9 mount -t proc none /proc
10 mount -t sysfs none /sys
11 mkdir -p /dev/pts
12 mount -t devpts devpts /dev/pts
13 mount -t tmpfs tmpfs /tmp
14
15 . ${VM_TEMP_DIR}/crosvm-env.sh
16
17 # .gitlab-ci.yml script variable is using relative paths to install directory,
18 # so change to that dir before running `crosvm-script`
19 cd "${CI_PROJECT_DIR}"
20
21 # The exception is the dEQP binary, as it needs to run from its own directory
22 [ -z "${DEQP_BIN_DIR}" ] || cd "${DEQP_BIN_DIR}"
23
24 # Use a FIFO to collect relevant error messages
25 STDERR_FIFO=/tmp/crosvm-stderr.fifo
26 mkfifo -m 600 ${STDERR_FIFO}
27
28 dmesg --level crit,err,warn -w > ${STDERR_FIFO} &
29 DMESG_PID=$!
30
31 # Transfer the errors and crosvm-script output via a pair of virtio-vsocks
32 socat -d -u pipe:${STDERR_FIFO} vsock-listen:${VSOCK_STDERR} &
33 socat -d -U vsock-listen:${VSOCK_STDOUT} \
34     system:"stdbuf -eL sh ${VM_TEMP_DIR}/crosvm-script.sh 2> ${STDERR_FIFO}; echo \$? > ${VM_TEMP_DIR}/exit_code",nofork
35
36 kill ${DMESG_PID}
37 wait
38
39 sync
40 poweroff -d -n -f || true
41
42 sleep 1   # Just in case init would exit before the kernel shuts down the VM