]> git.proxmox.com Git - swtpm.git/blame - tests/test_tpm2_ibmtss2
tests: Get the IBM TSS2 test suite and run it
[swtpm.git] / tests / test_tpm2_ibmtss2
CommitLineData
03c7fe45
SB
1#!/usr/bin/env bash
2
3if [ ${SWTPM_TEST_EXPENSIVE:-0} -eq 0 ]; then
4 exit 77
5fi
6
7ROOT=${abs_top_builddir:-$(pwd)/..}
8TESTDIR=${abs_top_testdir:-$(dirname "$0")}
9
10SWTPM_SERVER_PORT=65426
11SWTPM_SERVER_NAME=localhost
12SWTPM_CTRL_PORT=65427
13SWTPM_INTERFACE=socket+socket
14
15function cleanup() {
16 pid=${SWTPM_PID}
17 if [ -n "$pid" ]; then
18 kill_quiet -9 $pid
19 fi
20 if [ -n ${WORKDIR} ]; then
21 rm -rf ${WORKDIR}
22 fi
23}
24
25trap "cleanup" EXIT
26
27source ${TESTDIR}/common
28WORKDIR=$(mktemp -d)
29
30REGLOG=${WORKDIR}/reglog
31
32SWTPM_SERVER_NO_DISCONNECT="1" run_swtpm ${SWTPM_INTERFACE} \
33 --tpm2 \
34 --tpmstate dir=${WORKDIR} \
35 --flags not-need-init
36
37pushd ${WORKDIR} &>/dev/null
38
39git clone https://git.code.sf.net/p/ibmtpm20tss/tss ibmtpm20tss-tss
40
41pushd ibmtpm20tss-tss/utils &>/dev/null
42
43git checkout 8440ed
44if [ $? -ne 0 ]; then
45 echo "'Git checkout' failed."
46 exit 1
47fi
48
49make -j4
50make
51
52export TPM_SERVER_NAME=localhost
53export TPM_SERVER_TYPE=raw
54export TPM_COMMAND_PORT=${SWTPM_SERVER_PORT}
55export TPM_PLATFORM_PORT=${SWTPM_CTRL_PORT}
56
57export SWTPM_IOCTL
58
59cat <<_EOF_ > powerup
60#!/usr/bin/env bash
61\${SWTPM_IOCTL} -i --tcp \${TPM_SERVER_NAME}:\${TPM_PLATFORM_PORT}
62exit \$?
63_EOF_
64chmod 755 powerup
65
66./startup
67if [ $? -ne 0 ]; then
68 echo "Startup of TPM2 failed"
69 exit 1
70fi
71
72./reg.sh -a 2>&1 | tee ${REGLOG}
73
74ret=0
75
76if [ -n "$(grep -E "^ ERROR:" ${REGLOG})" ]; then
77 echo "There were test failures running the IBM TSS 2 tests"
78 grep -E "^ ERROR:" ${REGLOG} -B2 -A2
79 ret=1
80fi
81
82# Shut down
83run_swtpm_ioctl ${SWTPM_INTERFACE} -s
84if [ $? -ne 0 ]; then
85 echo "Error: Could not shut down the ${SWTPM_INTERFACE} TPM."
86 ret=1
87fi
88
89if wait_process_gone ${SWTPM_PID} 4; then
90 echo "Error: ${SWTPM_INTERFACE} TPM should not be running anymore."
91 ret=1
92fi
93
94popd &>/dev/null
95popd &>/dev/null
96
97[ $ret -eq 0 ] && echo "OK"
98
99exit $ret