1import ./make-test-python.nix {
2 name = "zram-generator";
3
4 nodes = {
5 single = { ... }: {
6 virtualisation = {
7 emptyDiskImages = [ 512 ];
8 };
9 zramSwap = {
10 enable = true;
11 priority = 10;
12 algorithm = "lz4";
13 swapDevices = 1;
14 memoryPercent = 30;
15 memoryMax = 10 * 1024 * 1024;
16 writebackDevice = "/dev/vdb";
17 };
18 };
19 machine = { ... }: {
20 zramSwap = {
21 enable = true;
22 priority = 10;
23 algorithm = "lz4";
24 swapDevices = 2;
25 memoryPercent = 30;
26 memoryMax = 10 * 1024 * 1024;
27 };
28 };
29 };
30
31 testScript = ''
32 single.wait_for_unit("systemd-zram-setup@zram0.service")
33
34 machine.wait_for_unit("systemd-zram-setup@zram0.service")
35 machine.wait_for_unit("systemd-zram-setup@zram1.service")
36 zram = machine.succeed("zramctl --noheadings --raw")
37 swap = machine.succeed("swapon --show --noheadings")
38 for i in range(2):
39 assert f"/dev/zram{i} lz4 10M" in zram
40 assert f"/dev/zram{i} partition 10M" in swap
41 '';
42}