From 13d4da95b017e0e2233bd798626652eb6ed40f97 Mon Sep 17 00:00:00 2001 From: Jared Baur Date: Fri, 25 Jul 2025 15:15:38 -0700 Subject: [PATCH] nixosTests.optee: switch to runTestOn --- nixos/tests/all-tests.nix | 2 +- nixos/tests/optee.nix | 128 +++++++++++++++++++------------------- 2 files changed, 64 insertions(+), 66 deletions(-) diff --git a/nixos/tests/all-tests.nix b/nixos/tests/all-tests.nix index 52b10f309d1c..6ad5ce64a98e 100644 --- a/nixos/tests/all-tests.nix +++ b/nixos/tests/all-tests.nix @@ -1174,7 +1174,7 @@ in opentelemetry-collector = runTest ./opentelemetry-collector.nix; openvscode-server = runTest ./openvscode-server.nix; openvswitch = runTest ./openvswitch.nix; - optee = handleTestOn [ "aarch64-linux" ] ./optee.nix { }; + optee = runTestOn [ "aarch64-linux" ] ./optee.nix; orangefs = runTest ./orangefs.nix; orthanc = runTest ./orthanc.nix; os-prober = handleTestOn [ "x86_64-linux" ] ./os-prober.nix { }; diff --git a/nixos/tests/optee.nix b/nixos/tests/optee.nix index f35f075e882a..f9e0bdd2f0f2 100644 --- a/nixos/tests/optee.nix +++ b/nixos/tests/optee.nix @@ -1,70 +1,68 @@ -import ./make-test-python.nix ( - { pkgs, lib, ... }: - { - name = "optee"; +{ pkgs, lib, ... }: +{ + name = "optee"; - meta = with pkgs.lib.maintainers; { - maintainers = [ jmbaur ]; - }; + meta = with pkgs.lib.maintainers; { + maintainers = [ jmbaur ]; + }; - nodes.machine = - { config, pkgs, ... }: - let - inherit (pkgs) armTrustedFirmwareQemu opteeQemuAarch64 ubootQemuAarch64; + nodes.machine = + { config, pkgs, ... }: + let + inherit (pkgs) armTrustedFirmwareQemu opteeQemuAarch64 ubootQemuAarch64; - # Default environment for qemu-arm64 uboot does not work well with - # large nixos kernel/initrds. - uboot = ubootQemuAarch64.overrideAttrs (old: { - postPatch = (old.postPatch or "") + '' - substituteInPlace board/emulation/qemu-arm/qemu-arm.env \ - --replace-fail "ramdisk_addr_r=0x44000000" "ramdisk_addr_r=0x46000000" - ''; - }); + # Default environment for qemu-arm64 uboot does not work well with + # large nixos kernel/initrds. + uboot = ubootQemuAarch64.overrideAttrs (old: { + postPatch = (old.postPatch or "") + '' + substituteInPlace board/emulation/qemu-arm/qemu-arm.env \ + --replace-fail "ramdisk_addr_r=0x44000000" "ramdisk_addr_r=0x46000000" + ''; + }); - bios = armTrustedFirmwareQemu.override { - extraMakeFlags = [ - "SPD=opteed" - "BL32=${opteeQemuAarch64}/tee-header_v2.bin" - "BL32_EXTRA1=${opteeQemuAarch64}/tee-pager_v2.bin" - "BL32_EXTRA2=${opteeQemuAarch64}/tee-pageable_v2.bin" - "BL33=${uboot}/u-boot.bin" - "all" - "fip" - ]; - filesToInstall = [ - "build/qemu/release/bl1.bin" - "build/qemu/release/fip.bin" - ]; - postInstall = '' - dd if=$out/bl1.bin of=$out/bios.bin bs=4096 conv=notrunc - dd if=$out/fip.bin of=$out/bios.bin seek=64 bs=4096 conv=notrunc - ''; - }; - in - { - virtualisation = { - inherit bios; - cores = 2; - qemu.options = [ - "-machine virt,secure=on,accel=tcg,gic-version=2" - "-cpu cortex-a57" - ]; - }; - - # VM boots up via qfw - boot.loader.grub.enable = false; - - services.tee-supplicant = { - enable = true; - # pkcs11 trusted application - trustedApplications = [ "${opteeQemuAarch64.devkit}/ta/fd02c9da-306c-48c7-a49c-bbd827ae86ee.ta" ]; - }; + bios = armTrustedFirmwareQemu.override { + extraMakeFlags = [ + "SPD=opteed" + "BL32=${opteeQemuAarch64}/tee-header_v2.bin" + "BL32_EXTRA1=${opteeQemuAarch64}/tee-pager_v2.bin" + "BL32_EXTRA2=${opteeQemuAarch64}/tee-pageable_v2.bin" + "BL33=${uboot}/u-boot.bin" + "all" + "fip" + ]; + filesToInstall = [ + "build/qemu/release/bl1.bin" + "build/qemu/release/fip.bin" + ]; + postInstall = '' + dd if=$out/bl1.bin of=$out/bios.bin bs=4096 conv=notrunc + dd if=$out/fip.bin of=$out/bios.bin seek=64 bs=4096 conv=notrunc + ''; }; - testScript = '' - machine.wait_for_unit("tee-supplicant.service") - out = machine.succeed("${pkgs.opensc}/bin/pkcs11-tool --module ${lib.getLib pkgs.optee-client}/lib/libckteec.so --list-token-slots") - if out.find("OP-TEE PKCS11 TA") < 0: - raise Exception("optee pkcs11 token not found") - ''; - } -) + in + { + virtualisation = { + inherit bios; + cores = 2; + qemu.options = [ + "-machine virt,secure=on,accel=tcg,gic-version=2" + "-cpu cortex-a57" + ]; + }; + + # VM boots up via qfw + boot.loader.grub.enable = false; + + services.tee-supplicant = { + enable = true; + # pkcs11 trusted application + trustedApplications = [ "${opteeQemuAarch64.devkit}/ta/fd02c9da-306c-48c7-a49c-bbd827ae86ee.ta" ]; + }; + }; + testScript = '' + machine.wait_for_unit("tee-supplicant.service") + out = machine.succeed("${pkgs.opensc}/bin/pkcs11-tool --module ${lib.getLib pkgs.optee-client}/lib/libckteec.so --list-token-slots") + if out.find("OP-TEE PKCS11 TA") < 0: + raise Exception("optee pkcs11 token not found") + ''; +}