mirror of
git://git.gnupg.org/gnupg.git
synced 2024-12-22 10:19:57 +01:00
tests:tpm2dtests: Modify tests with SWTPM and relax the condition.
* configure.ac (SWTPM_IOCTL): Remove. (TEST_LIBTSS): Fix the condition. * tests/tpm2dtests/Makefile.am (TESTS_ENVIRONMENT): Remove SWTPM_IOCTL. * tests/tpm2dtests/start_sw_tpm.sh: Add --flags to invoke SWTPM, not requiring SWTPM_IOCTL and TSSSTARTUP any more. -- Cherry-picked from master commit of: 227b3b14f4be2f33ed721818c2186e7fca4cebdf GnuPG-bug-id: 6052 Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
This commit is contained in:
parent
0e200f2187
commit
9353dc811a
@ -1614,9 +1614,8 @@ if test "$build_tpm2d" = "yes"; then
|
|||||||
AC_DEFINE(HAVE_LIBTSS, 1, [Defined if we have TPM2 support library])
|
AC_DEFINE(HAVE_LIBTSS, 1, [Defined if we have TPM2 support library])
|
||||||
# look for a TPM emulator for testing
|
# look for a TPM emulator for testing
|
||||||
AC_PATH_PROG(TPMSERVER, tpm_server)
|
AC_PATH_PROG(TPMSERVER, tpm_server)
|
||||||
AC_PATH_PROG(SWTPM, swtpm)
|
|
||||||
AC_PATH_PROG(SWTPM_IOCTL, swtpm_ioctl)
|
|
||||||
AC_PATH_PROG(TSSSTARTUP, tssstartup)
|
AC_PATH_PROG(TSSSTARTUP, tssstartup)
|
||||||
|
AC_PATH_PROG(SWTPM, swtpm)
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
if test "$have_libtss" = no; then
|
if test "$have_libtss" = no; then
|
||||||
@ -1625,7 +1624,7 @@ fi
|
|||||||
AC_SUBST(LIBTSS_LIBS)
|
AC_SUBST(LIBTSS_LIBS)
|
||||||
AC_SUBST(LIBTSS_CFLAGS)
|
AC_SUBST(LIBTSS_CFLAGS)
|
||||||
AM_CONDITIONAL(HAVE_LIBTSS, test "$have_libtss" != no)
|
AM_CONDITIONAL(HAVE_LIBTSS, test "$have_libtss" != no)
|
||||||
AM_CONDITIONAL(TEST_LIBTSS, test -n "$TPMSERVER" -o -n "$SWTPM" -a -n "$TSSSTARTUP" -a -n "$SWTPM_IOCTL")
|
AM_CONDITIONAL(TEST_LIBTSS, test -n "$SWTPM" -o -n "$TPMSERVER" -a -n "$TSSSTARTUP")
|
||||||
AC_SUBST(HAVE_LIBTSS)
|
AC_SUBST(HAVE_LIBTSS)
|
||||||
|
|
||||||
#
|
#
|
||||||
|
@ -36,7 +36,6 @@ TESTS_ENVIRONMENT = LC_ALL=C \
|
|||||||
objdir="$(abs_top_builddir)" \
|
objdir="$(abs_top_builddir)" \
|
||||||
TPMSERVER="$(TPMSERVER)" TSSSTARTUP="$(TSSSTARTUP)" \
|
TPMSERVER="$(TPMSERVER)" TSSSTARTUP="$(TSSSTARTUP)" \
|
||||||
SWTPM="$(SWTPM)" \
|
SWTPM="$(SWTPM)" \
|
||||||
SWTPM_IOCTL="$(SWTPM_IOCTL)" \
|
|
||||||
GNUPG_BUILD_ROOT="$(abs_top_builddir)" \
|
GNUPG_BUILD_ROOT="$(abs_top_builddir)" \
|
||||||
GNUPG_IN_TEST_SUITE=fact \
|
GNUPG_IN_TEST_SUITE=fact \
|
||||||
GPGSCM_PATH="$(abs_top_srcdir)/tests/gpgscm"
|
GPGSCM_PATH="$(abs_top_srcdir)/tests/gpgscm"
|
||||||
|
@ -3,36 +3,35 @@
|
|||||||
# remove any prior TPM contents
|
# remove any prior TPM contents
|
||||||
rm -f NVChip h*.bin *.permall
|
rm -f NVChip h*.bin *.permall
|
||||||
if [ -x "${SWTPM}" ]; then
|
if [ -x "${SWTPM}" ]; then
|
||||||
${SWTPM} socket --tpm2 --daemon \
|
${SWTPM} socket --tpm2 --daemon \
|
||||||
--pid file=swtpm.pid \
|
--pid file=swtpm.pid \
|
||||||
--server type=tcp,port=2321 \
|
--server type=tcp,port=2321 \
|
||||||
--ctrl type=tcp,port=2322 --tpmstate dir=`pwd`
|
--ctrl type=tcp,port=2322 \
|
||||||
pid=$(cat swtpm.pid)
|
--flags not-need-init,startup-clear \
|
||||||
|
--tpmstate dir=`pwd`
|
||||||
|
cat swtpm.pid
|
||||||
else
|
else
|
||||||
${TPMSERVER} > /dev/null 2>&1 &
|
${TPMSERVER} > /dev/null 2>&1 &
|
||||||
pid=$!
|
pid=$!
|
||||||
fi
|
##
|
||||||
##
|
# This powers on the tpm and starts it
|
||||||
# This powers on the tpm and starts it
|
# then we derive the RSA version of the storage seed and
|
||||||
# then we derive the RSA version of the storage seed and
|
# store it permanently at handle 81000001 and flush the transient
|
||||||
# store it permanently at handle 81000001 and flush the transient
|
##
|
||||||
##
|
a=0
|
||||||
a=0; while [ $a -lt 10 ]; do
|
while [ $a -lt 10 ]; do
|
||||||
if [ -x "${SWTPM_IOCTL}" ]; then
|
tsspowerup > /dev/null 2>&1
|
||||||
${SWTPM_IOCTL} --tcp 127.0.0.1:2322 -i > /dev/null 2>&1
|
if [ $? -eq 0 ]; then
|
||||||
else
|
break;
|
||||||
tsspowerup > /dev/null 2>&1
|
fi
|
||||||
|
sleep 1
|
||||||
|
a=$[$a+1]
|
||||||
|
done
|
||||||
|
if [ $a -eq 10 ]; then
|
||||||
|
echo "Waited 10s for tpm_server to come up; exiting"
|
||||||
|
exit 1
|
||||||
fi
|
fi
|
||||||
if [ $? -eq 0 ]; then
|
|
||||||
break;
|
|
||||||
fi
|
|
||||||
sleep 1
|
|
||||||
a=$[$a+1]
|
|
||||||
done
|
|
||||||
if [ $a -eq 10 ]; then
|
|
||||||
echo "Waited 10s for tpm_server to come up; exiting"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
tssstartup || exit 1
|
${TSSSTARTUP} || exit 1
|
||||||
echo -n $pid
|
echo -n $pid
|
||||||
|
fi
|
||||||
|
Loading…
x
Reference in New Issue
Block a user