From 3e6648699f15d1574f04f03f68a895a24749ee90 Mon Sep 17 00:00:00 2001 From: sternenseemann <0rpkxez4ksa01gb3typccl0i@systemli.org> Date: Mon, 5 Jul 2021 14:58:52 +0200 Subject: [PATCH 1/5] chromium: move ed and makeWrapper into nativeBuildInputs This most notably fixes cross _evaluation_ of chromium which previously would fail because makeWrapper relies on runtimeShell which is not available in the HostTarget package set. I tested that the native chromium build still works, but haven't tried cross compiling it yet. There very well may be additional errors, but at least they will be build errors, not hard to understand evaluation errors. (cherry picked from commit 524aa1c87c4cb024747930cda3a3e68c68dc362c) --- pkgs/applications/networking/browsers/chromium/default.nix | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pkgs/applications/networking/browsers/chromium/default.nix b/pkgs/applications/networking/browsers/chromium/default.nix index 14ee3290c71..535b87a87fd 100644 --- a/pkgs/applications/networking/browsers/chromium/default.nix +++ b/pkgs/applications/networking/browsers/chromium/default.nix @@ -149,9 +149,11 @@ in stdenv.mkDerivation { + "chromium${suffix}-${version}"; inherit version; - buildInputs = [ + nativeBuildInputs = [ makeWrapper ed + ]; + buildInputs = [ # needed for GSETTINGS_SCHEMAS_PATH gsettings-desktop-schemas glib gtk3 From a20f9eb0ec7f2d54243e03b09904904506dd839d Mon Sep 17 00:00:00 2001 From: Michael Weiss Date: Fri, 9 Jul 2021 11:24:16 +0200 Subject: [PATCH 2/5] nixos/tests/chromium: Fix the test for M92+ Unfortunately there are some regressions in the GPU code that cause Chromium and Google Chrome to crash, e.g.: machine # [0709/084047.890436:ERROR:process_memory_range.cc(75)] read out of range[ 30.153484] show_signal: 20 callbacks suppressed machine # [ 30.153490] traps: chrome[1036] trap invalid opcode ip:55af03357b29 sp:7ffeaa69ad10 error:0 in chrome[55aefe7a4000+81ec000] machine # machine # [0709/084047.955039:ERROR:file_io_posix.cc(144)] open /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq: No such file or directory (2) machine # [0709/084047.955078:ERROR:file_io_posix.cc(144)] open /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq: No such file or directory (2) machine # [ 30.126905] systemd[1]: Created slice system-systemd\x2dcoredump.slice. machine # [ 30.137012] systemd[1]: Started Process Core Dump (PID 1038/UID 0). machine # [ 30.571987] systemd-coredump[1039]: Process 1036 (chrome) of user 1000 dumped core. machine # [992:1021:0709/084048.501937:ERROR:gpu_process_host.cc(995)] GPU process exited unexpectedly: exit_code=132 machine # [ 30.594747] systemd[1]: systemd-coredump@0-1038-0.service: Succeeded. Hopefully this'll be fixed upstream before the final release (there are bug reports for it) but for the meantime we have to launch the beta and dev versions with "--use-gl=angle --use-angle=swiftshader". (cherry picked from commit f9645002a2d8615fd608bfdef4f924481dca391e) --- nixos/tests/chromium.nix | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/nixos/tests/chromium.nix b/nixos/tests/chromium.nix index 60ecf986d6e..c17d1953894 100644 --- a/nixos/tests/chromium.nix +++ b/nixos/tests/chromium.nix @@ -63,17 +63,25 @@ mapAttrs (channel: chromiumPkg: makeTest rec { return "su - ${user} -c " + shlex.quote(cmd) - def get_browser_binary(): - """Returns the name of the browser binary.""" + def get_browser_call(): + """Returns the name of the browser binary as well as CLI options.""" + # Determine the name of the binary: pname = "${getName chromiumPkg.name}" if pname.find("chromium") != -1: - return "chromium" # Same name for all channels and ungoogled-chromium - if pname == "google-chrome": - return "google-chrome-stable" - if pname == "google-chrome-dev": - return "google-chrome-unstable" - # For google-chrome-beta and as fallback: - return pname + binary = "chromium" # Same name for all channels and ungoogled-chromium + elif pname == "google-chrome": + binary = "google-chrome-stable" + elif pname == "google-chrome-dev": + binary = "google-chrome-unstable" + else: # For google-chrome-beta and as fallback: + binary = pname + # Add optional CLI options: + options = "" + major_version = "${versions.major (getVersion chromiumPkg.name)}" + if major_version > "91": + # To avoid a GPU crash: + options += "--use-gl=angle --use-angle=swiftshader" + return f"{binary} {options}" def create_new_win(): @@ -135,9 +143,9 @@ mapAttrs (channel: chromiumPkg: makeTest rec { machine.wait_for_x() url = "file://${startupHTML}" - machine.succeed(ru(f'ulimit -c unlimited; "{get_browser_binary()}" "{url}" & disown')) + machine.succeed(ru(f'ulimit -c unlimited; {get_browser_call()} "{url}" & disown')) - if get_browser_binary().startswith("google-chrome"): + if get_browser_call().startswith("google-chrome"): # Need to click away the first window: machine.wait_for_text("Make Google Chrome the default browser") machine.screenshot("google_chrome_default_browser_prompt") From 90e44d2f1cf2bf73555ef1fac733b649175fd835 Mon Sep 17 00:00:00 2001 From: Michael Weiss Date: Fri, 9 Jul 2021 19:04:04 +0200 Subject: [PATCH 3/5] nixos/tests/chromium: Refactor launching the browser process It should now be more flexible and less error-prone. (cherry picked from commit 8c52061b1fce2036b70836e5dcdfcf4b702dd405) --- nixos/tests/chromium.nix | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/nixos/tests/chromium.nix b/nixos/tests/chromium.nix index c17d1953894..06d92cd0c03 100644 --- a/nixos/tests/chromium.nix +++ b/nixos/tests/chromium.nix @@ -63,8 +63,8 @@ mapAttrs (channel: chromiumPkg: makeTest rec { return "su - ${user} -c " + shlex.quote(cmd) - def get_browser_call(): - """Returns the name of the browser binary as well as CLI options.""" + def launch_browser(): + """Launches the web browser with the correct options.""" # Determine the name of the binary: pname = "${getName chromiumPkg.name}" if pname.find("chromium") != -1: @@ -76,12 +76,19 @@ mapAttrs (channel: chromiumPkg: makeTest rec { else: # For google-chrome-beta and as fallback: binary = pname # Add optional CLI options: - options = "" + options = [] major_version = "${versions.major (getVersion chromiumPkg.name)}" if major_version > "91": # To avoid a GPU crash: - options += "--use-gl=angle --use-angle=swiftshader" - return f"{binary} {options}" + options += ["--use-gl=angle", "--use-angle=swiftshader"] + options.append("file://${startupHTML}") + # Launch the process: + machine.succeed(ru(f'ulimit -c unlimited; {binary} {shlex.join(options)} & disown')) + if binary.startswith("google-chrome"): + # Need to click away the first window: + machine.wait_for_text("Make Google Chrome the default browser") + machine.screenshot("google_chrome_default_browser_prompt") + machine.send_key("ret") def create_new_win(): @@ -142,14 +149,7 @@ mapAttrs (channel: chromiumPkg: makeTest rec { machine.wait_for_x() - url = "file://${startupHTML}" - machine.succeed(ru(f'ulimit -c unlimited; {get_browser_call()} "{url}" & disown')) - - if get_browser_call().startswith("google-chrome"): - # Need to click away the first window: - machine.wait_for_text("Make Google Chrome the default browser") - machine.screenshot("google_chrome_default_browser_prompt") - machine.send_key("ret") + launch_browser() machine.wait_for_text("startup done") machine.wait_until_succeeds( From 24599a5ba600906d98f1266083024cb68522a6c1 Mon Sep 17 00:00:00 2001 From: Michael Weiss Date: Sat, 10 Jul 2021 10:25:38 +0200 Subject: [PATCH 4/5] nixos/tests/chromium: Print the content of chrome://{sandbox,gpu} This can be very useful when running the test headless or e.g. when looking at Hydra logs. Especially the chrome://gpu content contains a lot of interesting information. I also decided to refactor the test_new_win() function to avoid duplicate code and rely less on xdo. (cherry picked from commit c33015a0c94777261ef054a3d7dacd53e744ceea) --- nixos/tests/chromium.nix | 73 +++++++++++++++------------------------- 1 file changed, 27 insertions(+), 46 deletions(-) diff --git a/nixos/tests/chromium.nix b/nixos/tests/chromium.nix index 06d92cd0c03..d2a8f276f12 100644 --- a/nixos/tests/chromium.nix +++ b/nixos/tests/chromium.nix @@ -30,7 +30,10 @@ mapAttrs (channel: chromiumPkg: makeTest rec { machine.imports = [ ./common/user-account.nix ./common/x11.nix ]; machine.virtualisation.memorySize = 2047; machine.test-support.displayManager.auto.user = user; - machine.environment.systemPackages = [ chromiumPkg ]; + machine.environment = { + systemPackages = [ chromiumPkg ]; + variables."XAUTHORITY" = "/home/alice/.Xauthority"; + }; startupHTML = pkgs.writeText "chromium-startup.html" '' @@ -139,10 +142,25 @@ mapAttrs (channel: chromiumPkg: makeTest rec { @contextmanager - def test_new_win(description): + def test_new_win(description, url, window_name): create_new_win() + machine.wait_for_window("New Tab") + machine.send_chars(f"{url}\n") + machine.wait_for_window(window_name) + machine.screenshot(description) + machine.succeed( + ru( + "${xdo "copy-all" '' + key --delay 1000 Ctrl+a Ctrl+c + ''}" + ) + ) + clipboard = machine.succeed( + ru("${pkgs.xclip}/bin/xclip -o") + ) + print(f"{description} window content:\n{clipboard}") with machine.nested(description): - yield + yield clipboard # Close the newly created window: machine.send_key("ctrl-w") @@ -172,49 +190,7 @@ mapAttrs (channel: chromiumPkg: makeTest rec { machine.screenshot("startup_done") - with test_new_win("check sandbox"): - machine.succeed( - ru( - "${xdo "type-url" '' - search --sync --onlyvisible --name "New Tab" - windowfocus --sync - type --delay 1000 "chrome://sandbox" - ''}" - ) - ) - - machine.succeed( - ru( - "${xdo "submit-url" '' - search --sync --onlyvisible --name "New Tab" - windowfocus --sync - key --delay 1000 Return - ''}" - ) - ) - - machine.screenshot("sandbox_info") - - machine.succeed( - ru( - "${xdo "find-window" '' - search --sync --onlyvisible --name "Sandbox Status" - windowfocus --sync - ''}" - ) - ) - machine.succeed( - ru( - "${xdo "copy-sandbox-info" '' - key --delay 1000 Ctrl+a Ctrl+c - ''}" - ) - ) - - clipboard = machine.succeed( - ru("${pkgs.xclip}/bin/xclip -o") - ) - + with test_new_win("sandbox_info", "chrome://sandbox", "Sandbox Status") as clipboard: filters = [ "layer 1 sandbox.*namespace", "pid namespaces.*yes", @@ -261,6 +237,11 @@ mapAttrs (channel: chromiumPkg: makeTest rec { machine.screenshot("after_copy_from_chromium") + + with test_new_win("gpu_info", "chrome://gpu", "chrome://gpu"): + pass + + machine.shutdown() ''; }) channelMap From 2eaf9b409a9f71f425ffe66faf5fa6ecd0bddbc1 Mon Sep 17 00:00:00 2001 From: Michael Weiss Date: Fri, 23 Jul 2021 10:03:14 +0200 Subject: [PATCH 5/5] chromium: Check the text rendering This should catch regressions like #131074 in the future. In that case a glibc update caused a regression that caused most of the text to become invisible (just not the "Web Store" we've already been checking for). (cherry picked from commit 11400dcd65ed95292d7ac7cb30912e15ec4cf8e1) --- nixos/tests/chromium.nix | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/nixos/tests/chromium.nix b/nixos/tests/chromium.nix index d2a8f276f12..752c8bef31d 100644 --- a/nixos/tests/chromium.nix +++ b/nixos/tests/chromium.nix @@ -239,7 +239,8 @@ mapAttrs (channel: chromiumPkg: makeTest rec { with test_new_win("gpu_info", "chrome://gpu", "chrome://gpu"): - pass + # To check the text rendering (catches regressions like #131074): + machine.wait_for_text("Graphics Feature Status") machine.shutdown()