Skip to content

Commit bc9322d

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

File tree

3 files changed

+95
-8
lines changed

3 files changed

+95
-8
lines changed

checks/blocksize.nix

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

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 lib blockSize imageSize;
34+
diskSizeMiB = 64;
35+
};
36+
}) parameters))
37+
else
1938
{ })

checks/headless/default.nix

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
{ lib, caligula, runCommand }:
22
runCommand "caligula-headless-test" {
33
buildInputs = [ caligula ];
4-
isoInnerHash = "3972dc9744f6499f0f9b2dbf76696f2ae7ad8af9b23dde66d6af86c9dfb36986";
4+
isoInnerHash =
5+
"3972dc9744f6499f0f9b2dbf76696f2ae7ad8af9b23dde66d6af86c9dfb36986";
56
meta.timeout = 10;
67
} ''
78
caligula burn ${./input.iso.gz} \

0 commit comments

Comments
 (0)