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