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