Use swtpm in tests

Resolves: rhbz#2160307

Signed-off-by: Štěpán Horáček <shoracek@redhat.com>
This commit is contained in:
Štěpán Horáček 2023-06-27 13:11:08 +02:00
parent 94b2079a24
commit 32e693db6f
2 changed files with 8 additions and 36 deletions

View File

@ -1,47 +1,18 @@
#!/bin/bash #!/bin/bash
# get tpm simulator code
IBMTPM_VERSION=1661
wget --no-check-certificate https://downloads.sourceforge.net/project/ibmswtpm2/ibmtpm$IBMTPM_VERSION.tar.gz
res="$?"
if [[ "$res" -ne 0 ]]; then
echo "wget failed"
exit 1
fi
# unpackage and build the source
mkdir ibmtpm
pushd ibmtpm
tar xf ../ibmtpm$IBMTPM_VERSION.tar.gz
pushd src
# fixup for openssl 3
sed -i -e "s|OPENSSL_VERSION_NUMBER >= 0x10200000L|OPENSSL_VERSION_NUMBER > 0x30000010L|" TpmToOsslMath.h
sed -i -e "s|CCFLAGS = -Wall|CCFLAGS = -Wall -Wno-error=deprecated-declarations|" makefile
make
res="$?"
if [[ "$res" -ne 0 ]]; then
echo "make of ibmtpm failed"
popd
popd
rm -rf ibmtpm ibmtpm$IBMTPM_VERSION.tar.gz
exit 1
fi
popd
popd
# get tpm2-tools tests # get tpm2-tools tests
TPM2_TOOLS_VERSION=5.0 TPM2_TOOLS_VERSION=5.0
git clone https://github.com/01org/tpm2-tools.git git clone https://github.com/01org/tpm2-tools.git
pushd tpm2-tools pushd tpm2-tools
git checkout -b test $TPM2_TOOLS_VERSION git checkout -b test $TPM2_TOOLS_VERSION
git cherry-pick 6318507a8a2ca2db7423c939c399f71bee2d9d40 # test: add support for swtpm simulator
git cherry-pick 6f5b83ce758e4ed0bdfb591e8db2ee586cacae97 # test/testparms.sh: use algo that's not supported by swtpm for negative test
git cherry-pick e858dec76686bb4c42e74e0984b433231e530f93 # testparms: ensure curve not supported before negative test
git cherry-pick 0789bf264a108c4718875a050d00b1fdee4478b7 # testparms: fix condition for negative test
pushd test/integration pushd test/integration
sed -i -e 's/python/python3/g' helpers.sh sed -i -e 's/\<python\>/python3/g' helpers.sh
pushd tests pushd tests
sed -i -e 's/python/python3/g' *.sh sed -i -e 's/\<python\>/python3/g' *.sh
# some tests aren't executable currently. Needs to be fixed upstream. # some tests aren't executable currently. Needs to be fixed upstream.
chmod +x *.sh chmod +x *.sh
popd popd
@ -49,7 +20,7 @@ popd
popd popd
TPM2_ABRMD=tpm2-abrmd TPM2_ABRMD=tpm2-abrmd
TPM2_SIM=tpm_server TPM2_SIM=swtpm
TPM2_TOOLS_TEST_FIXTURES=`pwd`/tpm2-tools/test/integration/fixtures TPM2_TOOLS_TEST_FIXTURES=`pwd`/tpm2-tools/test/integration/fixtures
PATH=`pwd`/ibmtpm/src/:.:$PATH PATH=`pwd`/ibmtpm/src/:.:$PATH
export TPM2_ABRMD TPM2_SIM TPM2_TOOLS_TEST_FIXTURES PATH export TPM2_ABRMD TPM2_SIM TPM2_TOOLS_TEST_FIXTURES PATH

View File

@ -21,6 +21,7 @@
- vim-common - vim-common
- perl-Digest-SHA - perl-Digest-SHA
- dbus-daemon - dbus-daemon
- swtpm
tests: tests:
- intel-tpm2: - intel-tpm2:
dir: . dir: .