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 69ec09f38a
).
Signed-off-by: aszlig <aszlig@redmoonstudios.org>
This commit is contained in:
parent
7eea91fbc0
commit
e45c211b50
3 changed files with 63 additions and 74 deletions
|
@ -48,7 +48,7 @@ in rec {
|
|||
(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
|
||||
|
|
|
@ -235,7 +235,7 @@ in rec {
|
|||
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"; });
|
||||
|
|
|
@ -1,13 +1,10 @@
|
|||
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 ];
|
||||
};
|
||||
|
@ -16,6 +13,7 @@ import ./make-test.nix (
|
|||
|
||||
machine.imports = [ ./common/x11.nix ];
|
||||
machine.virtualisation.memorySize = 2047;
|
||||
machine.environment.systemPackages = [ chromiumPkg ];
|
||||
|
||||
startupHTML = pkgs.writeText "chromium-startup.html" ''
|
||||
<!DOCTYPE html>
|
||||
|
@ -105,74 +103,65 @@ import ./make-test.nix (
|
|||
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
|
||||
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("empty_windows");
|
||||
closeWin;
|
||||
|
||||
$machine->screenshot("startup_done");
|
||||
|
||||
testNewWin "check sandbox", sub {
|
||||
$machine->succeed("${xdo "type-url" ''
|
||||
search --sync --onlyvisible --name "new tab"
|
||||
windowfocus --sync
|
||||
windowactivate --sync
|
||||
type --delay 1000 "chrome://sandbox"
|
||||
''}");
|
||||
|
||||
createAndWaitForNewWin;
|
||||
$machine->screenshot($channel."_emptywin");
|
||||
closeWin;
|
||||
$machine->succeed("${xdo "submit-url" ''
|
||||
search --sync --onlyvisible --name "new tab"
|
||||
windowfocus --sync
|
||||
key --delay 1000 Return
|
||||
''}");
|
||||
|
||||
$machine->screenshot($channel."_startup_done");
|
||||
$machine->screenshot("sandbox_info");
|
||||
|
||||
subtest("Chromium $channel", $code);
|
||||
$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->shutdown;
|
||||
}
|
||||
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;
|
||||
};
|
||||
|
||||
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->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
|
||||
''}");
|
||||
|
||||
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;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue