summary refs log tree commit diff
path: root/nixos/tests/tuptime.nix
blob: 36ce2b1ae19236771d7bf607ffc466756b755560 (plain) (blame)
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
import ./make-test-python.nix ({ pkgs, ...} : {
  name = "tuptime";
  meta = with pkgs.stdenv.lib.maintainers; {
    maintainers = [ evils ];
  };

  machine = { pkgs, ... }: {
    imports = [ ../modules/profiles/minimal.nix ];
    services.tuptime.enable = true;
  };

  testScript =
    ''
      # see if it starts
      start_all()
      machine.wait_for_unit("multi-user.target")
      machine.succeed("tuptime | grep 'System startups:[[:blank:]]*1'")
      machine.succeed("tuptime | grep 'System uptime:[[:blank:]]*100.0%'")
      machine.shutdown()

      # restart machine and see if it correctly reports the reboot
      machine.start()
      machine.wait_for_unit("multi-user.target")
      machine.succeed("tuptime | grep 'System startups:[[:blank:]]*2'")
      machine.succeed("tuptime | grep 'System shutdowns:[[:blank:]]*1 ok'")
      machine.shutdown()
    '';
})