Skip to content

Commit

Permalink
mir,mir_2_15: Fix builds, modernise & fix VM tests (NixOS#374873)
Browse files Browse the repository at this point in the history
  • Loading branch information
OPNA2608 authored Jan 21, 2025
2 parents e1996d7 + 3c0a99e commit 14b04af
Show file tree
Hide file tree
Showing 4 changed files with 93 additions and 15 deletions.
26 changes: 24 additions & 2 deletions nixos/tests/miracle-wm.nix
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
user = "alice";
};

programs.ydotool.enable = true;

services.xserver.enable = true;
services.displayManager.defaultSession = lib.mkForce "miracle-wm";

Expand Down Expand Up @@ -59,7 +61,7 @@
];

# To help with OCR
etc."xdg/foot/foot.ini".text = lib.generators.toINI { } {
etc."xdg/foot/foot.ini".source = (pkgs.formats.ini { }).generate "foot.ini" {
main = {
font = "inconsolata:size=16";
};
Expand All @@ -69,7 +71,7 @@
regular2 = foreground;
};
};
etc."xdg/alacritty/alacritty.yml".text = lib.generators.toYAML { } {
etc."xdg/alacritty/alacritty.toml".source = (pkgs.formats.toml { }).generate "alacritty.toml" {
font = rec {
normal.family = "Inconsolata";
bold.family = normal.family;
Expand Down Expand Up @@ -114,7 +116,17 @@
machine.wait_for_file("/tmp/test-wayland-exit-ok")
machine.copy_from_vm("/tmp/test-wayland.out")
machine.screenshot("foot_wayland_info")
# please actually register that we want to close the window
machine.succeed("ydotool mousemove -- 10 10")
machine.sleep(3)
machine.send_chars("exit\n")
# please actually register that we want to close the window
machine.succeed("ydotool mousemove -- 10 10")
machine.sleep(3)
machine.wait_until_fails("pgrep foot")
# Test XWayland
Expand All @@ -125,7 +137,17 @@
machine.wait_for_file("/tmp/test-x11-exit-ok")
machine.copy_from_vm("/tmp/test-x11.out")
machine.screenshot("alacritty_glinfo")
# please actually register that we want to close the window
machine.succeed("ydotool mousemove -- 10 10")
machine.sleep(3)
machine.send_chars("exit\n")
# please actually register that we want to close the window
machine.succeed("ydotool mousemove -- 10 10")
machine.sleep(3)
machine.wait_until_fails("pgrep alacritty")
'';
}
38 changes: 28 additions & 10 deletions nixos/tests/miriway.nix
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ import ./make-test-python.nix (
user = "alice";
};

programs.ydotool.enable = true;

services.xserver.enable = true;
services.displayManager.defaultSession = lib.mkForce "miriway";

Expand Down Expand Up @@ -55,7 +57,7 @@ import ./make-test-python.nix (
];

# To help with OCR
etc."xdg/foot/foot.ini".text = lib.generators.toINI { } {
etc."xdg/foot/foot.ini".source = (pkgs.formats.ini { }).generate "foot.ini" {
main = {
font = "inconsolata:size=16";
};
Expand All @@ -65,7 +67,7 @@ import ./make-test-python.nix (
regular2 = foreground;
};
};
etc."xdg/alacritty/alacritty.yml".text = lib.generators.toYAML { } {
etc."xdg/alacritty/alacritty.toml".source = (pkgs.formats.toml { }).generate "alacritty.toml" {
font = rec {
normal.family = "Inconsolata";
bold.family = normal.family;
Expand Down Expand Up @@ -109,10 +111,18 @@ import ./make-test-python.nix (
machine.wait_for_file("/tmp/test-wayland-exit-ok")
machine.copy_from_vm("/tmp/test-wayland.out")
machine.screenshot("foot_wayland_info")
# Only succeeds when a mouse is moved inside an interactive session?
# machine.send_chars("exit\n")
# machine.wait_until_fails("pgrep foot")
machine.succeed("pkill foot")
# please actually register that we want to close the window
machine.succeed("ydotool mousemove -- 10 10")
machine.sleep(3)
machine.send_chars("exit\n")
# please actually register that we want to close the window
machine.succeed("ydotool mousemove -- 10 10")
machine.sleep(3)
machine.wait_until_fails("pgrep foot")
# Test XWayland
machine.send_key("ctrl-alt-a")
Expand All @@ -121,10 +131,18 @@ import ./make-test-python.nix (
machine.wait_for_file("/tmp/test-x11-exit-ok")
machine.copy_from_vm("/tmp/test-x11.out")
machine.screenshot("alacritty_glinfo")
# Only succeeds when a mouse is moved inside an interactive session?
# machine.send_chars("exit\n")
# machine.wait_until_fails("pgrep alacritty")
machine.succeed("pkill alacritty")
# please actually register that we want to close the window
machine.succeed("ydotool mousemove -- 10 10")
machine.sleep(3)
machine.send_chars("exit\n")
# please actually register that we want to close the window
machine.succeed("ydotool mousemove -- 10 10")
machine.sleep(3)
machine.wait_until_fails("pgrep alacritty")
'';
}
)
9 changes: 6 additions & 3 deletions pkgs/servers/mir/common.nix
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
freetype,
glib,
glm,
glog,
libapparmor,
libdrm,
libepoxy,
Expand Down Expand Up @@ -112,7 +111,6 @@ stdenv.mkDerivation (finalAttrs: {
freetype
glib
glm
glog
libdrm
libepoxy
libevdev
Expand Down Expand Up @@ -159,7 +157,12 @@ stdenv.mkDerivation (finalAttrs: {
# BadBufferTest.test_truncated_shm_file *doesn't* throw an error as the test expected, mark as such
# https://github.com/canonical/mir/pull/1947#issuecomment-811810872
(lib.cmakeBool "MIR_SIGBUS_HANDLER_ENVIRONMENT_BROKEN" true)
(lib.cmakeFeature "MIR_EXCLUDE_TESTS" (lib.strings.concatStringsSep ";" [ ]))
(lib.cmakeFeature "MIR_EXCLUDE_TESTS" (
lib.strings.concatStringsSep ";" [
# https://github.com/canonical/mir/issues/3716#issuecomment-2580698552
"UdevWrapperTest.UdevMonitorDoesNotTriggerBeforeEnabling"
]
))
# These get built but don't get executed by default, yet they get installed when tests are enabled
(lib.cmakeBool "MIR_BUILD_PERFORMANCE_TESTS" false)
(lib.cmakeBool "MIR_BUILD_PLATFORM_TEST_HARNESS" false)
Expand Down
35 changes: 35 additions & 0 deletions pkgs/servers/mir/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,14 @@ in
hash = "sha256-k+51piPQandbHdm+ioqpBrb+C7Aqi2kugchAehZ1aiU=";
})

# Always depend on epoxy
# Remove when version > 2.15.0
(fetchpatch {
name = "0003-mir-cmake-always-require-epoxy.patch";
url = "https://github.com/canonical/mir/commit/171c42ac3929f946a70505ee42be0ce8220f245a.patch";
hash = "sha256-QuVZBcHSn/DK+xbjM36Y89+w22vk7NRV4MkbjgvS28A=";
})

# Fix ignored return value of std::lock_guard
# Remove when version > 2.15.0
# Was changed as part of the big platform API change, no individual upstream commit with this fix
Expand All @@ -44,6 +52,33 @@ in
# Partially done in https://github.com/canonical/mir/pull/3192, though one of the calloc was fixed earlier
# when some code was moved into that file
./1003-mir-2_15-calloc-args-in-right-order.patch

# Drop gflags & glog dependencies
# Remove when version > 2.16.4
(fetchpatch {
name = "0101-Drop-unused-dependency-on-gflags.patch";
url = "https://github.com/canonical/mir/commit/15a40638e5e9c4b6a11b7fa446ad31e190f485e7.patch";
includes = [
"CMakeLists.txt"
"examples/mir_demo_server/CMakeLists.txt"
"examples/mir_demo_server/glog_logger.cpp"
];
hash = "sha256-qIsWCOs6Ap0jJ2cpgdO+xJHmSqC6zP+J3ALAfmlA6Vc=";
})
(fetchpatch {
name = "0102-Drop-the-glog-example.patch";
url = "https://github.com/canonical/mir/commit/8407da28ddb9a535df2775f224bf5143e8770d52.patch";
includes = [
"CMakeLists.txt"
"examples/mir_demo_server/CMakeLists.txt"
"examples/mir_demo_server/glog_logger.cpp"
"examples/mir_demo_server/glog_logger.h"
"examples/mir_demo_server/server_example.cpp"
"examples/mir_demo_server/server_example_log_options.cpp"
"examples/mir_demo_server/server_example_log_options.h"
];
hash = "sha256-jVhVR7wZZZGRS40z+HPNoGBLHulvE1nHRKgYhQ6/g9M=";
})
];
};
}

0 comments on commit 14b04af

Please sign in to comment.