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
@ -48,7 +48,7 @@ in rec {
|
|||||||
(all nixos.ova)
|
(all nixos.ova)
|
||||||
|
|
||||||
#(all nixos.tests.containers)
|
#(all nixos.tests.containers)
|
||||||
(all nixos.tests.chromium)
|
(all nixos.tests.chromium.stable)
|
||||||
(all nixos.tests.firefox)
|
(all nixos.tests.firefox)
|
||||||
(all nixos.tests.firewall)
|
(all nixos.tests.firewall)
|
||||||
nixos.tests.gnome3.x86_64-linux # FIXME: i686-linux
|
nixos.tests.gnome3.x86_64-linux # FIXME: i686-linux
|
||||||
|
@ -235,7 +235,7 @@ in rec {
|
|||||||
tests.blivet = callTest tests/blivet.nix {};
|
tests.blivet = callTest tests/blivet.nix {};
|
||||||
tests.boot = callSubTests tests/boot.nix {};
|
tests.boot = callSubTests tests/boot.nix {};
|
||||||
tests.cadvisor = hydraJob (import tests/cadvisor.nix { system = "x86_64-linux"; });
|
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.cjdns = callTest tests/cjdns.nix {};
|
||||||
tests.containers = callTest tests/containers.nix {};
|
tests.containers = callTest tests/containers.nix {};
|
||||||
tests.docker = hydraJob (import tests/docker.nix { system = "x86_64-linux"; });
|
tests.docker = hydraJob (import tests/docker.nix { system = "x86_64-linux"; });
|
||||||
|
@ -1,13 +1,10 @@
|
|||||||
import ./make-test.nix (
|
{ system ? builtins.currentSystem }:
|
||||||
{ pkgs
|
|
||||||
, channelMap ? {
|
with import ../lib/testing.nix { inherit system; };
|
||||||
stable = pkgs.chromium;
|
with pkgs.lib;
|
||||||
#beta = pkgs.chromiumBeta;
|
|
||||||
#dev = pkgs.chromiumDev;
|
mapAttrs (channel: chromiumPkg: makeTest rec {
|
||||||
}
|
name = "chromium-${channel}";
|
||||||
, ...
|
|
||||||
}: rec {
|
|
||||||
name = "chromium";
|
|
||||||
meta = with pkgs.stdenv.lib.maintainers; {
|
meta = with pkgs.stdenv.lib.maintainers; {
|
||||||
maintainers = [ aszlig ];
|
maintainers = [ aszlig ];
|
||||||
};
|
};
|
||||||
@ -16,6 +13,7 @@ import ./make-test.nix (
|
|||||||
|
|
||||||
machine.imports = [ ./common/x11.nix ];
|
machine.imports = [ ./common/x11.nix ];
|
||||||
machine.virtualisation.memorySize = 2047;
|
machine.virtualisation.memorySize = 2047;
|
||||||
|
machine.environment.systemPackages = [ chromiumPkg ];
|
||||||
|
|
||||||
startupHTML = pkgs.writeText "chromium-startup.html" ''
|
startupHTML = pkgs.writeText "chromium-startup.html" ''
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
@ -105,74 +103,65 @@ import ./make-test.nix (
|
|||||||
closeWin;
|
closeWin;
|
||||||
}
|
}
|
||||||
|
|
||||||
sub chromiumTest {
|
$machine->waitForX;
|
||||||
my ($channel, $pkg, $code) = @_;
|
|
||||||
$machine->waitForX;
|
|
||||||
|
|
||||||
my $url = "file://${startupHTML}";
|
my $url = "file://${startupHTML}";
|
||||||
my $args = "--user-data-dir=/tmp/chromium-$channel";
|
my $args = "--user-data-dir=/tmp/chromium-${channel}";
|
||||||
$machine->execute(
|
$machine->execute(
|
||||||
"ulimit -c unlimited; ".
|
"ulimit -c unlimited; ".
|
||||||
"$pkg/bin/chromium $args \"$url\" & disown"
|
"chromium $args \"$url\" & disown"
|
||||||
);
|
);
|
||||||
$machine->waitForText(qr/Type to search or enter a URL to navigate/);
|
$machine->waitForText(qr/Type to search or enter a URL to navigate/);
|
||||||
$machine->waitUntilSucceeds("${xdo "check-startup" ''
|
$machine->waitUntilSucceeds("${xdo "check-startup" ''
|
||||||
search --sync --onlyvisible --name "startup done"
|
search --sync --onlyvisible --name "startup done"
|
||||||
# close first start help popup
|
# close first start help popup
|
||||||
key -delay 1000 Escape
|
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
|
windowfocus --sync
|
||||||
windowactivate --sync
|
type --delay 1000 "chrome://sandbox"
|
||||||
''}");
|
''}");
|
||||||
|
|
||||||
createAndWaitForNewWin;
|
$machine->succeed("${xdo "submit-url" ''
|
||||||
$machine->screenshot($channel."_emptywin");
|
search --sync --onlyvisible --name "new tab"
|
||||||
closeWin;
|
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
|
$machine->shutdown;
|
||||||
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;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
}
|
|
||||||
'';
|
'';
|
||||||
})
|
}) {
|
||||||
|
stable = pkgs.chromium;
|
||||||
|
beta = pkgs.chromiumBeta;
|
||||||
|
dev = pkgs.chromiumDev;
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user