-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
95 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
{ 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=${ | ||
builtins.toString blockSize | ||
}" | ||
]; | ||
/* virtualisation.qemu.drives = [{ | ||
name = "non-default-filesystem"; | ||
file = fsImage; | ||
}]; | ||
*/ | ||
}; | ||
|
||
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) | ||
''; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters