2021-12-23 20:19:41 +01:00
|
|
|
import ./make-test-python.nix ({ pkgs, lib, ... }:
|
nixos/tests/sway: init
This adds a basic test for Sway. Because Sway is an important part of
the Wayland ecosystem, is stable, and has few dependencies this test
should also be suitable for testing core packages it depends on (e.g.
wayland, wayland-protocols, wlroots, xwayland, mesa, libglvnd, libdrm,
and soon libseat).
The test is modeled after the suggested way of using Sway, i.e. logging
in via a virtual console (tty1) and copying the configuration from
/etc/sway/config (we replace Mod4 (the GNU/Tux key - you've replaced
that evil logo, right? :D) with Mod1 (Alt key) because QEMU monitor's
sendkey command doesn't support the former).
The shell aliases are used to make the sendkey log output shorter.
Co-authored-by: Patrick Hilhorst <git@hilhorst.be>
2021-05-01 22:24:28 +02:00
|
|
|
|
|
|
|
{
|
|
|
|
name = "sway";
|
|
|
|
meta = {
|
|
|
|
maintainers = with lib.maintainers; [ primeos synthetica ];
|
|
|
|
};
|
|
|
|
|
|
|
|
machine = { config, ... }: {
|
|
|
|
# Automatically login on tty1 as a normal user:
|
|
|
|
imports = [ ./common/user-account.nix ];
|
|
|
|
services.getty.autologinUser = "alice";
|
|
|
|
|
|
|
|
environment = {
|
|
|
|
# For glinfo and wayland-info:
|
2021-12-23 20:19:41 +01:00
|
|
|
systemPackages = with pkgs; [ mesa-demos wayland-utils alacritty ];
|
nixos/tests/sway: init
This adds a basic test for Sway. Because Sway is an important part of
the Wayland ecosystem, is stable, and has few dependencies this test
should also be suitable for testing core packages it depends on (e.g.
wayland, wayland-protocols, wlroots, xwayland, mesa, libglvnd, libdrm,
and soon libseat).
The test is modeled after the suggested way of using Sway, i.e. logging
in via a virtual console (tty1) and copying the configuration from
/etc/sway/config (we replace Mod4 (the GNU/Tux key - you've replaced
that evil logo, right? :D) with Mod1 (Alt key) because QEMU monitor's
sendkey command doesn't support the former).
The shell aliases are used to make the sendkey log output shorter.
Co-authored-by: Patrick Hilhorst <git@hilhorst.be>
2021-05-01 22:24:28 +02:00
|
|
|
# Use a fixed SWAYSOCK path (for swaymsg):
|
2021-06-24 19:57:07 +02:00
|
|
|
variables = {
|
|
|
|
"SWAYSOCK" = "/tmp/sway-ipc.sock";
|
2021-12-23 20:19:41 +01:00
|
|
|
# TODO: Investigate if we can get hardware acceleration to work (via
|
|
|
|
# virtio-gpu and Virgil). We currently have to use the Pixman software
|
|
|
|
# renderer since the GLES2 renderer doesn't work inside the VM (even
|
|
|
|
# with WLR_RENDERER_ALLOW_SOFTWARE):
|
|
|
|
# "WLR_RENDERER_ALLOW_SOFTWARE" = "1";
|
|
|
|
"WLR_RENDERER" = "pixman";
|
2021-06-24 19:57:07 +02:00
|
|
|
};
|
nixos/tests/sway: init
This adds a basic test for Sway. Because Sway is an important part of
the Wayland ecosystem, is stable, and has few dependencies this test
should also be suitable for testing core packages it depends on (e.g.
wayland, wayland-protocols, wlroots, xwayland, mesa, libglvnd, libdrm,
and soon libseat).
The test is modeled after the suggested way of using Sway, i.e. logging
in via a virtual console (tty1) and copying the configuration from
/etc/sway/config (we replace Mod4 (the GNU/Tux key - you've replaced
that evil logo, right? :D) with Mod1 (Alt key) because QEMU monitor's
sendkey command doesn't support the former).
The shell aliases are used to make the sendkey log output shorter.
Co-authored-by: Patrick Hilhorst <git@hilhorst.be>
2021-05-01 22:24:28 +02:00
|
|
|
# For convenience:
|
|
|
|
shellAliases = {
|
2021-12-23 20:19:41 +01:00
|
|
|
test-x11 = "glinfo | tee /tmp/test-x11.out && touch /tmp/test-x11-exit-ok";
|
nixos/tests/sway: init
This adds a basic test for Sway. Because Sway is an important part of
the Wayland ecosystem, is stable, and has few dependencies this test
should also be suitable for testing core packages it depends on (e.g.
wayland, wayland-protocols, wlroots, xwayland, mesa, libglvnd, libdrm,
and soon libseat).
The test is modeled after the suggested way of using Sway, i.e. logging
in via a virtual console (tty1) and copying the configuration from
/etc/sway/config (we replace Mod4 (the GNU/Tux key - you've replaced
that evil logo, right? :D) with Mod1 (Alt key) because QEMU monitor's
sendkey command doesn't support the former).
The shell aliases are used to make the sendkey log output shorter.
Co-authored-by: Patrick Hilhorst <git@hilhorst.be>
2021-05-01 22:24:28 +02:00
|
|
|
test-wayland = "wayland-info | tee /tmp/test-wayland.out && touch /tmp/test-wayland-exit-ok";
|
|
|
|
};
|
2021-12-23 20:19:41 +01:00
|
|
|
|
|
|
|
# To help with OCR:
|
|
|
|
etc."xdg/foot/foot.ini".text = lib.generators.toINI { } {
|
|
|
|
main = {
|
|
|
|
font = "inconsolata:size=14";
|
|
|
|
};
|
|
|
|
colors = rec {
|
|
|
|
foreground = "000000";
|
|
|
|
background = "ffffff";
|
|
|
|
regular2 = foreground;
|
|
|
|
};
|
|
|
|
};
|
nixos/tests/sway: init
This adds a basic test for Sway. Because Sway is an important part of
the Wayland ecosystem, is stable, and has few dependencies this test
should also be suitable for testing core packages it depends on (e.g.
wayland, wayland-protocols, wlroots, xwayland, mesa, libglvnd, libdrm,
and soon libseat).
The test is modeled after the suggested way of using Sway, i.e. logging
in via a virtual console (tty1) and copying the configuration from
/etc/sway/config (we replace Mod4 (the GNU/Tux key - you've replaced
that evil logo, right? :D) with Mod1 (Alt key) because QEMU monitor's
sendkey command doesn't support the former).
The shell aliases are used to make the sendkey log output shorter.
Co-authored-by: Patrick Hilhorst <git@hilhorst.be>
2021-05-01 22:24:28 +02:00
|
|
|
};
|
|
|
|
|
2021-12-23 20:19:41 +01:00
|
|
|
fonts.fonts = [ pkgs.inconsolata ];
|
|
|
|
|
nixos/tests/sway: init
This adds a basic test for Sway. Because Sway is an important part of
the Wayland ecosystem, is stable, and has few dependencies this test
should also be suitable for testing core packages it depends on (e.g.
wayland, wayland-protocols, wlroots, xwayland, mesa, libglvnd, libdrm,
and soon libseat).
The test is modeled after the suggested way of using Sway, i.e. logging
in via a virtual console (tty1) and copying the configuration from
/etc/sway/config (we replace Mod4 (the GNU/Tux key - you've replaced
that evil logo, right? :D) with Mod1 (Alt key) because QEMU monitor's
sendkey command doesn't support the former).
The shell aliases are used to make the sendkey log output shorter.
Co-authored-by: Patrick Hilhorst <git@hilhorst.be>
2021-05-01 22:24:28 +02:00
|
|
|
# Automatically configure and start Sway when logging in on tty1:
|
|
|
|
programs.bash.loginShellInit = ''
|
|
|
|
if [ "$(tty)" = "/dev/tty1" ]; then
|
|
|
|
set -e
|
|
|
|
|
|
|
|
mkdir -p ~/.config/sway
|
|
|
|
sed s/Mod4/Mod1/ /etc/sway/config > ~/.config/sway/config
|
|
|
|
|
|
|
|
sway --validate
|
|
|
|
sway && touch /tmp/sway-exit-ok
|
|
|
|
fi
|
|
|
|
'';
|
|
|
|
|
|
|
|
programs.sway.enable = true;
|
|
|
|
|
2021-05-13 20:35:45 +02:00
|
|
|
# To test pinentry via gpg-agent:
|
|
|
|
programs.gnupg.agent.enable = true;
|
|
|
|
|
2021-05-27 20:37:24 +02:00
|
|
|
# Need to switch to a different GPU driver than the default one (-vga std) so that Sway can launch:
|
|
|
|
virtualisation.qemu.options = [ "-vga none -device virtio-gpu-pci" ];
|
nixos/tests/sway: init
This adds a basic test for Sway. Because Sway is an important part of
the Wayland ecosystem, is stable, and has few dependencies this test
should also be suitable for testing core packages it depends on (e.g.
wayland, wayland-protocols, wlroots, xwayland, mesa, libglvnd, libdrm,
and soon libseat).
The test is modeled after the suggested way of using Sway, i.e. logging
in via a virtual console (tty1) and copying the configuration from
/etc/sway/config (we replace Mod4 (the GNU/Tux key - you've replaced
that evil logo, right? :D) with Mod1 (Alt key) because QEMU monitor's
sendkey command doesn't support the former).
The shell aliases are used to make the sendkey log output shorter.
Co-authored-by: Patrick Hilhorst <git@hilhorst.be>
2021-05-01 22:24:28 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
enableOCR = true;
|
|
|
|
|
|
|
|
testScript = { nodes, ... }: ''
|
|
|
|
start_all()
|
|
|
|
machine.wait_for_unit("multi-user.target")
|
|
|
|
|
|
|
|
# To check the version:
|
|
|
|
print(machine.succeed("sway --version"))
|
|
|
|
|
|
|
|
# Wait for Sway to complete startup:
|
|
|
|
machine.wait_for_file("/run/user/1000/wayland-1")
|
|
|
|
machine.wait_for_file("/tmp/sway-ipc.sock")
|
|
|
|
|
2021-12-23 20:19:41 +01:00
|
|
|
# Test XWayland (foot does not support X):
|
nixos/tests/sway: init
This adds a basic test for Sway. Because Sway is an important part of
the Wayland ecosystem, is stable, and has few dependencies this test
should also be suitable for testing core packages it depends on (e.g.
wayland, wayland-protocols, wlroots, xwayland, mesa, libglvnd, libdrm,
and soon libseat).
The test is modeled after the suggested way of using Sway, i.e. logging
in via a virtual console (tty1) and copying the configuration from
/etc/sway/config (we replace Mod4 (the GNU/Tux key - you've replaced
that evil logo, right? :D) with Mod1 (Alt key) because QEMU monitor's
sendkey command doesn't support the former).
The shell aliases are used to make the sendkey log output shorter.
Co-authored-by: Patrick Hilhorst <git@hilhorst.be>
2021-05-01 22:24:28 +02:00
|
|
|
machine.succeed(
|
|
|
|
"su - alice -c 'swaymsg exec WINIT_UNIX_BACKEND=x11 WAYLAND_DISPLAY=invalid alacritty'"
|
|
|
|
)
|
|
|
|
machine.wait_for_text("alice@machine")
|
|
|
|
machine.send_chars("test-x11\n")
|
|
|
|
machine.wait_for_file("/tmp/test-x11-exit-ok")
|
|
|
|
print(machine.succeed("cat /tmp/test-x11.out"))
|
2021-12-23 20:19:41 +01:00
|
|
|
machine.copy_from_vm("/tmp/test-x11.out")
|
nixos/tests/sway: init
This adds a basic test for Sway. Because Sway is an important part of
the Wayland ecosystem, is stable, and has few dependencies this test
should also be suitable for testing core packages it depends on (e.g.
wayland, wayland-protocols, wlroots, xwayland, mesa, libglvnd, libdrm,
and soon libseat).
The test is modeled after the suggested way of using Sway, i.e. logging
in via a virtual console (tty1) and copying the configuration from
/etc/sway/config (we replace Mod4 (the GNU/Tux key - you've replaced
that evil logo, right? :D) with Mod1 (Alt key) because QEMU monitor's
sendkey command doesn't support the former).
The shell aliases are used to make the sendkey log output shorter.
Co-authored-by: Patrick Hilhorst <git@hilhorst.be>
2021-05-01 22:24:28 +02:00
|
|
|
machine.screenshot("alacritty_glinfo")
|
|
|
|
machine.succeed("pkill alacritty")
|
|
|
|
|
2021-12-23 20:19:41 +01:00
|
|
|
# Start a terminal (foot) on workspace 3:
|
nixos/tests/sway: init
This adds a basic test for Sway. Because Sway is an important part of
the Wayland ecosystem, is stable, and has few dependencies this test
should also be suitable for testing core packages it depends on (e.g.
wayland, wayland-protocols, wlroots, xwayland, mesa, libglvnd, libdrm,
and soon libseat).
The test is modeled after the suggested way of using Sway, i.e. logging
in via a virtual console (tty1) and copying the configuration from
/etc/sway/config (we replace Mod4 (the GNU/Tux key - you've replaced
that evil logo, right? :D) with Mod1 (Alt key) because QEMU monitor's
sendkey command doesn't support the former).
The shell aliases are used to make the sendkey log output shorter.
Co-authored-by: Patrick Hilhorst <git@hilhorst.be>
2021-05-01 22:24:28 +02:00
|
|
|
machine.send_key("alt-3")
|
2021-12-23 20:19:41 +01:00
|
|
|
machine.sleep(3)
|
|
|
|
machine.send_key("alt-ret")
|
nixos/tests/sway: init
This adds a basic test for Sway. Because Sway is an important part of
the Wayland ecosystem, is stable, and has few dependencies this test
should also be suitable for testing core packages it depends on (e.g.
wayland, wayland-protocols, wlroots, xwayland, mesa, libglvnd, libdrm,
and soon libseat).
The test is modeled after the suggested way of using Sway, i.e. logging
in via a virtual console (tty1) and copying the configuration from
/etc/sway/config (we replace Mod4 (the GNU/Tux key - you've replaced
that evil logo, right? :D) with Mod1 (Alt key) because QEMU monitor's
sendkey command doesn't support the former).
The shell aliases are used to make the sendkey log output shorter.
Co-authored-by: Patrick Hilhorst <git@hilhorst.be>
2021-05-01 22:24:28 +02:00
|
|
|
machine.wait_for_text("alice@machine")
|
|
|
|
machine.send_chars("test-wayland\n")
|
|
|
|
machine.wait_for_file("/tmp/test-wayland-exit-ok")
|
|
|
|
print(machine.succeed("cat /tmp/test-wayland.out"))
|
2021-12-23 20:19:41 +01:00
|
|
|
machine.copy_from_vm("/tmp/test-wayland.out")
|
|
|
|
machine.screenshot("foot_wayland_info")
|
nixos/tests/sway: init
This adds a basic test for Sway. Because Sway is an important part of
the Wayland ecosystem, is stable, and has few dependencies this test
should also be suitable for testing core packages it depends on (e.g.
wayland, wayland-protocols, wlroots, xwayland, mesa, libglvnd, libdrm,
and soon libseat).
The test is modeled after the suggested way of using Sway, i.e. logging
in via a virtual console (tty1) and copying the configuration from
/etc/sway/config (we replace Mod4 (the GNU/Tux key - you've replaced
that evil logo, right? :D) with Mod1 (Alt key) because QEMU monitor's
sendkey command doesn't support the former).
The shell aliases are used to make the sendkey log output shorter.
Co-authored-by: Patrick Hilhorst <git@hilhorst.be>
2021-05-01 22:24:28 +02:00
|
|
|
machine.send_key("alt-shift-q")
|
2021-12-23 20:19:41 +01:00
|
|
|
machine.wait_until_fails("pgrep foot")
|
nixos/tests/sway: init
This adds a basic test for Sway. Because Sway is an important part of
the Wayland ecosystem, is stable, and has few dependencies this test
should also be suitable for testing core packages it depends on (e.g.
wayland, wayland-protocols, wlroots, xwayland, mesa, libglvnd, libdrm,
and soon libseat).
The test is modeled after the suggested way of using Sway, i.e. logging
in via a virtual console (tty1) and copying the configuration from
/etc/sway/config (we replace Mod4 (the GNU/Tux key - you've replaced
that evil logo, right? :D) with Mod1 (Alt key) because QEMU monitor's
sendkey command doesn't support the former).
The shell aliases are used to make the sendkey log output shorter.
Co-authored-by: Patrick Hilhorst <git@hilhorst.be>
2021-05-01 22:24:28 +02:00
|
|
|
|
2021-05-13 20:35:45 +02:00
|
|
|
# Test gpg-agent starting pinentry-gnome3 via D-Bus (tests if
|
|
|
|
# $WAYLAND_DISPLAY is correctly imported into the D-Bus user env):
|
|
|
|
machine.succeed(
|
|
|
|
"su - alice -c 'swaymsg -- exec gpg --no-tty --yes --quick-generate-key test'"
|
|
|
|
)
|
|
|
|
machine.wait_until_succeeds("pgrep --exact gpg")
|
|
|
|
machine.wait_for_text("Passphrase")
|
|
|
|
machine.screenshot("gpg_pinentry")
|
|
|
|
machine.send_key("alt-shift-q")
|
|
|
|
machine.wait_until_fails("pgrep --exact gpg")
|
|
|
|
|
nixos/tests/sway: init
This adds a basic test for Sway. Because Sway is an important part of
the Wayland ecosystem, is stable, and has few dependencies this test
should also be suitable for testing core packages it depends on (e.g.
wayland, wayland-protocols, wlroots, xwayland, mesa, libglvnd, libdrm,
and soon libseat).
The test is modeled after the suggested way of using Sway, i.e. logging
in via a virtual console (tty1) and copying the configuration from
/etc/sway/config (we replace Mod4 (the GNU/Tux key - you've replaced
that evil logo, right? :D) with Mod1 (Alt key) because QEMU monitor's
sendkey command doesn't support the former).
The shell aliases are used to make the sendkey log output shorter.
Co-authored-by: Patrick Hilhorst <git@hilhorst.be>
2021-05-01 22:24:28 +02:00
|
|
|
# Test swaynag:
|
|
|
|
machine.send_key("alt-shift-e")
|
|
|
|
machine.wait_for_text("You pressed the exit shortcut.")
|
|
|
|
machine.screenshot("sway_exit")
|
|
|
|
|
|
|
|
# Exit Sway and verify process exit status 0:
|
|
|
|
machine.succeed("su - alice -c 'swaymsg exit || true'")
|
2021-06-25 02:06:00 +02:00
|
|
|
machine.wait_until_fails("pgrep -x sway")
|
2021-12-23 20:19:41 +01:00
|
|
|
machine.wait_for_file("/tmp/sway-exit-ok")
|
nixos/tests/sway: init
This adds a basic test for Sway. Because Sway is an important part of
the Wayland ecosystem, is stable, and has few dependencies this test
should also be suitable for testing core packages it depends on (e.g.
wayland, wayland-protocols, wlroots, xwayland, mesa, libglvnd, libdrm,
and soon libseat).
The test is modeled after the suggested way of using Sway, i.e. logging
in via a virtual console (tty1) and copying the configuration from
/etc/sway/config (we replace Mod4 (the GNU/Tux key - you've replaced
that evil logo, right? :D) with Mod1 (Alt key) because QEMU monitor's
sendkey command doesn't support the former).
The shell aliases are used to make the sendkey log output shorter.
Co-authored-by: Patrick Hilhorst <git@hilhorst.be>
2021-05-01 22:24:28 +02:00
|
|
|
'';
|
|
|
|
})
|