drgn has a significant amount of code (both core and in helpers) which is
dependent on the Linux kernel version. This code is tested on multiple Linux
kernel versions in a virtual machine. These tests can be run on all supported
kernels with python3 setup.py test -K
. This requires QEMU and zstd to be
installed.
Tests can also be run on specific kernels with -k
. This takes a
comma-separated list of kernels which are wildcard patterns (e.g., 5.6.*
)
matching a kernel release hosted on GitHub (see below).
The goal of vmtest is to run tests in the same userspace environment as the host, but with a different kernel. The host runs the virtual machine with QEMU (see the vmtest.vm module).
The guest mounts the host's root filesystem as its own root filesystem via VirtFS. It is mounted read-only for safety. To support modifications, the guest uses OverlayFS to overlay a read-write tmpfs over the VirtFS root. It also mounts the kernel modules and vmlinux via VirtFS.
The guest runs an init shell script which sets up the system and filesystem hierarchy, runs a command, and returns the exit status via virtio-serial.
This infrastructure is all generic. The drgn-specific parts are:
- The kernel builds. These are configured with a minimal configuration
including everything required to run drgn and the Linux kernel helper tests.
Each build is packaged as a tarball containing
vmlinux
,vmlinuz
, and kernel modules. These packages are built by the vmtest.kbuild module. They are hosted in a GitHub release which is managed via the GitHub API by the vmtest.manage CLI. New kernel releases are built and uploaded by a GitHub Actions workflow. The packages are downloaded by the vmtest.download module. - A kernel module for testing drgn functionality that cannot be tested through userspace APIs.
- The test command itself. This is just some
setup.py
glue to build the test kernel module and run the VM with the proper invocation of the Python unittest command line interface.
The vmtest.vm
and vmtest.download
modules also have CLIs for testing
purposes. These are subject to change.