ports/tpm2.nix
TPM2's mocks must retain pointers, including Fil-C capabilities.
λpkgs, final
let
final.cmocka.overrideAttrs
Nixpkgs drops the TCTI unit tests under Clang, whose mocks it cannot make work there. The pointer-preserving mocks below make them pass.
sed -i '/TESTS_UNIT / {
/test\/unit\/tcti-swtpm/d;
/test\/unit\/tcti-mssim/d;
/test\/unit\/tcti-device/d
}' Makefile-test.am
used by keepTctiTests
postPatch: assert pkgs.lib.hasInfixdropTctiTests postPatch; builtins.replaceStringsdropTctiTests "" postPatch
uses dropTctiTests used by tpm2-tss
in
38tpm2-tss
| arg | inherit cmocka; | |
| use | import../toolchain/test-wrap.nix inherit pkgs; | |
| patch | ../patches/tpm2-test-environment.patch | |
| patch | ../patches/tpm2-spi-pointers.patch | |
| use | λold keepTctiTestsold.postPatch + cp ${../toolchain/cmocka-pointer-mocks.h} test/cmocka-pointer-mocks.h # Since 4.2 every test includes cmocka through this helper. substituteInPlace test/helper/cmocka_all.h \ --replace-fail '#include <cmocka.h>' '#include "../cmocka-pointer-mocks.h"' substituteInPlace test/unit/esys-vendor.c \ --replace-fail 'will_return_uint_always(tcti_fake_recv, (uintptr_t) __func__)' \ 'will_return_ptr_always(tcti_fake_recv, __func__)' \ --replace-fail '(const char *)mock_type(uintptr_t)' 'mock_ptr_type(const char *)' # Preserve calls to the functions these tests interpose. The compiler # adapter restores their descriptor names after Fil-C's lowering. substituteInPlace Makefile-test.am \ --replace-fail 'TESTS_CFLAGS = ' \ 'TESTS_CFLAGS = -Dmalloc=filnix_wrap_malloc -Dfree=filnix_wrap_free ' |
uses arg for keepTctiTests patch use