git.iko.soy/typeable/nixpkgs
on master help sign in
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>

commite45c211b50c6f473e3d92d29e1a8426ec4579f05 authoraszlig <aszlig@redmoonstudios.org> dateTue 1 Mar 2016, 00:20 (11 years ago) parent7eea91f
3 files changed+64−75
nixos/release-combined.nix+1−1 nixos/release.nix+1−1 nixos/tests/chromium.nix+62−73
nixos/release-combined.nix+1−1
@@ -48,7 +48,7 @@ in rec {
4848 (all nixos.ova)
4949
5050 #(all nixos.tests.containers)
51− (all nixos.tests.chromium)
51+ (all nixos.tests.chromium.stable)
5252 (all nixos.tests.firefox)
5353 (all nixos.tests.firewall)
5454 nixos.tests.gnome3.x86_64-linux # FIXME: i686-linux
nixos/release.nix+1−1
@@ -235,7 +235,7 @@ in rec {
235235 tests.blivet = callTest tests/blivet.nix {};
236236 tests.boot = callSubTests tests/boot.nix {};
237237 tests.cadvisor = hydraJob (import tests/cadvisor.nix { system = "x86_64-linux"; });
238− tests.chromium = callTest tests/chromium.nix {};
238+ tests.chromium = callSubTests tests/chromium.nix {};
239239 tests.cjdns = callTest tests/cjdns.nix {};
240240 tests.containers = callTest tests/containers.nix {};
241241 tests.docker = hydraJob (import tests/docker.nix { system = "x86_64-linux"; });
nixos/tests/chromium.nix+62−73
@@ -1,13 +1,10 @@
1−import ./make-test.nix (
2−{ pkgs
3−, channelMap ? {
4− stable = pkgs.chromium;
5− #beta = pkgs.chromiumBeta;
6− #dev = pkgs.chromiumDev;
7− }
8−, ...
9−}: rec {
10− name = "chromium";
1+{ system ? builtins.currentSystem }:
2+
3+with import ../lib/testing.nix { inherit system; };
4+with pkgs.lib;
5+
6+mapAttrs (channel: chromiumPkg: makeTest rec {
7+ name = "chromium-${channel}";
118 meta = with pkgs.stdenv.lib.maintainers; {
129 maintainers = [ aszlig ];
1310 };
@@ -16,6 +13,7 @@ import ./make-test.nix (
1613
1714 machine.imports = [ ./common/x11.nix ];
1815 machine.virtualisation.memorySize = 2047;
16+ machine.environment.systemPackages = [ chromiumPkg ];
1917
2018 startupHTML = pkgs.writeText "chromium-startup.html" ''
2119 <!DOCTYPE html>
@@ -105,74 +103,65 @@ import ./make-test.nix (
105103 closeWin;
106104 }
107105
108− sub chromiumTest {
109− my ($channel, $pkg, $code) = @_;
110− $machine->waitForX;
111−
112− my $url = "file://${startupHTML}";
113− my $args = "--user-data-dir=/tmp/chromium-$channel";
114− $machine->execute(
115− "ulimit -c unlimited; ".
116− "$pkg/bin/chromium $args \"$url\" & disown"
117− );
118− $machine->waitForText(qr/Type to search or enter a URL to navigate/);
119− $machine->waitUntilSucceeds("${xdo "check-startup" ''
120− search --sync --onlyvisible --name "startup done"
121− # close first start help popup
122− key -delay 1000 Escape
106+ $machine->waitForX;
107+
108+ my $url = "file://${startupHTML}";
109+ my $args = "--user-data-dir=/tmp/chromium-${channel}";
110+ $machine->execute(
111+ "ulimit -c unlimited; ".
112+ "chromium $args \"$url\" & disown"
113+ );
114+ $machine->waitForText(qr/Type to search or enter a URL to navigate/);
115+ $machine->waitUntilSucceeds("${xdo "check-startup" ''
116+ search --sync --onlyvisible --name "startup done"
117+ # close first start help popup
118+ key -delay 1000 Escape
119+ windowfocus --sync
120+ windowactivate --sync
121+ ''}");
122+
123+ createAndWaitForNewWin;
124+ $machine->screenshot("empty_windows");
125+ closeWin;
126+
127+ $machine->screenshot("startup_done");
128+
129+ testNewWin "check sandbox", sub {
130+ $machine->succeed("${xdo "type-url" ''
131+ search --sync --onlyvisible --name "new tab"
123132 windowfocus --sync
124− windowactivate --sync
133+ type --delay 1000 "chrome://sandbox"
125134 ''}");
126135
127− createAndWaitForNewWin;
128− $machine->screenshot($channel."_emptywin");
129− closeWin;
130−
131− $machine->screenshot($channel."_startup_done");
132−
133− subtest("Chromium $channel", $code);
134−
135− $machine->shutdown;
136− }
137−
138− for (${let
139− mkArray = name: pkg: "[\"${name}\", \"${pkg}\"]";
140− chanArrays = pkgs.lib.mapAttrsToList mkArray channelMap;
141− in pkgs.lib.concatStringsSep ", " chanArrays}) {
142− my ($channel, $pkg) = @$_;
143− chromiumTest $channel, $pkg, sub {
144− testNewWin "check sandbox", sub {
145− $machine->succeed("${xdo "type-url" ''
146− search --sync --onlyvisible --name "new tab"
147− windowfocus --sync
148− type --delay 1000 "chrome://sandbox"
149− ''}");
136+ $machine->succeed("${xdo "submit-url" ''
137+ search --sync --onlyvisible --name "new tab"
138+ windowfocus --sync
139+ key --delay 1000 Return
140+ ''}");
150141
151− $machine->succeed("${xdo "submit-url" ''
152− search --sync --onlyvisible --name "new tab"
153− windowfocus --sync
154− key --delay 1000 Return
155− ''}");
142+ $machine->screenshot("sandbox_info");
156143
157− $machine->screenshot($channel."_sandbox");
144+ $machine->succeed("${xdo "submit-url" ''
145+ search --sync --onlyvisible --name "sandbox status"
146+ windowfocus --sync
147+ ''}");
148+ $machine->succeed("${xdo "submit-url" ''
149+ key --delay 1000 Ctrl+a Ctrl+c
150+ ''}");
158151
159− $machine->succeed("${xdo "submit-url" ''
160− search --sync --onlyvisible --name "sandbox status"
161− windowfocus --sync
162− ''}");
163− $machine->succeed("${xdo "submit-url" ''
164− key --delay 1000 Ctrl+a Ctrl+c
165− ''}");
152+ my $clipboard = $machine->succeed("${pkgs.xclip}/bin/xclip -o");
153+ die "sandbox not working properly: $clipboard"
154+ unless $clipboard =~ /namespace sandbox.*yes/mi
155+ && $clipboard =~ /pid namespaces.*yes/mi
156+ && $clipboard =~ /network namespaces.*yes/mi
157+ && $clipboard =~ /seccomp.*sandbox.*yes/mi
158+ && $clipboard =~ /you are adequately sandboxed/mi;
159+ };
166160
167− my $clipboard = $machine->succeed("${pkgs.xclip}/bin/xclip -o");
168− die "sandbox not working properly: $clipboard"
169− unless $clipboard =~ /namespace sandbox.*yes/mi
170− && $clipboard =~ /pid namespaces.*yes/mi
171− && $clipboard =~ /network namespaces.*yes/mi
172− && $clipboard =~ /seccomp.*sandbox.*yes/mi
173− && $clipboard =~ /you are adequately sandboxed/mi;
174− };
175− };
176− }
161+ $machine->shutdown;
177162 '';
178−})
163+}) {
164+ stable = pkgs.chromium;
165+ beta = pkgs.chromiumBeta;
166+ dev = pkgs.chromiumDev;
167+}