From bb8bbb29619cb15b644328375d161317f8158ca5 Mon Sep 17 00:00:00 2001 From: Muminul Islam Date: Thu, 23 Apr 2026 14:29:10 -0700 Subject: [PATCH] docs: add testing documentation Add docs/testing.md covering the dev_cli.sh interface, all test types (unit, integration, VFIO, Windows, live migration, rate limiter, CVM), custom kernel/firmware overrides via environment variables, performance metrics, code coverage, and the CI workflow matrix. Assisted-by: GitHub Copilot:Claude-Opus-4.6 Signed-off-by: Muminul Islam --- docs/testing.md | 403 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 403 insertions(+) create mode 100644 docs/testing.md diff --git a/docs/testing.md b/docs/testing.md new file mode 100644 index 000000000..74478c494 --- /dev/null +++ b/docs/testing.md @@ -0,0 +1,403 @@ +# Testing + +- [Testing](#testing) + - [Overview](#overview) + - [Prerequisites](#prerequisites) + - [The dev\_cli.sh entry point](#the-dev_clish-entry-point) + - [Global flags](#global-flags) + - [Building](#building) + - [Running tests](#running-tests) + - [Argument passthrough](#argument-passthrough) + - [Custom kernel and firmware](#custom-kernel-and-firmware) + - [Unit tests](#unit-tests) + - [Integration tests](#integration-tests) + - [x86\_64](#x86_64) + - [ARM64](#arm64) + - [VFIO](#vfio) + - [Windows guests](#windows-guests) + - [Rate limiter](#rate-limiter) + - [Confidential VMs](#confidential-vms) + - [Performance metrics](#performance-metrics) + - [Code coverage](#code-coverage) + - [CI workflows](#ci-workflows) + +## Overview + +All Cloud Hypervisor builds and tests run inside a Docker container to +provide a reproducible environment. The main entry point is +`scripts/dev_cli.sh`, which manages the container lifecycle and +forwards arguments to the appropriate test scripts. + +The container image is published at +`ghcr.io/cloud-hypervisor/cloud-hypervisor` and is automatically +pulled on first use. A local build of the container can be triggered +with `scripts/dev_cli.sh build-container` or by passing the `--local` +flag. + +Test workloads (guest images, kernels, firmware) are stored on the host +under `$HOME/workloads` and bind-mounted into the container at +`/root/workloads`. Most test scripts download missing workloads +automatically on first run. + +## Prerequisites + +A working Docker (or Podman) installation and access to `/dev/kvm` +(or `/dev/mshv` for Microsoft Hypervisor tests) are required. The +host must be running Linux on x86_64 or aarch64. + +```shell +# Verify KVM is available +ls -l /dev/kvm +``` + +The container image bundles all build dependencies. No Rust toolchain +is needed on the host. + +## The dev_cli.sh entry point + +``` +scripts/dev_cli.sh [flags] [] +``` + +### Global flags + +| Flag | Description | +|-----------|--------------------------------------------------| +| `--local` | Build and use a local container image instead of pulling from the registry. | + +### Building + +```shell +scripts/dev_cli.sh build [--debug|--release] [--libc musl|gnu] \ + [--hypervisor kvm|mshv] [--features ] \ + [--volumes /host:/ctr#...] [-- ] +``` + +| Flag | Default | Description | +|----------------|---------|------------------------------------------| +| `--debug` | yes | Build debug binaries. | +| `--release` | | Build release binaries. | +| `--libc` | `gnu` | C library to link against (`musl`/`gnu`).| +| `--hypervisor` | `kvm` | Hypervisor backend (`kvm`/`mshv`). | +| `--features` | | Additional cargo features. | +| `--volumes` | | Extra host volumes (`/a:/a#/b:/b`). | +| `--runtime` | `docker`| Container runtime (`docker`/`podman`). | + +Arguments after `--` are forwarded directly to `cargo build`. + +### Running tests + +```shell +scripts/dev_cli.sh tests [] [--libc musl|gnu] \ + [--hypervisor kvm|mshv] [--volumes /host:/ctr#...] \ + [--