Skip to content

Commit 7788230

Browse files
committed
Add full qemu integration test
Runs the full xenomorph workflow on a VM.
1 parent 9604828 commit 7788230

1 file changed

Lines changed: 46 additions & 0 deletions

File tree

flake.nix

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,42 @@
128128

129129
dontInstall = true;
130130
};
131+
132+
# QEMU integration test (requires KVM)
133+
qemu-integration = pkgs.stdenv.mkDerivation {
134+
pname = "xenomorph-qemu-integration";
135+
inherit version;
136+
src = ./.;
137+
138+
nativeBuildInputs = [
139+
pkgs.zig
140+
pkgs.qemu_kvm
141+
pkgs.cpio
142+
pkgs.gzip
143+
];
144+
145+
dontConfigure = true;
146+
dontInstall = true;
147+
148+
# Require KVM for this test
149+
requiredSystemFeatures = [ "kvm" ];
150+
151+
buildPhase = ''
152+
export ZIG_GLOBAL_CACHE_DIR=$(mktemp -d)
153+
154+
# Set up environment for the test
155+
export KERNEL_PATH="${pkgs.linuxPackages_latest.kernel}/bzImage"
156+
export BUSYBOX_PATH="${pkgs.pkgsStatic.busybox}/bin/busybox"
157+
export QEMU_PATH="${pkgs.qemu_kvm}/bin/qemu-system-x86_64"
158+
export XENOMORPH_PATH="${xenomorphStatic}/bin/xenomorph"
159+
160+
# Build and run the QEMU test
161+
zig build test-qemu -Doptimize=ReleaseSafe
162+
./zig-out/bin/qemu-test
163+
164+
touch $out
165+
'';
166+
};
131167
};
132168

133169
# QEMU integration test
@@ -143,6 +179,9 @@
143179
144180
export KERNEL_PATH BUSYBOX_PATH XENOMORPH_PATH QEMU_PATH
145181
182+
# Set up Zig cache directory
183+
export ZIG_GLOBAL_CACHE_DIR="''${XDG_CACHE_HOME:-$HOME/.cache}/zig"
184+
146185
# Build and run the QEMU test executable
147186
${pkgs.zig}/bin/zig build test-qemu -Doptimize=ReleaseSafe
148187
./zig-out/bin/qemu-test
@@ -157,9 +196,14 @@
157196
busybox
158197
cpio
159198
gzip
199+
# Ensure proper less is available (busybox's less breaks git pager)
200+
less
160201
];
161202

162203
shellHook = ''
204+
# Use real less instead of busybox's (fixes git pager)
205+
export PAGER="${pkgs.less}/bin/less"
206+
163207
echo "Xenomorph development environment"
164208
echo "Zig version: $(zig version)"
165209
echo ""
@@ -176,6 +220,8 @@
176220
builds = {
177221
exclude = [ "aarch64-darwin" "x86_64-darwin" ];
178222
};
223+
# Enable KVM for QEMU integration tests
224+
server.enable = true;
179225
};
180226
};
181227
}

0 commit comments

Comments
 (0)