3 if [ ${SWTPM_TEST_EXPENSIVE:-0} -eq 0 ]; then
7 if [ -z "$(type openssl)" ]; then
8 echo "Openssl command line tool is required."
12 if [ -n "$(openssl version | grep -E "^OpenSSL
3")" ]; then
13 echo "IBMTSS2 v1.6 test suite does not work with OpenSSL 3.0"
17 ROOT
=${abs_top_builddir:-$(pwd)/..}
18 TESTDIR
=${abs_top_testdir:-$(dirname "$0")}
19 ABSTESTDIR
=$
(cd ${TESTDIR} &>/dev
/null
;echo ${PWD})
21 PATCHESDIR
=${ABSTESTDIR}/patches
23 SWTPM_SERVER_PORT
=65426
24 SWTPM_SERVER_NAME
=127.0.0.1
26 SWTPM_INTERFACE
=socket
+socket
30 if [ -n "$pid" ]; then
33 if [ -n ${WORKDIR} ]; then
40 source ${TESTDIR}/common
41 skip_test_no_tpm20
"${SWTPM_EXE}"
43 WORKDIR
="$(mktemp -d)" ||
exit 1
45 REGLOG
=${WORKDIR}/reglog
47 SWTPM_SERVER_NO_DISCONNECT
="1" run_swtpm
${SWTPM_INTERFACE} \
49 --tpmstate dir
=${WORKDIR} \
52 pushd ${WORKDIR} &>/dev
/null
54 git clone https
://git.code.sf.net
/p
/ibmtpm20tss
/tss ibmtpm20tss-tss
56 pushd ibmtpm20tss-tss
&>/dev
/null
58 git checkout tags
/v1.6
.0
60 echo "'Git checkout' failed."
64 # To be able to apply the patches we need to to set some variables
65 # for user that don't have this set up properly
66 git config
--local user.name
test
67 git config
--local user.email
test@
test.
test
69 # A v1.6.0 bug work-around:
70 # We cannot run the EK certificate tests since rootcerts.txt points to
71 # files we do not have
72 git am
< ${PATCHESDIR}/0001-Deactivate-test-cases-accessing-rootcerts.txt.
patch
74 # Implement 'powerup' for swtpm
75 git am
< ${PATCHESDIR}/0002-Implement-powerup-for-swtpm.
patch
77 # set CRYPTOLIBRARY=openssl
78 git am
< ${PATCHESDIR}/0003-Set-CRYPTOLIBRARY-to-openssl.
patch
80 # Store and restore volatile state at every step
81 git am
< ${PATCHESDIR}/0004-Store-and-restore-volatile-state-at-every-step.
patch
83 # Disable 'Events' test
84 git am
< ${PATCHESDIR}/0005-Disable-tests-related-to-events.
patch
86 rsa3072
=$
(run_swtpm_ioctl
${SWTPM_INTERFACE} --info 4 |
87 sed -n 's/.*"RSAKeySizes":\[\([0-9,]*\)\].*/\1/p' |
89 if [ -z "$rsa3072" ]; then
90 echo "Modifying test cases related to RSA 3072 keys."
91 git am
< ${PATCHESDIR}/0006-Disable-testing-with-RSA-3072.
patch
93 echo "swtpm/libtpms support RSA 3072 bit keys"
96 # Adjust test suite to TPM 2.0 revision libtpms is implementing
97 revision
=$
(run_swtpm_ioctl
${SWTPM_INTERFACE} --info 1 |
98 sed 's/.*,"revision":\([^\}]*\).*/\1/')
99 echo "Libtpms implements TPM 2.0 revision ${revision}."
100 if [ $revision -lt 155 ]; then
101 echo "Removing revision 155 and later test cases."
102 git am
< ${PATCHESDIR}/0007-Disable-rev155-test-cases.
patch
103 git am
< ${PATCHESDIR}/0008-Disable-x509-test-cases.
patch
104 git am
< ${PATCHESDIR}/0009-Disable-getcapability-TPM_CAP_ACT.
patch
107 autoreconf
--force --install
108 unset CFLAGS LDFLAGS LIBS
109 .
/configure
--disable-tpm-1.2
114 export TPM_SERVER_NAME
=127.0.0.1
115 export TPM_INTERFACE_TYPE
=socsim
116 export TPM_COMMAND_PORT
=${SWTPM_SERVER_PORT}
117 export TPM_PLATFORM_PORT
=${SWTPM_CTRL_PORT}
122 if [ $?
-ne 0 ]; then
123 echo "Startup of TPM2 failed"
127 .
/reg.sh
-a 2>&1 |
tee ${REGLOG}
131 if [ -n "$(grep -E "^ ERROR
:" ${REGLOG})" ]; then
132 echo "There were test failures running the IBM TSS 2 tests"
133 grep -E "^ ERROR:" ${REGLOG} -B2 -A2
138 run_swtpm_ioctl
${SWTPM_INTERFACE} -s
139 if [ $?
-ne 0 ]; then
140 echo "Error: Could not shut down the ${SWTPM_INTERFACE} TPM."
144 if wait_process_gone
${SWTPM_PID} 4; then
145 echo "Error: ${SWTPM_INTERFACE} TPM should not be running anymore."
153 [ $ret -eq 0 ] && echo "OK"