Scripts for testing ProcLens in isolated QEMU virtual machines.
# QEMU Testing
sudo ./e2e/qemu-setup.sh # One-time setup
sudo ./e2e/qemu-run.sh # Start VM
sudo ./e2e/qemu-test.sh # Automated tests (run from host in another terminal)
# Other utilities
./.github/pre-commit.sh # Pre-commit hook (auto-installed in dev container)Purpose: One-time setup of QEMU testing environment
What it does:
- Downloads Ubuntu 24.04 cloud image (~700MB)
- Creates cloud-init configuration for VM
- Installs VM kernel and headers matching the host
uname -r - Provisions VM build dependencies (
make,build-essential,kmod,git,vim,net-tools) - Repairs interrupted dpkg state during first-boot provisioning
- Configures SSH access with default credentials
Requirements:
qemu-system-x86_64qemu-imgcloud-localds(from cloud-image-utils package)
Output: Creates qemu-env/ directory with VM image and cloud-init config
Purpose: Start the QEMU virtual machine
What it does:
- Starts QEMU VM with appropriate settings
- Forwards SSH port 2222 to VM's port 22
- Allocates 2GB RAM and 2 CPU cores
- Enables KVM acceleration if available
- Provides serial console access
- Performs no installation; expects
qemu-setup.shto have provisioned host and VM prerequisites
VM Access:
- SSH:
ssh -p 2222 ubuntu@localhost - Default password:
ubuntu - Exit console: Press Ctrl+A then X
Note: First boot takes 1-2 minutes for cloud-init to complete.
Purpose: Automated end-to-end testing in QEMU VM
What it does:
- Syncs project files to VM
- Builds kernel module and user program in VM
- Loads kernel module
- Builds the multi-threaded test program
- Runs user program with test process
- Captures and displays output
- Unloads kernel module
- Cleans up
Requirements:
- QEMU VM must be running (
sudo ./e2e/qemu-run.sh) - SSH access configured (done by
qemu-setup.sh) - VM prerequisites are expected to be pre-provisioned by
qemu-setup.sh
Usage:
# Start VM in one terminal
sudo ./e2e/qemu-run.sh
# Run tests from another terminal
sudo ./e2e/qemu-test.shOutput: Shows build process, module loading, test results, and kernel logs.
Purpose: Git pre-commit hook for code quality
What it does:
- Runs code formatting checks
- Executes cppcheck static analysis
- Validates kernel coding style with checkpatch
Installation: Automatically installed in dev container on startup.
Manual bypass (use sparingly):
git commit --no-verify -m "message"- OS: Ubuntu 24.04 LTS
- Kernel: Matches host kernel release (
uname -r) - RAM: 2GB
- CPUs: 2 cores
- Disk: 20GB (resized cloud image)
- Network: User-mode networking with port forwarding
- Username:
ubuntu - Password:
ubuntu - Note: Change password after first login for security
- Host port 2222 → VM port 22 (SSH)
To avoid password prompts:
# Generate SSH key if you don't have one
ssh-keygen -t ed25519
# Copy to VM
ssh-copy-id -p 2222 ubuntu@localhostCopy TO VM:
scp -P 2222 localfile.txt ubuntu@localhost:~/Copy FROM VM:
scp -P 2222 ubuntu@localhost:~/remotefile.txt ./Sync directory (used by qemu-test.sh):
rsync -avz --exclude='.git' --exclude='build' \
-e "ssh -p 2222 -o StrictHostKeyChecking=no" \
./ ubuntu@localhost:~/ProcLens/rm -rf e2e/qemu-env/rm -rf e2e/qemu-env/
sudo ./e2e/qemu-setup.sh# Check if QEMU is running
ps aux | grep qemu
# Test SSH connection
ssh -p 2222 ubuntu@localhost echo "VM is accessible"- Check if VM is running:
ps aux | grep qemu - Wait for cloud-init to complete (1-2 minutes on first boot)
- Verify port forwarding:
netstat -ln | grep 2222 - Check VM console for errors (Ctrl+A then C in qemu-run.sh)
- Ensure KVM acceleration is enabled:
ls /dev/kvm - Check CPU/memory allocation in
qemu-run.sh - Verify host system has sufficient resources
- Check kernel headers:
ls /lib/modules/$(uname -r)/build - Update VM packages:
sudo apt update && sudo apt upgrade - Verify project files synced correctly
- Check kernel logs:
sudo dmesg | tail -20 - Verify kernel version compatibility
- Ensure no conflicting modules loaded
- Safe: Kernel panics won't crash your host system
- Isolated: No risk to host kernel or data
- Reproducible: Clean VM state for each test
- Fast: Quick VM reset and rebuild
- Automated: Full CI/CD integration possible
- Realistic: Tests in real Linux kernel environment
- Dev Container (current setup) - Isolated from host
- QEMU VM (recommended) - Extra safety from kernel crashes
- Cloud VM - Disposable testing environment
- Physical test machine - Dedicated hardware for kernel development
For kernel module development, QEMU offers the best balance of safety, speed, and realism.