๐Ÿ“ฆ longregen / fastshot

๐Ÿ“„ vm.nix ยท 62 lines
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62{pkgs ? import <nixpkgs> {}}:
pkgs.testers.nixosTest {
  name = "fastshot-test";

  globalTimeout = 600;

  nodes.machine = {pkgs, ...}: {
    imports = [../module.nix];

    services.fastshot = {
      enable = true;
      directory = "screenshots";
      interval = 5;
      threshold = 0.99;
      verbose = true;
    };

    services = {
      xserver = {
        enable = true;
        desktopManager.plasma6.enable = true;
      };
      displayManager = {
        sddm.enable = true;
        defaultSession = "plasma";
        autoLogin = {
          enable = true;
          user = "testuser";
        };
      };
    };

    users.users.testuser = {
      isNormalUser = true;
      password = "test";
    };

    virtualisation.qemu.options = ["-vga virtio"];
    virtualisation.memorySize = 4096;
  };

  testScript = ''
    start_all()

    machine.wait_for_unit("multi-user.target")
    machine.wait_for_unit("graphical.target")
    machine.wait_for_unit("display-manager.service")
    machine.sleep(10)

    # Wait for fastshot service to be running
    machine.wait_until_succeeds("systemctl --user -M testuser@ is-active fastshot.service", timeout=60)

    machine.sleep(20)

    # Copy screenshots to xchg
    machine.succeed("cp -r /home/testuser/screenshots /tmp/xchg/")

    # Verify at least one screenshot exists
    machine.succeed("ls /tmp/xchg/screenshots/*.png")
  '';
}