Skip to content

Commit

Permalink
tests: start swtpm as daemon
Browse files Browse the repository at this point in the history
  • Loading branch information
brandsimon committed Jan 9, 2024
1 parent abe0329 commit 363e027
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions tests/run_with_test_tpm2.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export TCTI="tabrmd:bus_type=session"
export TPM2TOOLS_TCTI="${TCTI}"
DIR="$(pwd)/tests/swtpm"
TMPDIR="$(mktemp -d)"
SWTPMPIDFILE="${TMPDIR}/swtpm.pid"
KILL_PIDS=()
cleanup_pids() {
for pid in "${KILL_PIDS[@]}"; do
Expand All @@ -29,11 +30,13 @@ swtpm socket \
--tpmstate dir="${TMPDIR}/swtpm" \
--flags startup-clear \
--ctrl type=tcp,port=2322 \
--server type=tcp,port=2321 &
KILL_PIDS+=("$!")
sleep 0.1 # Wait until started
--server type=tcp,port=2321 \
--daemon \
--pid file="${SWTPMPIDFILE}"
KILL_PIDS+=("$(cat "${SWTPMPIDFILE}")")
# in gitlab container, tests are running as root
/usr/sbin/tpm2-abrmd --session --allow-root --tcti=swtpm &
sleep 0.1 # Wait until started
KILL_PIDS+=("$!")
sha1="0000000000000000000000000000000000000000"
sha256="0000000000000000000000000000000000000000000000000000000000000000"
Expand Down

0 comments on commit 363e027

Please sign in to comment.