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 virtualisation.useBootLoader = true;
12 virtualisation.useEFIBoot = true;
13 boot.loader.systemd-boot.enable = true;
14 boot.loader.efi.canTouchEfiVariables = true;
15 };
16
17 node2 = { modulesPath, ... }: {
18 virtualisation.vlans = [ ];
19 environment.systemPackages = [ pkgs.hello ];
20 imports = [
21 "${modulesPath}/installer/netboot/netboot-minimal.nix"
22 ];
23 };
24 };
25
26 testScript = { nodes, ... }: ''
27 # Test whether reboot via kexec works.
28 node1.wait_for_unit("multi-user.target")
29 node1.succeed('kexec --load /run/current-system/kernel --initrd /run/current-system/initrd --command-line "$(</proc/cmdline)"')
30 node1.execute("systemctl kexec >&2 &", check_return=False)
31 node1.connected = False
32 node1.connect()
33 node1.wait_for_unit("multi-user.target")
34
35 # Check if the machine with netboot-minimal.nix profile boots up
36 node2.wait_for_unit("multi-user.target")
37 node2.shutdown()
38
39 # Kexec node1 to the toplevel of node2 via the kexec-boot script
40 node1.succeed('touch /run/foo')
41 node1.fail('hello')
42 node1.execute('${nodes.node2.config.system.build.kexecTree}/kexec-boot', check_return=False)
43 node1.succeed('! test -e /run/foo')
44 node1.succeed('hello')
45 node1.succeed('[ "$(hostname)" = "node2" ]')
46
47 node1.shutdown()
48 '';
49})