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