fix hardcoded efi arch in tests

Update nix/tests/lanzaboote.nix

Co-authored-by: nikstur <nikstur@outlook.com>
This commit is contained in:
Jörg Thalheim 2024-01-07 09:21:36 +01:00
parent 1d3f28acef
commit 65330d8172
2 changed files with 9 additions and 6 deletions

View File

@ -6,6 +6,9 @@ let
inherit (pkgs) lib system; inherit (pkgs) lib system;
defaultTimeout = 5 * 60; # = 5 minutes defaultTimeout = 5 * 60; # = 5 minutes
inherit (pkgs.stdenv.hostPlatform) efiArch;
efiArchUppercased = lib.toUpper efiArch;
mkSecureBootTest = { name, machine ? { }, useSecureBoot ? true, useTPM2 ? false, readEfiVariables ? false, testScript }: mkSecureBootTest = { name, machine ? { }, useSecureBoot ? true, useTPM2 ? false, readEfiVariables ? false, testScript }:
let let
tpmSocketPath = "/tmp/swtpm-sock"; tpmSocketPath = "/tmp/swtpm-sock";
@ -384,8 +387,8 @@ in
# TODO: this should work -- machine.succeed("efibootmgr -d /dev/vda -c -l \\EFI\\Linux\\nixos-generation-1.efi") -- efivars are not persisted # TODO: this should work -- machine.succeed("efibootmgr -d /dev/vda -c -l \\EFI\\Linux\\nixos-generation-1.efi") -- efivars are not persisted
# across reboots atm? # across reboots atm?
# cheat code no 1 # cheat code no 1
machine.succeed("cp /boot/EFI/Linux/nixos-generation-1-*.efi /boot/EFI/BOOT/BOOTX64.EFI") machine.succeed("cp /boot/EFI/Linux/nixos-generation-1-*.efi /boot/EFI/BOOT/BOOT${efiArchUppercased}.EFI")
machine.succeed("cp /boot/EFI/Linux/nixos-generation-1-*.efi /boot/EFI/systemd/systemd-bootx64.efi") machine.succeed("cp /boot/EFI/Linux/nixos-generation-1-*.efi /boot/EFI/systemd/systemd-boot${efiArch}.efi")
# Let's reboot. # Let's reboot.
machine.succeed("sync") machine.succeed("sync")
@ -415,7 +418,7 @@ in
with subtest("Is `StubInfo` correctly set"): with subtest("Is `StubInfo` correctly set"):
assert "lanzastub" in read_string_variable("StubInfo"), "Unexpected stub information, provenance is not lanzaboote project!" assert "lanzastub" in read_string_variable("StubInfo"), "Unexpected stub information, provenance is not lanzaboote project!"
assert_variable_string("LoaderImageIdentifier", "\\EFI\\BOOT\\BOOTX64.EFI") assert_variable_string("LoaderImageIdentifier", "\\EFI\\BOOT\\BOOT${efiArchUppercased}.EFI")
# TODO: exploit QEMU test infrastructure to pass the good value all the time. # TODO: exploit QEMU test infrastructure to pass the good value all the time.
assert_variable_string("LoaderDevicePartUUID", "1c06f03b-704e-4657-b9cd-681a087a2fdc") assert_variable_string("LoaderDevicePartUUID", "1c06f03b-704e-4657-b9cd-681a087a2fdc")
# OVMF tests are using EDK II tree. # OVMF tests are using EDK II tree.

View File

@ -26,7 +26,7 @@ in
nodes.machine = _: { nodes.machine = _: {
imports = [ common ]; imports = [ common ];
boot.loader.uki.stub = "${pkgs.systemd}/lib/systemd/boot/efi/linuxx64.efi.stub"; boot.loader.uki.stub = "${pkgs.systemd}/lib/systemd/boot/efi/linux${pkgs.hostPlatform.efiArch}.efi.stub";
}; };
testScript = '' testScript = ''
machine.start() machine.start()