Skip to content

Conversation

@rminnich
Copy link
Member

The test runs on Linux on amd64, arm, arm64, and riscv64.

Once this is merged, this test can replace the one in u-root. Our goal is to elminate as many u-root VM shell script tests as possible, because we have found undetected errors in them. Tests should be written in Go.

We keep this test here to also test cpu. Getting it all working was no small matter. We want it to keep working :-)

We extend the client package in small ways to make writing VM tests convenient.

The kernel images and initramfs for cpu are built into the package. The tests can be run hermetically by running go test.
ghcr.io is only used for go generate, and that will not be frequent (possibly changing only every year or so).

The kernels are cached from the u-root ghcr.io docker images. The kernels have a few tweaks, for things missing
from the kernel (GRE, VTI) in ghcr.io. The PR for these additions has been submitted for the vmtest repo. The kernels also provide /proc/config.gz. For now, my fixes are local to config_linux.txt files.

Note: I have no idea how the vmscript in u-root is passing at this point, with support for GRE, VTI, and other things missing. The script may not be working; there may be errors that are not caught. I've seen ignored errors in other scripts.

The compiled-in initramfs package only contains cpud. The vm package builds a u-root image for testing as needed and concatenates it to the cpud initramfs.

The VMs start with two network interfaces. The first is used to support cpud; the second interface can be manipulated by the tests. This removes the need to parse VM console output, which can be fragile.

IP is configured by ip=dhcp.

The test assumes there is a working qemu on the CI. This allows us to run these tests on any kernel/architecture combination that has qemu.

The test runs on Linux on amd64, arm, arm64, and riscv64.

Once this is merged, this test can replace the one in u-root.
Our goal is to elminate as many u-root VM shell script tests
as possible, because we have found undetected errors in them.
Tests should be written in Go.

We keep this test here to also test cpu. Getting it all
working was no small matter. We want it to keep working :-)

We extend the client package in small ways to make writing
VM tests convenient.

The kernel images and initramfs for cpu are built into
the package. The tests can be run hermetically by running
go test.
ghcr.io is only used for go generate, and that will not be
frequent (possibly changing only every year or so).

The kernels are cached from the u-root ghcr.io docker images.
The kernels have a few tweaks, for things missing
from the kernel (GRE, VTI) in ghcr.io. The PR for these additions
has been submitted for the vmtest repo. The kernels also
provide /proc/config.gz. For now, my fixes are local
to config_linux.txt files.

Note: I have no idea how the vmscript in u-root is passing
at this point, with support for GRE, VTI, and other things missing.
The script may not be working; there may be errors
that are not caught. I've seen ignored errors in other scripts.

The compiled-in initramfs package only contains cpud. The vm
package builds a u-root image for testing as needed and concatenates
it to the cpud initramfs.

The VMs start with two network interfaces. The first is used
to support cpud; the second interface can be manipulated by the tests.
This removes the need to parse VM console output, which can be fragile.

IP is configured by ip=dhcp.

The test assumes there is a working qemu on the CI.
This allows us to run these tests on any kernel/architecture
combination that has qemu.

Signed-off-by: Ronald G Minnich <rminnich@gmail.com>
@rminnich rminnich added enhancement New feature or request Awaiting Reviewer labels Oct 21, 2025
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds comprehensive integration tests for the cpu package using QEMU VMs across four Linux architectures (amd64, arm, arm64, and riscv64). The tests validate network configuration capabilities using the u-root ip command, including interface management, routing, tunneling (SIT, GRE, VTI, IPIP), and ARP operations. This replaces fragile shell-based VM tests in u-root with hermetic Go tests that can be run with go test.

Key Changes

  • Added TestIP function that validates ip command functionality across multiple architectures
  • Extended vm package API to support architecture-specific builds with GOOS/GOARCH parameters
  • Added second network interface to VMs for testing network operations without parsing console output
  • Updated TestCPUAMD64 to use new Uroot API and added similar TestCPUARM test

Reviewed Changes

Copilot reviewed 4 out of 14 changed files in this pull request and generated 9 comments.

File Description
vm/ip_linux_test.go New comprehensive test validating ip command operations across four architectures
vm/vm.go Extended Image struct and Uroot function to support architecture-specific builds; added second network interface
vm/vm_linux_test.go Updated existing tests to use new Uroot API signature and added ARM-specific test
vm/build.go Reordered build configurations and added debug code (disabled) for container image pulling

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Signed-off-by: Ronald G Minnich <rminnich@gmail.com>
@rminnich rminnich merged commit 6cbb2c0 into u-root:main Oct 22, 2025
15 checks passed
Copy link
Collaborator

@brho brho left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor nits

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do you want both the cpio and the cpio.gz?

@rminnich
Copy link
Member Author

Sorry I missed your comments. I will work on them next.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Awaiting Reviewer enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants