tangled
alpha
login
or
join now
pyrox.dev
/
nixpkgs
lol
0
fork
atom
overview
issues
pulls
pipelines
nixos/tests: add hibernation test
Nikolay Amiantov
9 years ago
9cc70b41
399db54e
+43
2 changed files
expand all
collapse all
unified
split
nixos
release.nix
tests
hibernate.nix
+1
nixos/release.nix
···
231
231
tests.gnome3 = callTest tests/gnome3.nix {};
232
232
tests.gnome3-gdm = callTest tests/gnome3-gdm.nix {};
233
233
tests.grsecurity = callTest tests/grsecurity.nix {};
234
234
+
tests.hibernate = callTest tests/hibernate.nix {};
234
235
tests.i3wm = callTest tests/i3wm.nix {};
235
236
tests.installer = callSubTests tests/installer.nix {};
236
237
tests.influxdb = callTest tests/influxdb.nix {};
+42
nixos/tests/hibernate.nix
···
1
1
+
# Test whether hibernation from partition works.
2
2
+
3
3
+
import ./make-test.nix (pkgs: {
4
4
+
name = "hibernate";
5
5
+
6
6
+
nodes = {
7
7
+
machine = { config, lib, pkgs, ... }: with lib; {
8
8
+
virtualisation.emptyDiskImages = [ config.virtualisation.memorySize ];
9
9
+
10
10
+
systemd.services.backdoor.conflicts = [ "sleep.target" ];
11
11
+
12
12
+
swapDevices = mkOverride 0 [ { device = "/dev/vdb"; } ];
13
13
+
14
14
+
networking.firewall.allowedTCPPorts = [ 4444 ];
15
15
+
16
16
+
systemd.services.listener.serviceConfig.ExecStart = "${pkgs.netcat}/bin/nc -l -p 4444";
17
17
+
};
18
18
+
19
19
+
probe = { config, lib, pkgs, ...}: {
20
20
+
environment.systemPackages = [ pkgs.netcat ];
21
21
+
};
22
22
+
};
23
23
+
24
24
+
# 9P doesn't support reconnection to virtio transport after a hibernation.
25
25
+
# Therefore, machine just hangs on any Nix store access.
26
26
+
# To work around it we run a daemon which listens to a TCP connection and
27
27
+
# try to connect to it as a test.
28
28
+
29
29
+
testScript =
30
30
+
''
31
31
+
$machine->waitForUnit("multi-user.target");
32
32
+
$machine->succeed("mkswap /dev/vdb");
33
33
+
$machine->succeed("swapon -a");
34
34
+
$machine->startJob("listener");
35
35
+
$machine->succeed("systemctl hibernate &");
36
36
+
$machine->waitForShutdown;
37
37
+
$machine->start;
38
38
+
$probe->waitForUnit("network.target");
39
39
+
$probe->waitUntilSucceeds("echo test | nc -c machine 4444");
40
40
+
'';
41
41
+
42
42
+
})