mirror of
https://chromium.googlesource.com/crosvm/crosvm
synced 2025-02-06 02:25:23 +00:00
Instead of instanciating crosvm directly, we can start the binary as a sub-process. This includes parsing of crosvm options in the tests, and makes the test cases closer to real-world usage. To make make this possible, we need to make sure that the crosvm binary is uploaded to the VM before running the test, which is done by the sync_so script, which is baked into the builder container. We prevent future container re-builds for just maintaining the script, I have removed them from the container, and call the scripts from the local source directly. The test runner is also updated to ensure all package binaries are built (currently only tests are built). BUG=b:182841358 TEST=./test_all passes Change-Id: I7dfd21abcb2b90fe125eb43f85572fbf645b888a Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2744280 Tested-by: Dennis Kempin <denniskempin@google.com> Commit-Queue: Dennis Kempin <denniskempin@google.com> Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
78 lines
2.3 KiB
Docker
78 lines
2.3 KiB
Docker
# Copyright 2021 The Chromium OS Authors. All rights reserved.
|
|
# Use of this source code is governed by a BSD-style license that can be
|
|
# found in the LICENSE file.
|
|
#
|
|
# Docker container for VMs that can run crosvm tests. This container is
|
|
# primarily an intermediate step and imported into the crosvm_(aarch64)_builder
|
|
# containers, but for testing purposes it can be run directly.
|
|
|
|
# Target architecture of the VM. Either arm64 or amd64.
|
|
ARG VM_ARCH
|
|
|
|
# Build stage which will build the rootfs for our VM
|
|
FROM debian:buster as vm_builder
|
|
ARG VM_ARCH
|
|
|
|
RUN apt-get update && apt-get install --yes \
|
|
cloud-image-utils \
|
|
curl \
|
|
expect \
|
|
qemu-system-arm \
|
|
qemu-system-x86 \
|
|
qemu-efi-aarch64
|
|
|
|
WORKDIR /workspace/vm
|
|
|
|
RUN curl -sSfL -o rootfs.qcow2 \
|
|
"http://cloud.debian.org/images/cloud/bullseye/daily/20210208-542/debian-11-generic-${VM_ARCH}-daily-20210208-542.qcow2"
|
|
|
|
# Package `cloud_init_data.yaml` to be loaded during `first_boot.expect`
|
|
COPY build/cloud_init_data.yaml ./
|
|
RUN cloud-localds -v cloud_init.img cloud_init_data.yaml
|
|
|
|
# Boot the VM once, to do initialization work so we do not have to do it at
|
|
# every launch.
|
|
COPY runtime/start_vm.${VM_ARCH} ./start_vm
|
|
COPY build/first_boot.expect ./
|
|
RUN expect -f first_boot.expect
|
|
|
|
# Compress and sparsify image after doing all the init work.
|
|
RUN qemu-img convert -O qcow2 -c rootfs.qcow2 rootfs.compressed \
|
|
&& mv -f rootfs.compressed rootfs.qcow2
|
|
|
|
|
|
# Runtime environment for amd64
|
|
FROM debian:buster as runtime_amd64
|
|
RUN apt-get update && apt-get install --yes --no-install-recommends \
|
|
qemu-system-x86
|
|
|
|
|
|
# Runtime environment for arm64
|
|
FROM debian:buster as runtime_arm64
|
|
RUN apt-get update && apt-get install --yes --no-install-recommends \
|
|
ipxe-qemu \
|
|
qemu-system-arm \
|
|
qemu-efi-aarch64
|
|
|
|
|
|
# Select the correct stage as runtime stage
|
|
FROM runtime_${VM_ARCH} as runtime
|
|
ARG VM_ARCH
|
|
|
|
RUN apt-get install --yes --no-install-recommends \
|
|
openssh-client
|
|
|
|
# Copy rootfs into runtime stage
|
|
WORKDIR /workspace/vm
|
|
COPY --from=vm_builder /workspace/vm/rootfs.qcow2 ./
|
|
|
|
# Setup SSH profile for `vm`.
|
|
RUN mkdir -p ~/.ssh
|
|
COPY runtime/ssh /root/.ssh
|
|
RUN chmod 0600 /root/.ssh/id_rsa
|
|
|
|
# Copy utility scripts
|
|
COPY runtime/start_vm.${VM_ARCH} ./start_vm
|
|
|
|
# Automatically start the VM.
|
|
ENTRYPOINT [ "/workspace/vm/start_vm" ]
|