nixos/tests/chromium: Split up into subtests

This makes it easier to test just a specific channel rather than to
force testing all builds down the users/testers throat. Especially this
makes it easier to test NixOS channel upgrades only against the Chromium
stable channel instead of just removing the beta/dev channels from the
tests entirely (as done in 69ec09f38aa1f1d37baec73ebdf9cf5f21050f94).

Signed-off-by: aszlig <aszlig@redmoonstudios.org>

aszlig e45c211b 7eea91fb

Changed files
+62 -73
nixos
+1 -1
nixos/release-combined.nix
···
(all nixos.ova)
#(all nixos.tests.containers)
-
(all nixos.tests.chromium)
+
(all nixos.tests.chromium.stable)
(all nixos.tests.firefox)
(all nixos.tests.firewall)
nixos.tests.gnome3.x86_64-linux # FIXME: i686-linux
+1 -1
nixos/release.nix
···
tests.blivet = callTest tests/blivet.nix {};
tests.boot = callSubTests tests/boot.nix {};
tests.cadvisor = hydraJob (import tests/cadvisor.nix { system = "x86_64-linux"; });
-
tests.chromium = callTest tests/chromium.nix {};
+
tests.chromium = callSubTests tests/chromium.nix {};
tests.cjdns = callTest tests/cjdns.nix {};
tests.containers = callTest tests/containers.nix {};
tests.docker = hydraJob (import tests/docker.nix { system = "x86_64-linux"; });
+60 -71
nixos/tests/chromium.nix
···
-
import ./make-test.nix (
-
{ pkgs
-
, channelMap ? {
-
stable = pkgs.chromium;
-
#beta = pkgs.chromiumBeta;
-
#dev = pkgs.chromiumDev;
-
}
-
, ...
-
}: rec {
-
name = "chromium";
+
{ system ? builtins.currentSystem }:
+
+
with import ../lib/testing.nix { inherit system; };
+
with pkgs.lib;
+
+
mapAttrs (channel: chromiumPkg: makeTest rec {
+
name = "chromium-${channel}";
meta = with pkgs.stdenv.lib.maintainers; {
maintainers = [ aszlig ];
};
···
machine.imports = [ ./common/x11.nix ];
machine.virtualisation.memorySize = 2047;
+
machine.environment.systemPackages = [ chromiumPkg ];
startupHTML = pkgs.writeText "chromium-startup.html" ''
<!DOCTYPE html>
···
closeWin;
}
-
sub chromiumTest {
-
my ($channel, $pkg, $code) = @_;
-
$machine->waitForX;
+
$machine->waitForX;
-
my $url = "file://${startupHTML}";
-
my $args = "--user-data-dir=/tmp/chromium-$channel";
-
$machine->execute(
-
"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
-
windowfocus --sync
-
windowactivate --sync
-
''}");
+
my $url = "file://${startupHTML}";
+
my $args = "--user-data-dir=/tmp/chromium-${channel}";
+
$machine->execute(
+
"ulimit -c unlimited; ".
+
"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
+
windowfocus --sync
+
windowactivate --sync
+
''}");
-
createAndWaitForNewWin;
-
$machine->screenshot($channel."_emptywin");
-
closeWin;
+
createAndWaitForNewWin;
+
$machine->screenshot("empty_windows");
+
closeWin;
-
$machine->screenshot($channel."_startup_done");
+
$machine->screenshot("startup_done");
-
subtest("Chromium $channel", $code);
+
testNewWin "check sandbox", sub {
+
$machine->succeed("${xdo "type-url" ''
+
search --sync --onlyvisible --name "new tab"
+
windowfocus --sync
+
type --delay 1000 "chrome://sandbox"
+
''}");
-
$machine->shutdown;
-
}
+
$machine->succeed("${xdo "submit-url" ''
+
search --sync --onlyvisible --name "new tab"
+
windowfocus --sync
+
key --delay 1000 Return
+
''}");
-
for (${let
-
mkArray = name: pkg: "[\"${name}\", \"${pkg}\"]";
-
chanArrays = pkgs.lib.mapAttrsToList mkArray channelMap;
-
in pkgs.lib.concatStringsSep ", " chanArrays}) {
-
my ($channel, $pkg) = @$_;
-
chromiumTest $channel, $pkg, sub {
-
testNewWin "check sandbox", sub {
-
$machine->succeed("${xdo "type-url" ''
-
search --sync --onlyvisible --name "new tab"
-
windowfocus --sync
-
type --delay 1000 "chrome://sandbox"
-
''}");
+
$machine->screenshot("sandbox_info");
-
$machine->succeed("${xdo "submit-url" ''
-
search --sync --onlyvisible --name "new tab"
-
windowfocus --sync
-
key --delay 1000 Return
-
''}");
-
-
$machine->screenshot($channel."_sandbox");
+
$machine->succeed("${xdo "submit-url" ''
+
search --sync --onlyvisible --name "sandbox status"
+
windowfocus --sync
+
''}");
+
$machine->succeed("${xdo "submit-url" ''
+
key --delay 1000 Ctrl+a Ctrl+c
+
''}");
-
$machine->succeed("${xdo "submit-url" ''
-
search --sync --onlyvisible --name "sandbox status"
-
windowfocus --sync
-
''}");
-
$machine->succeed("${xdo "submit-url" ''
-
key --delay 1000 Ctrl+a Ctrl+c
-
''}");
+
my $clipboard = $machine->succeed("${pkgs.xclip}/bin/xclip -o");
+
die "sandbox not working properly: $clipboard"
+
unless $clipboard =~ /namespace sandbox.*yes/mi
+
&& $clipboard =~ /pid namespaces.*yes/mi
+
&& $clipboard =~ /network namespaces.*yes/mi
+
&& $clipboard =~ /seccomp.*sandbox.*yes/mi
+
&& $clipboard =~ /you are adequately sandboxed/mi;
+
};
-
my $clipboard = $machine->succeed("${pkgs.xclip}/bin/xclip -o");
-
die "sandbox not working properly: $clipboard"
-
unless $clipboard =~ /namespace sandbox.*yes/mi
-
&& $clipboard =~ /pid namespaces.*yes/mi
-
&& $clipboard =~ /network namespaces.*yes/mi
-
&& $clipboard =~ /seccomp.*sandbox.*yes/mi
-
&& $clipboard =~ /you are adequately sandboxed/mi;
-
};
-
};
-
}
+
$machine->shutdown;
'';
-
})
+
}) {
+
stable = pkgs.chromium;
+
beta = pkgs.chromiumBeta;
+
dev = pkgs.chromiumDev;
+
}