at 23.11-beta 1.6 kB view raw
1import ./make-test-python.nix ({ pkgs, lib, ... }: { 2 name = "kexec"; 3 meta = with lib.maintainers; { 4 maintainers = [ flokli lassulus ]; 5 }; 6 7 nodes = { 8 node1 = { ... }: { 9 virtualisation.vlans = [ ]; 10 virtualisation.memorySize = 4 * 1024; 11 }; 12 13 node2 = { modulesPath, ... }: { 14 virtualisation.vlans = [ ]; 15 environment.systemPackages = [ pkgs.hello ]; 16 imports = [ 17 "${modulesPath}/installer/netboot/netboot-minimal.nix" 18 "${modulesPath}/testing/test-instrumentation.nix" 19 "${modulesPath}/profiles/qemu-guest.nix" 20 ]; 21 }; 22 }; 23 24 testScript = { nodes, ... }: '' 25 # Test whether reboot via kexec works. 26 node1.wait_for_unit("multi-user.target") 27 node1.succeed('kexec --load /run/current-system/kernel --initrd /run/current-system/initrd --command-line "$(</proc/cmdline)"') 28 node1.execute("systemctl kexec >&2 &", check_return=False) 29 node1.connected = False 30 node1.connect() 31 node1.wait_for_unit("multi-user.target") 32 33 # Check if the machine with netboot-minimal.nix profile boots up 34 node2.wait_for_unit("multi-user.target") 35 node2.shutdown() 36 37 # Kexec node1 to the toplevel of node2 via the kexec-boot script 38 node1.succeed('touch /run/foo') 39 node1.fail('hello') 40 node1.execute('${nodes.node2.system.build.kexecTree}/kexec-boot', check_output=False) 41 node1.connected = False 42 node1.connect() 43 node1.wait_for_unit("multi-user.target") 44 node1.succeed('! test -e /run/foo') 45 node1.succeed('hello') 46 node1.succeed('[ "$(hostname)" = "node2" ]') 47 48 node1.shutdown() 49 ''; 50})