Skip to content

Commit da7dccd

Browse files
committed
tests: cover btrfs mountOptions consistency guardrails
1 parent 60173af commit da7dccd

File tree

2 files changed

+63
-0
lines changed

2 files changed

+63
-0
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
pkgs ? import <nixpkgs> { },
3+
diskoLib ? pkgs.callPackage ../lib { },
4+
}:
5+
let
6+
name = "btrfs-mountoptions-consistency-guardrail";
7+
disko = pkgs.callPackage ../. {
8+
checked = true;
9+
inherit diskoLib;
10+
};
11+
disko-config = pkgs.lib.recursiveUpdate (import ../example/btrfs-subvolumes.nix) {
12+
# Intentionally conflicting filesystem-wide mount options across mounted subvolumes.
13+
disko.devices.disk.main.content.partitions.root.content.subvolumes = {
14+
"/rootfs".mountOptions = [ "compress=zstd" ];
15+
"/home".mountOptions = [ "compress=no" ];
16+
};
17+
};
18+
19+
# The guardrail throws during evaluation; this test validates that behavior directly.
20+
evalResult = builtins.tryEval (builtins.deepSeq (disko._cliMount disko-config pkgs) true);
21+
in
22+
assert (!evalResult.success);
23+
pkgs.writeText name "ok\n"
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
{
2+
pkgs ? import <nixpkgs> { },
3+
diskoLib ? pkgs.callPackage ../lib { },
4+
}:
5+
diskoLib.testLib.makeDiskoTest {
6+
inherit pkgs;
7+
name = "btrfs-mountoptions-per-mount-allowed";
8+
disko-config = pkgs.lib.recursiveUpdate (import ../example/btrfs-subvolumes.nix) {
9+
disko.devices.disk.main.content.partitions.root.content.subvolumes = {
10+
"/home".mountOptions = [ "noexec" ];
11+
"/nosuid" = {
12+
mountpoint = "/nosuid";
13+
mountOptions = [ "nosuid" ];
14+
};
15+
"/nodev" = {
16+
mountpoint = "/nodev";
17+
mountOptions = [ "nodev" ];
18+
};
19+
"/noatime" = {
20+
mountpoint = "/noatime";
21+
mountOptions = [ "noatime" ];
22+
};
23+
};
24+
};
25+
extraTestScript = ''
26+
machine.succeed("mountpoint /");
27+
machine.succeed("mountpoint /home");
28+
machine.succeed("mountpoint /nosuid");
29+
machine.succeed("mountpoint /nodev");
30+
machine.succeed("mountpoint /noatime");
31+
machine.succeed("findmnt -no OPTIONS /home | tr ',' '\n' | grep -qx noexec");
32+
machine.succeed("findmnt -no OPTIONS /nosuid | tr ',' '\n' | grep -qx nosuid");
33+
machine.succeed("findmnt -no OPTIONS /nodev | tr ',' '\n' | grep -qx nodev");
34+
machine.succeed("findmnt -no OPTIONS /noatime | tr ',' '\n' | grep -qx noatime");
35+
machine.fail("findmnt -no OPTIONS / | tr ',' '\n' | grep -qx noexec");
36+
machine.fail("findmnt -no OPTIONS / | tr ',' '\n' | grep -qx nosuid");
37+
machine.fail("findmnt -no OPTIONS / | tr ',' '\n' | grep -qx nodev");
38+
machine.fail("findmnt -no OPTIONS / | tr ',' '\n' | grep -qx noatime");
39+
'';
40+
}

0 commit comments

Comments
 (0)