if [ "$arch" = "arm64" ]; then
    . debian/tests/qemu-cmd
    rc=0
    expect -- - ${QEMU_CMD[@]} -netdev user,id=net0 -device vmxnet3,netdev=net0,id=net0,romfile= << 'EOF' || rc=$?
set timeout 30

spawn {*}$argv

expect {
    "UEFI firmware" {
    }
    timeout {
        exit 2
    }
}
expect {
    -re {\e\[} {
        exit 0
    }
    timeout {
        exit 1
    }
}

EOF
    if [ "$rc" -eq 2 ]; then
        echo "Cannot boot arm64 VM with CPU model $arm64_cpu_model, try with cortex-a57"
        arm64_cpu_model="cortex-a57"
    elif [ "$rc" -eq 1 ]; then
        echo "Booting arm64 VM with CPU model $arm64_cpu_model stuck, try with cortex-a57"
        arm64_cpu_model="cortex-a57"
    elif [ "$rc" -ne 0 ]; then
        echo "Unexpected error when testing arm64 CPU model $arm64_cpu_model"
        exit "$rc"
    fi
fi
