-
-
Notifications
You must be signed in to change notification settings - Fork 294
Expand file tree
/
Copy pathbcachefs.nix
More file actions
149 lines (137 loc) · 5.01 KB
/
bcachefs.nix
File metadata and controls
149 lines (137 loc) · 5.01 KB
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
{
pkgs ? import <nixpkgs> { },
diskoLib ? pkgs.callPackage ../lib { },
}:
diskoLib.testLib.makeDiskoTest {
inherit pkgs;
name = "bcachefs";
disko-config = ../example/bcachefs.nix;
enableOCR = true;
bootCommands = ''
machine.wait_for_text("enter passphrase for /");
machine.send_chars("secretsecret\n");
machine.wait_for_text("enter passphrase for /home");
machine.send_chars("secretsecret\n");
machine.wait_for_text("enter passphrase for /nix");
machine.send_chars("secretsecret\n");
'';
extraInstallerConfig = {
boot = {
kernelPackages = pkgs.linuxPackages_testing;
supportedFilesystems = [ "bcachefs" ];
};
};
extraSystemConfig = {
environment.systemPackages = [
pkgs.jq
];
boot.initrd.extraUtilsCommands = ''
# Copy tools for bcachefs
copy_bin_and_libs ${pkgs.lib.getOutput "mount" pkgs.util-linux}/bin/mount
copy_bin_and_libs ${pkgs.bcachefs-tools}/bin/bcachefs
copy_bin_and_libs ${pkgs.bcachefs-tools}/bin/mount.bcachefs
'';
};
extraTestScript = ''
# Print debug information.
machine.succeed("uname -a >&2");
machine.succeed("ls -la / >&2");
machine.succeed("lsblk >&2");
machine.succeed("lsblk -f >&2");
machine.succeed("mount >&2");
machine.succeed("bcachefs show-super /dev/vda2 >&2");
machine.succeed("bcachefs show-super /dev/vdd1 >&2");
machine.succeed("findmnt --json >&2");
# Verify existence of mountpoints.
machine.succeed("mountpoint /");
machine.succeed("mountpoint /home");
machine.succeed("mountpoint /nix");
machine.succeed("mountpoint /home/Documents");
machine.succeed("mountpoint /empty_label")
machine.fail("mountpoint /non-existent");
# Verify device membership and labels.
machine.succeed("bcachefs show-super /dev/vda2 | grep 'Devices:' | grep -q '3'");
machine.succeed("bcachefs show-super /dev/vdd1 | grep 'Devices:' | grep -q '1'");
machine.succeed("bcachefs show-super /dev/vda2 | grep -qE '^[[:space:]]*Label:[[:space:]]+group_a\.vdb2'");
machine.succeed("bcachefs show-super /dev/vda2 | grep -qE '^[[:space:]]*Label:[[:space:]]+group_a\.vdc1'");
machine.succeed("bcachefs show-super /dev/vda2 | grep -qE '^[[:space:]]*Label:[[:space:]]+group_b\.vdd1'");
## !Warning! device /dev/vde1 in the example config shows up as /dev/vdd1 here
machine.succeed("bcachefs show-super /dev/vdd1 | grep -qE '^[[:space:]]*Label:[[:space:]]+group_a\.vde1'");
## !Warning! device /dev/vdf is the example config shows up as /dev/vde here
machine.succeed("bcachefs show-super /dev/vde | grep -qE '^Label:[[:space:]]+\(none\)'");
machine.fail("bcachefs show-super /dev/vda2 | grep 'Label:' | grep -q 'non-existent'");
# Verify format arguments.
# Test that lza4 compression and background_compression options were set for vda2.
machine.succeed("bcachefs show-super /dev/vda2 | grep -qE '^[[:space:]]*compression:[[:space:]]+lz4'");
machine.succeed("bcachefs show-super /dev/vda2 | grep -qE '^[[:space:]]*background_compression:[[:space:]]+lz4'");
# Test that no compression option was set for vdd1.
machine.succeed("bcachefs show-super /dev/vdd1 | grep -qE '^[[:space:]]*compression:[[:space:]]+none'");
# Verify mount options from configuration.
# Test that verbose option was set for "/".
machine.succeed("""
findmnt --json \
| jq -e ' \
.filesystems[] \
| select(.target == "/") \
| .options \
| split(",") \
| contains(["verbose"]) \
'
""");
# Test that verbose option was not set for "/home/Documents".
machine.fail("""
findmnt --json \
| jq -e ' \
.filesystems[] \
| .. \
| select(.target? == "/home/Documents") \
| .options \
| split(",") \
| contains(["verbose"]) \
'
""");
# Test that non-existent option was not set for "/".
machine.fail("""
findmnt --json \
| jq -e ' \
.filesystems[] \
| select(.target == "/") \
| .options \
| split(",") \
| contains(["non-existent"]) \
'
""");
# Verify device composition of filesystems.
machine.succeed("""
findmnt --json \
| jq -e ' \
.filesystems[] \
| select(.target == "/") \
| .source \
| contains("/dev/vda2") \
and contains("/dev/vdb1") \
and contains("/dev/vdc1") \
and contains("[/subvolumes/root]") \
'
""");
machine.succeed("""
findmnt --json \
| jq -e ' \
.filesystems[] \
| .. \
| select(.target? == "/home/Documents") \
| .source \
| contains("/dev/vdd1") \
'
""");
machine.fail("""
findmnt --json \
| jq -e ' \
.filesystems[] \
| select(.target == "/") \
| .source \
| contains(["/dev/non-existent"]) \
'
""");
'';
}