wip: first PubSolarOS iso test using the NixOS
This commit is contained in:
parent
f3e1c53b0d
commit
ab2ce6a1dd
|
@ -114,7 +114,7 @@
|
||||||
/* set host specific properties here */
|
/* set host specific properties here */
|
||||||
PubSolarOS = {
|
PubSolarOS = {
|
||||||
tests = [
|
tests = [
|
||||||
(import ./tests/first-test.nix {})
|
(import ./tests/first-test.nix { pkgs = nixos.legacyPackages.x86_64-linux; })
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,11 +1,15 @@
|
||||||
{ }:
|
{ pkgs, ... }:
|
||||||
{
|
{
|
||||||
name = "firstTest";
|
name = "firstTest";
|
||||||
|
|
||||||
nodes.test-machine = { suites ? null, ... }: {
|
nodes.test-machine = { suites ? null, ... }: {
|
||||||
imports = suites.iso;
|
imports = suites.iso;
|
||||||
|
|
||||||
|
# source: https://github.com/NixOS/nixpkgs/blob/nixos-unstable/nixos/tests/sway.nix
|
||||||
environment = {
|
environment = {
|
||||||
|
# For glinfo and wayland-info:
|
||||||
|
systemPackages = with pkgs; [ mesa-demos wayland-utils alacritty ];
|
||||||
|
# Use a fixed SWAYSOCK path (for swaymsg):
|
||||||
variables = {
|
variables = {
|
||||||
"SWAYSOCK" = "/tmp/sway-ipc.sock";
|
"SWAYSOCK" = "/tmp/sway-ipc.sock";
|
||||||
# TODO: Investigate if we can get hardware acceleration to work (via
|
# TODO: Investigate if we can get hardware acceleration to work (via
|
||||||
|
@ -17,6 +21,7 @@
|
||||||
};
|
};
|
||||||
|
|
||||||
shellAliases = {
|
shellAliases = {
|
||||||
|
test-x11 = "glinfo | tee /tmp/test-x11.out && touch /tmp/test-x11-exit-ok";
|
||||||
test-wayland = "wayland-info | tee /tmp/test-wayland.out && touch /tmp/test-wayland-exit-ok";
|
test-wayland = "wayland-info | tee /tmp/test-wayland.out && touch /tmp/test-wayland-exit-ok";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
@ -28,25 +33,49 @@
|
||||||
enableOCR = true;
|
enableOCR = true;
|
||||||
|
|
||||||
testScript = ''
|
testScript = ''
|
||||||
|
import shlex
|
||||||
|
def swaymsg(command: str, succeed=True):
|
||||||
|
with machine.nested(f"sending swaymsg {command!r}" + " (allowed to fail)" * (not succeed)):
|
||||||
|
(machine.succeed if succeed else machine.execute)(
|
||||||
|
f"su - pub-solar -c {shlex.quote('swaymsg -- ' + command)}"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
machine.wait_for_unit("multi-user.target")
|
machine.wait_for_unit("multi-user.target")
|
||||||
|
|
||||||
# To check the version:
|
# To check the version:
|
||||||
print(machine.succeed("sway --version"))
|
print(machine.succeed("sway --version"))
|
||||||
|
|
||||||
# Wait for Sway to complete startup:
|
# Wait for Sway to complete startup:
|
||||||
machine.wait_for_file("/run/user/1000/wayland-1")
|
machine.wait_for_file("/run/user/1000/wayland-1")
|
||||||
machine.wait_for_file("/tmp/sway-ipc.sock")
|
machine.wait_for_file("/tmp/sway-ipc.sock")
|
||||||
|
machine.wait_for_file("/run/user/1000/pipewire-0")
|
||||||
|
|
||||||
# Start a terminal (alacritty) on workspace 3:
|
# Test XWayland (foot does not support X):
|
||||||
machine.send_key("super-3")
|
machine.sleep(10)
|
||||||
|
swaymsg("exec WINIT_UNIX_BACKEND=x11 WAYLAND_DISPLAY=invalid alacritty")
|
||||||
|
machine.wait_for_text("~")
|
||||||
|
machine.send_chars("test-x11\n")
|
||||||
|
machine.wait_for_file("/tmp/test-x11-exit-ok")
|
||||||
|
print(machine.succeed("cat /tmp/test-x11.out"))
|
||||||
|
machine.copy_from_vm("/tmp/test-x11.out")
|
||||||
|
machine.screenshot("alacritty_glinfo")
|
||||||
|
machine.succeed("pkill alacritty")
|
||||||
|
|
||||||
|
# Start a terminal (foot) on workspace 3:
|
||||||
|
machine.wait_for_text("1")
|
||||||
|
machine.send_key("meta_l-3")
|
||||||
machine.sleep(3)
|
machine.sleep(3)
|
||||||
machine.send_key("super-ret")
|
machine.send_key("meta_l-ret")
|
||||||
|
machine.sleep(10)
|
||||||
machine.send_chars("whoami\n")
|
machine.send_chars("whoami\n")
|
||||||
machine.wait_for_text("pub-solar")
|
machine.wait_for_text("pub-solar")
|
||||||
machine.send_chars("test-wayland\n")
|
machine.send_chars("test-wayland\n")
|
||||||
machine.wait_for_file("/tmp/test-wayland-exit-ok")
|
machine.wait_for_file("/tmp/test-wayland-exit-ok")
|
||||||
print(machine.succeed("cat /tmp/test-wayland.out"))
|
print(machine.succeed("cat /tmp/test-wayland.out"))
|
||||||
machine.copy_from_vm("/tmp/test-wayland.out")
|
machine.copy_from_vm("/tmp/test-wayland.out")
|
||||||
machine.screenshot("alacritty_wayland_info")
|
machine.screenshot("foot_wayland_info")
|
||||||
machine.send_key("super-shift-q")
|
machine.send_key("meta_l-shift-q")
|
||||||
machine.wait_until_fails("pgrep alacritty")
|
machine.wait_until_fails("pgrep foot")
|
||||||
'';
|
'';
|
||||||
}
|
}
|
||||||
|
|
14
tests/second-test.nix
Normal file
14
tests/second-test.nix
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
{ }:
|
||||||
|
{
|
||||||
|
name = "secondTest";
|
||||||
|
|
||||||
|
nodes.test-machine2 = { suites ? null, ... }: {
|
||||||
|
imports = [
|
||||||
|
suites.iso
|
||||||
|
];
|
||||||
|
};
|
||||||
|
|
||||||
|
testScript = ''
|
||||||
|
machines[0].systemctl("is-system-running --wait")
|
||||||
|
'';
|
||||||
|
}
|
Loading…
Reference in a new issue