diff options
author | Venkateswara Rao Mandela <venkat.mandela@gmail.com> | 2019-03-07 15:08:28 +0530 |
---|---|---|
committer | Venkateswara Rao Mandela <venkat.mandela@gmail.com> | 2019-07-11 17:40:25 +0530 |
commit | bc68f85326cc6dcd1b5785005649dfe10a31c827 (patch) | |
tree | 76f31a760e0ef8964212403ab6c74259fffe22c2 /nixos/tests/installer.nix | |
parent | b08400a4d2b81e0e680ce08f502c2d2b1c43367f (diff) |
nixos/tests: add test for showing child configuration in grub menu
- Create a child configuration named "Work" with an extra config file.
- Name the default configuration as "Home" :-)
- Once the VM is setup, reboot and verify that it has booted into
default configuration.
- Reboot into the "Work" configuration via grub.
- Verify that we have booted into the "Work" configuration and that
the extra config file is present.
This test works for the simple grub configuration and simple UEFI
Grub configuration. UEFI Systemd is not included in the test.
Diffstat (limited to 'nixos/tests/installer.nix')
-rw-r--r-- | nixos/tests/installer.nix | 71 |
1 files changed, 70 insertions, 1 deletions
diff --git a/nixos/tests/installer.nix b/nixos/tests/installer.nix index 36206b199e73..a136678c6eff 100644 --- a/nixos/tests/installer.nix +++ b/nixos/tests/installer.nix @@ -67,6 +67,7 @@ let # partitions and filesystems. testScriptFun = { bootLoader, createPartitions, grubVersion, grubDevice, grubUseEfi , grubIdentifier, preBootCommands, extraConfig + , testCloneConfig }: let iface = if grubVersion == 1 then "ide" else "virtio"; @@ -85,6 +86,7 @@ let in if !isEfi && !(pkgs.stdenv.isi686 || pkgs.stdenv.isx86_64) then throw "Non-EFI boot methods are only supported on i686 / x86_64" else '' + $machine->start; # Make sure that we get a login prompt etc. @@ -185,6 +187,43 @@ let ${preBootCommands} $machine->waitForUnit("network.target"); $machine->shutdown; + + # Tests for validating clone configuration entries in grub menu + ${optionalString testCloneConfig '' + # Reboot Machine + $machine = createMachine({ ${hdFlags} qemuFlags => "${qemuFlags}", name => "clone-default-config" }); + ${preBootCommands} + $machine->waitForUnit("multi-user.target"); + + # Booted configuration name should be Home + # This is not the name that shows in the grub menu. + # The default configuration is always shown as "Default" + $machine->succeed("cat /run/booted-system/configuration-name >&2"); + $machine->succeed("cat /run/booted-system/configuration-name | grep Home"); + + # We should find **not** a file named /etc/gitconfig + $machine->fail("test -e /etc/gitconfig"); + + # Set grub to boot the second configuration + $machine->succeed("grub-reboot 1"); + + $machine->shutdown; + + # Reboot Machine + $machine = createMachine({ ${hdFlags} qemuFlags => "${qemuFlags}", name => "clone-alternate-config" }); + ${preBootCommands} + + $machine->waitForUnit("multi-user.target"); + # Booted configuration name should be Work + $machine->succeed("cat /run/booted-system/configuration-name >&2"); + $machine->succeed("cat /run/booted-system/configuration-name | grep Work"); + + # We should find a file named /etc/gitconfig + $machine->succeed("test -e /etc/gitconfig"); + + $machine->shutdown; + ''} + ''; @@ -194,6 +233,7 @@ let , bootLoader ? "grub" # either "grub" or "systemd-boot" , grubVersion ? 2, grubDevice ? "/dev/vda", grubIdentifier ? "uuid", grubUseEfi ? false , enableOCR ? false, meta ? {} + , testCloneConfig ? false }: makeTest { inherit enableOCR; @@ -269,7 +309,8 @@ let testScript = testScriptFun { inherit bootLoader createPartitions preBootCommands - grubVersion grubDevice grubIdentifier grubUseEfi extraConfig; + grubVersion grubDevice grubIdentifier grubUseEfi extraConfig + testCloneConfig; }; }; @@ -343,6 +384,28 @@ let bootLoader = "grub"; grubUseEfi = true; }; + + clone-test-extraconfig = { extraConfig = + '' + environment.systemPackages = [ pkgs.grub2 ]; + boot.loader.grub.configurationName = "Home"; + nesting.clone = [ + { + boot.loader.grub.configurationName = lib.mkForce "Work"; + + environment.etc = { + "gitconfig".text = " + [core] + gitproxy = none for work.com + "; + }; + } + ]; + ''; + testCloneConfig = true; + }; + + in { # !!! `parted mkpart' seems to silently create overlapping partitions. @@ -352,6 +415,9 @@ in { # one big filesystem partition. simple = makeInstallerTest "simple" simple-test-config; + # Test cloned configurations with the simple grub configuration + simpleClone = makeInstallerTest "simpleClone" (simple-test-config // clone-test-extraconfig); + # Simple GPT/UEFI configuration using systemd-boot with 3 partitions: ESP, swap & root filesystem simpleUefiSystemdBoot = makeInstallerTest "simpleUefiSystemdBoot" { createPartitions = @@ -377,6 +443,9 @@ in { simpleUefiGrub = makeInstallerTest "simpleUefiGrub" simple-uefi-grub-config; + # Test cloned configurations with the uefi grub configuration + simpleUefiGrubClone = makeInstallerTest "simpleUefiGrubClone" (simple-uefi-grub-config // clone-test-extraconfig); + # Same as the previous, but now with a separate /boot partition. separateBoot = makeInstallerTest "separateBoot" { createPartitions = |