| .. | ||
| README.md | ||
UEFI Rescue System Test Suite
Overview
The test suite verifies that UEFI rescue system images build correctly and boot successfully in QEMU.
Running Tests
From the repository root:
./run-tests.sh
This will:
- Build the minimal UKI image
- Boot it in QEMU
- Monitor the serial console for successful autologin
- Stop QEMU once the test passes
- Timeout after 120 seconds if boot fails
How It Works
The test script (run-tests.sh) is a simple bash script that:
- Builds the minimal image with
nix build .#minimal - Starts
test-boot.shin the background with output redirected to a log file - Loops every second, grepping the log file for the success pattern
^\[root@ - If found: kills QEMU and reports success
- If timeout (120s) reached: shows the last 50 lines and exits with failure
- If QEMU crashes: shows the full log and exits with failure
This approach is simple, provides immediate output, and doesn't require complex Nix builds for testing.
Current Tests
minimal-boot
Verifies that the minimal rescue image:
- Builds successfully
- Boots in QEMU
- Auto-login works (checks for
[root@nixos-rescue:~]#prompt)
Adding New Tests
To add a new test, edit run-tests.sh and add a new test section:
# Test 2: Your new test
echo "Test: your-test-name"
echo " Building your image..."
nix build .#your-image --no-link
# ... test logic similar to minimal-boot ...
Future Test Ideas
- fat-boot: Test the KDE fat image boots
- ssh-service: Verify SSH service starts (check for "Started OpenSSH" in logs)
- network-dhcp: Check that network configuration works
- disk-tools: Verify rescue tools are available in the booted system
- nix-commands: Test that Nix commands work (nix-env, nix-shell)
Debugging Failed Tests
- Check the output: The test script shows output in real-time
- Boot manually:
./test-boot.sh ./resultto see what's happening interactively - Use graphical mode:
./test-boot.sh --graphical ./resultto see VGA output - Increase timeout: Edit
TIMEOUT=120inrun-tests.shif the system is slow - Check the pattern: Make sure the grep pattern matches what you expect
Tips
- The script runs in the repository directory, so paths are relative
- QEMU process is automatically killed on script exit (via trap)
- Serial console output is captured to a temporary file
- Use
grep -Esyntax for the success pattern (extended regex)