ci/crosvm: Sanitize CROSVM_RET in crosvm-runner.sh
Some checks are pending
macOS-CI / macOS-CI (dri) (push) Waiting to run
macOS-CI / macOS-CI (xlib) (push) Waiting to run

When crosvm crashes, the `exit_code` file might not exist or might
contain unexpected garbage (multi-line output or spaces).
Because $CROSVM_RET was unquoted in comparisons, this led to intermittent
"too many arguments" bash syntax errors, which masked the true failure.

Signed-off-by: Valentine Burley <valentine.burley@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/41124>
This commit is contained in:
Valentine Burley 2026-04-22 21:44:59 +02:00 committed by Marge Bot
parent c22e4022a8
commit 96ae27069d

View file

@ -150,15 +150,17 @@ crosvm --no-syslog run \
section_start crosvm_results "Processing crosvm results"
CROSVM_RET=$?
[ ${CROSVM_RET} -eq 0 ] && {
[ "${CROSVM_RET}" -eq 0 ] && {
# The actual return code is the crosvm guest script's exit code
CROSVM_RET=$(cat ${VM_TEMP_DIR}/exit_code 2>/dev/null)
# Sanitize it to a single integer
CROSVM_RET=$(echo "$CROSVM_RET" | grep -o '^[0-9]\+' | head -n 1)
# Force error when the guest script's exit code is not available
CROSVM_RET=${CROSVM_RET:-1}
}
# Show crosvm output on error to help with debugging
[ ${CROSVM_RET} -eq 0 ] || {
[ "${CROSVM_RET}" -eq 0 ] || {
{ set +x; } 2>/dev/null
echo "Dumping crosvm output.." >&2
cat ${VM_TEMP_DIR}/crosvm >&2