diff options
author | James Bottomley <James.Bottomley@HansenPartnership.com> | 2020-03-23 14:36:16 -0700 |
---|---|---|
committer | James Bottomley <James.Bottomley@HansenPartnership.com> | 2020-03-24 09:13:46 -0700 |
commit | e6fcb0558a51811f6aa9fef0326ab22e727bac77 (patch) | |
tree | caae88eab2a9a9dd94b486c3a7ff3cd40104bdd0 | |
parent | a0344f8b4895d76afcb2934a5734563d6026df5d (diff) | |
download | openssl_tpm2_engine-e6fcb0558a51811f6aa9fef0326ab22e727bac77.tar.gz |
configure.ac: make location of software TPM configurable
openSUSE has chosen to put the tpm_server binary in /usr/lib/ibmtss
which means the current test programmes can't find it. Fix this by
creating a new configuration variable TPMSERVER corresponding to the
absolute path of the software TPM. Make failing to find the software
TPM a non-fatal but significantly warned about problem because it only
affects the running of the tests, not the building of the engine.
Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
-rw-r--r-- | configure.ac | 5 | ||||
-rw-r--r-- | tests/Makefile.am | 10 | ||||
-rwxr-xr-x | tests/start_sw_tpm.sh | 5 |
3 files changed, 15 insertions, 5 deletions
diff --git a/configure.ac b/configure.ac index dd9a63d..f0c5802 100644 --- a/configure.ac +++ b/configure.ac @@ -102,6 +102,7 @@ AC_CHECK_HEADER([tss2/tss.h],[AC_DEFINE(TSS_INCLUDE,tss2)], AC_CHECK_HEADER([ibmtss/tss.h],[AC_DEFINE(TSS_INCLUDE,ibmtss)], AC_MSG_ERROR([No TSS2 include directory found]))) +AC_PATH_PROG(TPMSERVER, tpm_server,,/bin:/usr/bin:/usr/lib/ibmtss:/usr/libexec/ibmtss) CFLAGS="$CFLAGS -Wall" SHREXT=$shrext_cmds AC_SUBST(CFLAGS) @@ -114,6 +115,10 @@ cat <<EOF CFLAGS: ${CFLAGS} openssl engines directory: ${enginesdir} +swtpm for testing: ${TPMSERVER} EOF +if test -z "${TPMSERVER}"; then + AC_MSG_WARN([Software TPM not found, engine will build but can't be tested]) +fi diff --git a/tests/Makefile.am b/tests/Makefile.am index 742464f..9fd36be 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -25,10 +25,16 @@ TESTS = fail_connect.sh \ seal_unseal.sh \ stop_sw_tpm.sh +fail_connect.sh: tpm_server_found + +tpm_server_found: + @if [ -z "$(TPMSERVER)" ]; then echo "ERROR: Can't run tests, no tpm server is found"; exit 1; fi + AM_TESTS_ENVIRONMENT = TPM_INTERFACE_TYPE=socsim; \ srcdir=$(abs_srcdir); \ - OPENSSL_CONF=$(abs_srcdir)/openssl.cnf \ - export TPM_INTERFACE_TYPE OPENSSL_CONF srcdir; + OPENSSL_CONF=$(abs_srcdir)/openssl.cnf; \ + TPMSERVER=$(TPMSERVER); \ + export TPM_INTERFACE_TYPE OPENSSL_CONF srcdir TPMSERVER; TEST_EXTENSIONS = .sh CLEANFILES = key*.tpm key*.pub key*.priv tmp.* NVChip h*.bin key*.der seal.* diff --git a/tests/start_sw_tpm.sh b/tests/start_sw_tpm.sh index 12aa857..93b669c 100755 --- a/tests/start_sw_tpm.sh +++ b/tests/start_sw_tpm.sh @@ -1,10 +1,9 @@ -a=$(which tpm_server) -if [ $? -ne 0 ]; then +if [ -z "${TPMSERVER}" -o ! -x ${TPMSERVER} ]; then exit 1; fi # remove any prior TPM contents rm -f NVChip h*.bin -${a} > /dev/null 2>&1 & +${TPMSERVER} > /dev/null 2>&1 & pid=$! echo ${pid} > tpm_server.pid ## |