From a25482ffa725d306558d0a88db9aaac29cc54759 Mon Sep 17 00:00:00 2001 From: Vincent Haupert Date: Mon, 15 Nov 2021 18:57:27 +0100 Subject: [PATCH] sgxsdk: use samples as passthru tests --- pkgs/os-specific/linux/sgx-sdk/default.nix | 4 +- pkgs/os-specific/linux/sgx-sdk/samples.nix | 57 ++++++++++++++++++++++ 2 files changed, 59 insertions(+), 2 deletions(-) create mode 100644 pkgs/os-specific/linux/sgx-sdk/samples.nix diff --git a/pkgs/os-specific/linux/sgx-sdk/default.nix b/pkgs/os-specific/linux/sgx-sdk/default.nix index 8c6351fb8ee0..7544ac0fed37 100644 --- a/pkgs/os-specific/linux/sgx-sdk/default.nix +++ b/pkgs/os-specific/linux/sgx-sdk/default.nix @@ -19,7 +19,6 @@ , python3 , texinfo , validatePkgConfig -, which , writeShellScript , writeText }: @@ -218,7 +217,6 @@ stdenv.mkDerivation rec { ''; doInstallCheck = true; - installCheckInputs = [ which ]; installCheckPhase = '' runHook preInstallCheck @@ -242,6 +240,8 @@ stdenv.mkDerivation rec { postHooks+=(sgxsdk) ''; + passthru.tests = callPackage ./samples.nix { }; + meta = with lib; { description = "Intel SGX SDK for Linux built with IPP Crypto Library"; homepage = "https://github.com/intel/linux-sgx"; diff --git a/pkgs/os-specific/linux/sgx-sdk/samples.nix b/pkgs/os-specific/linux/sgx-sdk/samples.nix new file mode 100644 index 000000000000..2036a1c5d0d4 --- /dev/null +++ b/pkgs/os-specific/linux/sgx-sdk/samples.nix @@ -0,0 +1,57 @@ +{ stdenv +, sgx-sdk +, which +}: +let + buildSample = name: stdenv.mkDerivation rec { + inherit name; + + src = sgx-sdk.out; + sourceRoot = "${sgx-sdk.name}/share/SampleCode/${name}"; + + buildInputs = [ + sgx-sdk + ]; + + buildFlags = [ + "SGX_MODE=SIM" + ]; + + installPhase = '' + mkdir $out + install -m 755 app $out/app + install *.so $out/ + ''; + + doInstallCheck = true; + installCheckInputs = [ which ]; + installCheckPhase = '' + pushd $out + ./app + popd + ''; + }; +in +{ + cxx11SGXDemo = buildSample "Cxx11SGXDemo"; + localAttestation = (buildSample "LocalAttestation").overrideAttrs (oldAttrs: { + installPhase = '' + mkdir $out + cp -r bin/. $out/ + ''; + }); + powerTransition = (buildSample "PowerTransition").overrideAttrs (oldAttrs: { + # Requires interaction + doInstallCheck = false; + }); + remoteAttestation = (buildSample "RemoteAttestation").overrideAttrs (oldAttrs: { + dontFixup = true; + installCheckPhase = '' + echo "a" | LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$PWD/sample_libcrypto ./app + ''; + }); + sampleEnclave = buildSample "SampleEnclave"; + sampleEnclavePCL = buildSample "SampleEnclavePCL"; + sealUnseal = buildSample "SealUnseal"; + switchless = buildSample "Switchless"; +}