From 02b0484ccce67fd38a6e35529af79b94fac92895 Mon Sep 17 00:00:00 2001 From: Jacek Galowicz Date: Mon, 13 Jul 2026 16:58:38 +0200 Subject: [PATCH] nixos-test-driver: Add multi-arch test --- nixos/tests/all-tests.nix | 1 + .../nixos-test-driver/multi-arch-test.nix | 55 +++++++++++++++++++ 2 files changed, 56 insertions(+) create mode 100644 nixos/tests/nixos-test-driver/multi-arch-test.nix diff --git a/nixos/tests/all-tests.nix b/nixos/tests/all-tests.nix index 7b5ce335f0bf..e08301831793 100644 --- a/nixos/tests/all-tests.nix +++ b/nixos/tests/all-tests.nix @@ -153,6 +153,7 @@ in console-log = runTest ./nixos-test-driver/console-log.nix; containers = runTest ./nixos-test-driver/containers.nix; nspawn-daemon-reexec-dbus = runTest ./nspawn-daemon-reexec-dbus.nix; + multi-arch-test = runTest ./nixos-test-driver/multi-arch-test.nix; skip-typecheck = runTest ./nixos-test-driver/skip-typecheck.nix; console-timeout = runTest ./nixos-test-driver/console-timeout.nix; options-doc-regression = import ./nixos-test-driver/options-doc-regression.nix { inherit pkgs; }; diff --git a/nixos/tests/nixos-test-driver/multi-arch-test.nix b/nixos/tests/nixos-test-driver/multi-arch-test.nix new file mode 100644 index 000000000000..33b9973c7f89 --- /dev/null +++ b/nixos/tests/nixos-test-driver/multi-arch-test.nix @@ -0,0 +1,55 @@ +{ pkgs, lib, ... }: +{ + name = "multi-arch-test"; + meta.maintainers = with pkgs.lib.maintainers; [ tfc ]; + + node.pkgsReadOnly = false; + + nodes = { + # Setting build = host platform because such standard VM setups + # are well-cached by the multi-arch build infrastructure of the + # project. + vmIntel = { + nixpkgs.buildPlatform = "x86_64-linux"; + nixpkgs.hostPlatform = "x86_64-linux"; + }; + vmArm = { + nixpkgs.buildPlatform = "aarch64-linux"; + nixpkgs.hostPlatform = "aarch64-linux"; + }; + }; + + defaults = { + # not needed for this test and shrinks the closure + # because we dont' need qemu for all architectures + virtualisation.qemu.guestAgent.enable = false; + + # the test is already very slow but we don't need DHCP anyway + networking.dhcpcd.enable = false; + + # fix the network-online target, otherwise it doesn't work + # properly as a synchronization mechanism. + systemd.network.wait-online.enable = true; + systemd.network.wait-online.anyInterface = true; + }; + + # slow due to SW emulation but shouldn't be slower than that + globalTimeout = 5 * 60; + + testScript = { nodes, ... }: /* python */ '' + start_all() + + vmIntel.systemctl("start network-online.target") + vmArm.systemctl("start network-online.target") + vmIntel.wait_for_unit("network-online.target") + vmArm.wait_for_unit("network-online.target") + + vmIntel.succeed("ping -c 1 vmArm") + vmArm.succeed("ping -c 1 vmIntel") + + archIntel = vmIntel.succeed("uname -m") + t.assertIn("${nodes.vmIntel.nixpkgs.hostPlatform.qemuArch}", archIntel, "machine1 is an intel VM") + archArm = vmArm.succeed("uname -m") + t.assertIn("${nodes.vmArm.nixpkgs.hostPlatform.qemuArch}", archArm, "machine1 is an ARM VM") + ''; +}