diff options
author | Eelco Dolstra <eelco.dolstra@logicblox.com> | 2015-05-22 15:57:36 +0200 |
---|---|---|
committer | Eelco Dolstra <eelco.dolstra@logicblox.com> | 2015-05-22 15:57:36 +0200 |
commit | 09d06f5ffd867afc72d5ca6786f73aed2b80e207 (patch) | |
tree | 0b39699b6fae1ea7f5e6b40b2214c901eb9a578b /nixos/tests | |
parent | f106125f77ba2b3588f95ef58667763042f808c9 (diff) | |
parent | a49afdf1743436ac07c9be9da1d27ea5461af571 (diff) | |
download | nixlib-09d06f5ffd867afc72d5ca6786f73aed2b80e207.tar nixlib-09d06f5ffd867afc72d5ca6786f73aed2b80e207.tar.gz nixlib-09d06f5ffd867afc72d5ca6786f73aed2b80e207.tar.bz2 nixlib-09d06f5ffd867afc72d5ca6786f73aed2b80e207.tar.lz nixlib-09d06f5ffd867afc72d5ca6786f73aed2b80e207.tar.xz nixlib-09d06f5ffd867afc72d5ca6786f73aed2b80e207.tar.zst nixlib-09d06f5ffd867afc72d5ca6786f73aed2b80e207.zip |
Merge remote-tracking branch 'origin/master' into systemd-219
Conflicts: pkgs/development/libraries/libseccomp/default.nix
Diffstat (limited to 'nixos/tests')
-rw-r--r-- | nixos/tests/chromium.nix | 8 | ||||
-rw-r--r-- | nixos/tests/common/user-account.nix | 5 | ||||
-rw-r--r-- | nixos/tests/gnome3_16.nix | 34 | ||||
-rw-r--r-- | nixos/tests/installer.nix | 66 | ||||
-rw-r--r-- | nixos/tests/printing.nix | 4 |
5 files changed, 68 insertions, 49 deletions
diff --git a/nixos/tests/chromium.nix b/nixos/tests/chromium.nix index 026433fc7ee9..2241bc9c3bca 100644 --- a/nixos/tests/chromium.nix +++ b/nixos/tests/chromium.nix @@ -9,6 +9,8 @@ import ./make-test.nix ( }: rec { name = "chromium"; + enableOCR = true; + machine.imports = [ ./common/x11.nix ]; machine.virtualisation.memorySize = 1024; @@ -106,15 +108,11 @@ import ./make-test.nix ( "ulimit -c unlimited; ". "$pkg/bin/chromium $args \"$url\" & disown" ); + $machine->waitForText(qr/Type to search or enter a URL to navigate/); $machine->waitUntilSucceeds("${xdo "check-startup" '' search --sync --onlyvisible --name "startup done" # close first start help popup key -delay 1000 Escape - # XXX: This is to make sure the popup is closed, but we better do - # screenshots to detect visual changes. - key -delay 2000 Escape - key -delay 3000 Escape - key -delay 4000 Escape windowfocus --sync windowactivate --sync ''}"); diff --git a/nixos/tests/common/user-account.nix b/nixos/tests/common/user-account.nix index aa3a0b82bcde..ded8275000af 100644 --- a/nixos/tests/common/user-account.nix +++ b/nixos/tests/common/user-account.nix @@ -1,10 +1,9 @@ -{ pkgs, ... }: +{ lib, ... }: -{ users.extraUsers = pkgs.lib.singleton +{ users.extraUsers = lib.singleton { isNormalUser = true; name = "alice"; description = "Alice Foobar"; password = "foobar"; - uid = 1000; }; } diff --git a/nixos/tests/gnome3_16.nix b/nixos/tests/gnome3_16.nix deleted file mode 100644 index 23a66aba50c5..000000000000 --- a/nixos/tests/gnome3_16.nix +++ /dev/null @@ -1,34 +0,0 @@ -import ./make-test.nix { - name = "gnome3"; - - machine = - { config, pkgs, ... }: - - { imports = [ ./common/user-account.nix ]; - - services.xserver.enable = true; - - services.xserver.displayManager.auto.enable = true; - services.xserver.displayManager.auto.user = "alice"; - services.xserver.desktopManager.gnome3.enable = true; - - environment.gnome3.packageSet = pkgs.gnome3_16; - - virtualisation.memorySize = 512; - }; - - testScript = - '' - $machine->waitForX; - $machine->sleep(15); - - # Check that logging in has given the user ownership of devices. - $machine->succeed("getfacl /dev/snd/timer | grep -q alice"); - - $machine->succeed("su - alice -c 'DISPLAY=:0.0 gnome-terminal &'"); - $machine->waitForWindow(qr/Terminal/); - $machine->sleep(20); - $machine->screenshot("screen"); - ''; - -} diff --git a/nixos/tests/installer.nix b/nixos/tests/installer.nix index af87705b9279..64f98141cc0e 100644 --- a/nixos/tests/installer.nix +++ b/nixos/tests/installer.nix @@ -45,7 +45,8 @@ let # The configuration to install. makeConfig = { testChannel, grubVersion, grubDevice, grubIdentifier - , readOnly ? true, forceGrubReinstallCount ? 0 }: + , extraConfig, readOnly ? true, forceGrubReinstallCount ? 0 + }: pkgs.writeText "configuration.nix" '' { config, lib, pkgs, modulesPath, ... }: @@ -70,6 +71,7 @@ let environment.systemPackages = [ ${optionalString testChannel "pkgs.rlwrap"} ]; nix.binaryCaches = [ http://cache.nixos.org/ ]; + ${replaceChars ["\n"] ["\n "] extraConfig} } ''; @@ -106,7 +108,9 @@ let # disk, and then reboot from the hard disk. It's parameterized with # a test script fragment `createPartitions', which must create # partitions and filesystems. - testScriptFun = { createPartitions, testChannel, grubVersion, grubDevice, grubIdentifier }: + testScriptFun = { createPartitions, testChannel, grubVersion, grubDevice + , grubIdentifier, preBootCommands, extraConfig + }: let # FIXME: OVMF doesn't boot from virtio http://www.mail-archive.com/edk2-devel@lists.sourceforge.net/msg01501.html iface = if grubVersion == 1 then "scsi" else "virtio"; @@ -172,7 +176,7 @@ let $machine->succeed("cat /mnt/etc/nixos/hardware-configuration.nix >&2"); $machine->copyFileFromHost( - "${ makeConfig { inherit testChannel grubVersion grubDevice grubIdentifier; } }", + "${ makeConfig { inherit testChannel grubVersion grubDevice grubIdentifier extraConfig; } }", "/mnt/etc/nixos/configuration.nix"); # Perform the installation. @@ -190,6 +194,9 @@ let # Now see if we can boot the installation. $machine = createMachine({ ${hdFlags} qemuFlags => "${qemuFlags}" }); + # For example to enter LUKS passphrase + ${preBootCommands} + # Did /boot get mounted? $machine->waitForUnit("local-fs.target"); @@ -210,7 +217,7 @@ let # We need to a writable nix-store on next boot $machine->copyFileFromHost( - "${ makeConfig { inherit testChannel grubVersion grubDevice grubIdentifier; readOnly = false; forceGrubReinstallCount = 1; } }", + "${ makeConfig { inherit testChannel grubVersion grubDevice grubIdentifier extraConfig; readOnly = false; forceGrubReinstallCount = 1; } }", "/etc/nixos/configuration.nix"); # Check whether nixos-rebuild works. @@ -225,9 +232,10 @@ let # Check whether a writable store build works $machine = createMachine({ ${hdFlags} qemuFlags => "${qemuFlags}" }); + ${preBootCommands} $machine->waitForUnit("multi-user.target"); $machine->copyFileFromHost( - "${ makeConfig { inherit testChannel grubVersion grubDevice grubIdentifier; readOnly = false; forceGrubReinstallCount = 2; } }", + "${ makeConfig { inherit testChannel grubVersion grubDevice grubIdentifier extraConfig; readOnly = false; forceGrubReinstallCount = 2; } }", "/etc/nixos/configuration.nix"); $machine->succeed("nixos-rebuild boot >&2"); $machine->shutdown; @@ -235,19 +243,25 @@ let # And just to be sure, check that the machine still boots after # "nixos-rebuild switch". $machine = createMachine({ ${hdFlags} qemuFlags => "${qemuFlags}" }); + ${preBootCommands} $machine->waitForUnit("network.target"); $machine->shutdown; ''; makeInstallerTest = name: - { createPartitions, testChannel ? false, grubVersion ? 2, grubDevice ? "/dev/vda", grubIdentifier ? "uuid" }: + { createPartitions, preBootCommands ? "", extraConfig ? "" + , testChannel ? false, grubVersion ? 2, grubDevice ? "/dev/vda" + , grubIdentifier ? "uuid", enableOCR ? false + }: makeTest { inherit iso; name = "installer-" + name; nodes = if testChannel then { inherit webserver; } else { }; + inherit enableOCR; testScript = testScriptFun { - inherit createPartitions testChannel grubVersion grubDevice grubIdentifier; + inherit createPartitions preBootCommands testChannel grubVersion + grubDevice grubIdentifier extraConfig; }; }; @@ -321,6 +335,44 @@ in { ''; }; + # Boot off an encrypted root partition + luksroot = makeInstallerTest "luksroot" + { createPartitions = '' + $machine->succeed( + "parted /dev/vda mklabel msdos", + "parted /dev/vda -- mkpart primary ext2 1M 50MB", # /boot + "parted /dev/vda -- mkpart primary linux-swap 50M 1024M", + "parted /dev/vda -- mkpart primary 1024M -1s", # LUKS + "udevadm settle", + "mkswap /dev/vda2 -L swap", + "swapon -L swap", + "modprobe dm_mod dm_crypt", + "echo -n supersecret | cryptsetup luksFormat -q /dev/vda3 -", + "echo -n supersecret | cryptsetup luksOpen --key-file - /dev/vda3 cryptroot", + "mkfs.ext3 -L nixos /dev/mapper/cryptroot", + "mount LABEL=nixos /mnt", + "mkfs.ext3 -L boot /dev/vda1", + "mkdir -p /mnt/boot", + "mount LABEL=boot /mnt/boot", + ); + ''; + # XXX: Currently, generate-config doesn't detect LUKS yet. + extraConfig = '' + boot.kernelParams = lib.mkAfter [ "console=tty0" ]; + boot.initrd.luks.devices = lib.singleton { + name = "cryptroot"; + device = "/dev/vda3"; + preLVM = true; + }; + ''; + enableOCR = true; + preBootCommands = '' + $machine->start; + $machine->waitForText(qr/Enter passphrase/); + $machine->sendChars("supersecret\n"); + ''; + }; + swraid = makeInstallerTest "swraid" { createPartitions = '' diff --git a/nixos/tests/printing.nix b/nixos/tests/printing.nix index 708ff5391570..1e3a0057c657 100644 --- a/nixos/tests/printing.nix +++ b/nixos/tests/printing.nix @@ -34,6 +34,7 @@ import ./make-test.nix ({pkgs, ... }: { # Make sure that cups is up on both sides. $server->waitForUnit("cups.service"); $client->waitForUnit("cups.service"); + $client->sleep(10); # wait until cups is fully initialized $client->succeed("lpstat -r") =~ /scheduler is running/ or die; $client->succeed("lpstat -H") =~ "/var/run/cups/cups.sock" or die; $client->succeed("curl --fail http://localhost:631/"); @@ -67,6 +68,7 @@ import ./make-test.nix ({pkgs, ... }: { # Print the file on the client. $client->succeed("lp $file"); + $client->sleep(10); $client->succeed("lpq") =~ /active.*root.*$fn/ or die; # Ensure that a raw PCL file appeared in the server's queue @@ -74,11 +76,13 @@ import ./make-test.nix ({pkgs, ... }: { # course, since there is no actual USB printer attached, the # file will stay in the queue forever. $server->waitForFile("/var/spool/cups/d00001-001"); + $server->sleep(10); $server->succeed("lpq -a") =~ /$fn/ or die; # Delete the job on the client. It should disappear on the # server as well. $client->succeed("lprm"); + $client->sleep(10); $client->succeed("lpq -a") =~ /no entries/; Machine::retry sub { return 1 if $server->succeed("lpq -a") =~ /no entries/; |