aboutsummaryrefslogtreecommitdiffstats
path: root/tests/tpm2dtests
diff options
context:
space:
mode:
authorJames Bottomley <[email protected]>2021-03-15 16:09:32 +0000
committerWerner Koch <[email protected]>2021-03-15 16:09:32 +0000
commita788f2e8306d80f7f3df34eb62ec7ce1a62d48e1 (patch)
tree5f11f21c29b5a86a511d14d2697ca53799eb2077 /tests/tpm2dtests
parentgpg: New option --no-auto-trust-new-key. (diff)
downloadgnupg-a788f2e8306d80f7f3df34eb62ec7ce1a62d48e1.tar.gz
gnupg-a788f2e8306d80f7f3df34eb62ec7ce1a62d48e1.zip
tests:tpm2d: add missing start_sw_tpm.sh script
* tests/tpm2dtests/start_sw_tpm.sh: New. * tests/tpm2dtests/Makefile.am: Add. -- This accidentally got left out of the initial commit for testing 6720f1343 ("tpm2d: add tests for the tpm2daemon") Signed-off-by: James Bottomley <[email protected]> Added to Makefile and wrote tiny ChangeLog. Signed-off-by: Werner Koch <[email protected]>
Diffstat (limited to 'tests/tpm2dtests')
-rw-r--r--tests/tpm2dtests/Makefile.am2
-rwxr-xr-xtests/tpm2dtests/start_sw_tpm.sh35
2 files changed, 36 insertions, 1 deletions
diff --git a/tests/tpm2dtests/Makefile.am b/tests/tpm2dtests/Makefile.am
index 36be90efd..ced4a1f49 100644
--- a/tests/tpm2dtests/Makefile.am
+++ b/tests/tpm2dtests/Makefile.am
@@ -61,7 +61,7 @@ xcheck: tpm_server_found
tpm_server_found:
@if [ -z "$(TPMSERVER)" -a -z "$(SWTPM)" -a -z "$(FORCE)" ]; then echo "ERROR: No Software TPM has been found, cannot run TPM tests. Set FORCE=1 to force using the physical TPM"; exit 1; fi
-EXTRA_DIST = defs.scm shell.scm all-tests.scm
+EXTRA_DIST = defs.scm shell.scm all-tests.scm start_sw_tpm.sh
CLEANFILES = gpg.conf gpg-agent.conf S.gpg-agent \
pubring.gpg pubring.gpg~ pubring.kbx pubring.kbx~ \
diff --git a/tests/tpm2dtests/start_sw_tpm.sh b/tests/tpm2dtests/start_sw_tpm.sh
new file mode 100755
index 000000000..36e1a806e
--- /dev/null
+++ b/tests/tpm2dtests/start_sw_tpm.sh
@@ -0,0 +1,35 @@
+#!/bin/bash
+
+# remove any prior TPM contents
+rm -f NVChip h*.bin *.permall
+if [ -x "${SWTPM}" ]; then
+ ${SWTPM} socket --tpm2 --server type=tcp,port=2321 \
+ --ctrl type=tcp,port=2322 --tpmstate dir=`pwd` &
+else
+ ${TPMSERVER} > /dev/null 2>&1 &
+fi
+pid=$!
+##
+# This powers on the tpm and starts it
+# then we derive the RSA version of the storage seed and
+# store it permanently at handle 81000001 and flush the transient
+##
+a=0; while [ $a -lt 10 ]; do
+ if [ -x "${SWTPM_IOCTL}" ]; then
+ ${SWTPM_IOCTL} --tcp 127.0.0.1:2322 -i > /dev/null 2>&1
+ else
+ tsspowerup > /dev/null 2>&1
+ 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
+echo -n $pid