Skip to content

Commit

Permalink
Add a matrix of blocky burny tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ifd3f committed May 24, 2024
1 parent f17579e commit 664fd4f
Show file tree
Hide file tree
Showing 3 changed files with 90 additions and 8 deletions.
62 changes: 62 additions & 0 deletions checks/blocksize.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
{ lib, nixosTest, imageSize, blockSize, diskSizeMiB }:
let
serial = "awawawawawa";
diskFile = "/tmp/block-file.img";
byDiskPath = "/dev/disk/by-id/usb-QEMU_QEMU_HARDDISK_${serial}-0:0";
in nixosTest {
name = "blocksize-bs${toString blockSize}-image${toString imageSize}-diskMiB${
toString diskSizeMiB
}";

nodes.machine = { pkgs, lib, ... }:
with lib; {
imports = [ ];

users.users = {
admin = {
isNormalUser = true;
extraGroups = [ "wheel" ];
};
};

environment.systemPackages = with pkgs; [ caligula ];
virtualisation.qemu.options =
[ "-drive" "if=none,id=usbstick,format=raw,file=${diskFile}" ]
++ [ "-usb" ] ++ [ "-device" "usb-ehci,id=ehci" ] ++ [
"-device"
"usb-storage,bus=ehci.0,drive=usbstick,serial=${serial},physical_block_size=${
toString blockSize
}"
];
};

testScript = with lib; ''
import os
print("Creating file image at ${diskFile}")
os.system("dd bs=1M count=${
toString diskSizeMiB
} if=/dev/urandom of=${diskFile}")
${readFile ./common.py}
machine.start()
machine.wait_for_unit('default.target')
print(machine.execute('stat $(readlink -f ${byDiskPath})', check_output=True)[1])
try:
machine.succeed('dd if=/dev/urandom of=/tmp/input.iso bs=1 count=${
toString imageSize
}')
with subtest("executes successfully"):
machine.succeed('caligula burn /tmp/input.iso --force -o $(readlink -f ${byDiskPath}) --hash skip --compression auto --interactive never')
with subtest("burns correctly"):
machine.succeed('dd if=${byDiskPath} of=/tmp/written.iso bs=1 count=${
toString imageSize
}')
machine.succeed('diff -s /tmp/input.iso /tmp/written.iso')
finally:
print_logs(machine)
'';
}
33 changes: 26 additions & 7 deletions checks/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,34 @@ let
inherit system;
overlays = [ self.overlays.default ];
};
in {
lib = pkgs.lib;
in with lib;
{
headless = pkgs.callPackage ./headless { };
smoke-test-simple = pkgs.callPackage ./smoke-test-simple { };
} //

(if system == "x86_64-linux" then {
autoescalate-doas =
pkgs.callPackage ./autoescalate { escalationTool = "doas"; };
autoescalate-sudo =
pkgs.callPackage ./autoescalate { escalationTool = "sudo"; };
} else
(if system == "x86_64-linux" then
{
autoescalate-doas =
pkgs.callPackage ./autoescalate { escalationTool = "doas"; };
autoescalate-sudo =
pkgs.callPackage ./autoescalate { escalationTool = "sudo"; };
} //

# blocksize alignment tests
(let
MiB = 1048576;
parameters = cartesianProduct {
blockSize = [ 512 1024 2048 4096 8192 ];
imageSize = [ (10 * MiB) (10 * MiB + 51) ];
};
in listToAttrs (map ({ imageSize, blockSize }: rec {
name = value.name;
value = pkgs.callPackage ./blocksize.nix {
inherit lib blockSize imageSize;
diskSizeMiB = 64;
};
}) parameters))
else
{ })
3 changes: 2 additions & 1 deletion checks/headless/default.nix
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{ lib, caligula, runCommand }:
runCommand "caligula-headless-test" {
buildInputs = [ caligula ];
isoInnerHash = "3972dc9744f6499f0f9b2dbf76696f2ae7ad8af9b23dde66d6af86c9dfb36986";
isoInnerHash =
"3972dc9744f6499f0f9b2dbf76696f2ae7ad8af9b23dde66d6af86c9dfb36986";
meta.timeout = 10;
} ''
caligula burn ${./input.iso.gz} \
Expand Down

0 comments on commit 664fd4f

Please sign in to comment.