1#!/usr/bin/env bash 2# SPDX-License-Identifier: LGPL-2.1-or-later 3set -e 4 5TEST_DESCRIPTION="cryptenroll/cryptsetup with TPM2 devices" 6IMAGE_NAME="tpm2" 7TEST_NO_NSPAWN=1 8TEST_REQUIRE_INSTALL_TESTS=0 9 10# shellcheck source=test/test-functions 11. "${TEST_BASE_DIR:?}/test-functions" 12 13command -v swtpm >/dev/null 2>&1 || exit 0 14command -v tpm2_pcrextend >/dev/null 2>&1 || exit 0 15 16test_append_files() { 17 ( 18 local workspace="${1:?}" 19 20 instmods tpm tpm_tis tpm_ibmvtpm 21 install_dmevent 22 generate_module_dependencies 23 inst_binary tpm2_pcrextend 24 ) 25} 26 27machine="$(uname -m)" 28tpmdevice="tpm-tis" 29if [ "$machine" = "ppc64le" ]; then 30 # tpm-spapr support was introduced in qemu 5.0.0. Skip test for old qemu versions. 31 qemu_min_version "5.0.0" || exit 0 32 tpmdevice="tpm-spapr" 33fi 34 35tpmstate=$(mktemp -d) 36swtpm socket --tpm2 --tpmstate dir="$tpmstate" --ctrl type=unixio,path="$tpmstate/sock" & 37trap 'kill %%; rm -rf $tpmstate' SIGINT EXIT 38QEMU_OPTIONS="-chardev socket,id=chrtpm,path=$tpmstate/sock -tpmdev emulator,id=tpm0,chardev=chrtpm -device $tpmdevice,tpmdev=tpm0" 39 40do_test "$@" 41