Skip to content

Commit d745770

Browse files
committed
Add a matrix of blocky burny tests
1 parent 1521f98 commit d745770

File tree

2 files changed

+83
-7
lines changed

2 files changed

+83
-7
lines changed

checks/blocksize.nix

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
{ nixosTest, imageSize, blockSize, diskSizeMiB }:
2+
let
3+
serial = "awawawawawa";
4+
diskFile = "/tmp/block-file.img";
5+
byDiskPath = "/dev/disk/by-id/usb-QEMU_QEMU_HARDDISK_${serial}-0:0";
6+
in nixosTest {
7+
name = "blocksize-bs${toString blockSize}-image${toString imageSize}-diskMiB${toString diskSizeMiB}";
8+
9+
nodes.machine = { pkgs, lib, ... }:
10+
with lib; {
11+
imports = [ ];
12+
13+
users.users = {
14+
admin = {
15+
isNormalUser = true;
16+
extraGroups = [ "wheel" ];
17+
};
18+
};
19+
20+
environment.systemPackages = with pkgs; [ caligula ];
21+
virtualisation.qemu.options =
22+
[ "-drive" "if=none,id=usbstick,format=raw,file=${diskFile}" ]
23+
++ [ "-usb" ] ++ [ "-device" "usb-ehci,id=ehci" ] ++ [
24+
"-device"
25+
"usb-storage,bus=ehci.0,drive=usbstick,serial=${serial},physical_block_size=${
26+
builtins.toString blockSize
27+
}"
28+
];
29+
/* virtualisation.qemu.drives = [{
30+
name = "non-default-filesystem";
31+
file = fsImage;
32+
}];
33+
*/
34+
};
35+
36+
testScript = ''
37+
import os
38+
39+
print("Creating file image at ${diskFile}")
40+
os.system("dd bs=1 count=${
41+
builtins.toString diskSizeMiB
42+
} if=/dev/urandom of=${diskFile}")
43+
44+
${builtins.readFile ./common.py}
45+
46+
machine.start()
47+
machine.wait_for_unit('default.target')
48+
print(machine.execute('stat $(readlink -f ${byDiskPath})', check_output=True)[1])
49+
try:
50+
machine.succeed('dd if=/dev/urandom of=/tmp/input.iso bs=1 count=${
51+
builtins.toString imageSize
52+
}')
53+
machine.succeed('caligula burn /tmp/input.iso --force -o $(readlink -f ${byDiskPath}) --hash skip --compression auto --interactive never')
54+
finally:
55+
print_logs(machine)
56+
'';
57+
}

checks/default.nix

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,34 @@ let
55
inherit system;
66
overlays = [ self.overlays.default ];
77
};
8-
in {
8+
lib = pkgs.lib;
9+
in with lib;
10+
{
911
headless = pkgs.callPackage ./headless { };
1012
smoke-test-simple = pkgs.callPackage ./smoke-test-simple { };
1113
} //
1214

13-
(if system == "x86_64-linux" then {
14-
autoescalate-doas =
15-
pkgs.callPackage ./autoescalate { escalationTool = "doas"; };
16-
autoescalate-sudo =
17-
pkgs.callPackage ./autoescalate { escalationTool = "sudo"; };
18-
} else
15+
(if system == "x86_64-linux" then
16+
{
17+
autoescalate-doas =
18+
pkgs.callPackage ./autoescalate { escalationTool = "doas"; };
19+
autoescalate-sudo =
20+
pkgs.callPackage ./autoescalate { escalationTool = "sudo"; };
21+
} //
22+
23+
# blocksize alignment tests
24+
(let
25+
MiB = 1048576;
26+
parameters = cartesianProduct {
27+
blockSize = [ 512 1024 2048 4096 8192 ];
28+
imageSize = [ (10 * MiB) (10 * MiB + 51) ];
29+
};
30+
in listToAttrs (map ({ imageSize, blockSize }: rec {
31+
name = value.name;
32+
value = pkgs.callPackage ./blocksize.nix {
33+
inherit blockSize imageSize;
34+
diskSizeMiB = 64;
35+
};
36+
}) parameters))
37+
else
1938
{ })

0 commit comments

Comments
 (0)