3 if [ ${SWTPM_TEST_EXPENSIVE:-0} -eq 0 ]; then
7 ROOT
=${abs_top_builddir:-$(pwd)/..}
8 TESTDIR
=${abs_top_testdir:-$(dirname "$0")}
9 ABSTESTDIR
=$
(cd ${TESTDIR} &>/dev
/null
;echo ${PWD})
11 SWTPM_SERVER_PORT
=65426
12 SWTPM_SERVER_NAME
=127.0.0.1
14 SWTPM_INTERFACE
=socket
+socket
18 if [ -n "$pid" ]; then
21 if [ -n ${WORKDIR} ]; then
28 source ${TESTDIR}/common
31 REGLOG
=${WORKDIR}/reglog
33 SWTPM_SERVER_NO_DISCONNECT
="1" run_swtpm
${SWTPM_INTERFACE} \
35 --tpmstate dir
=${WORKDIR} \
38 pushd ${WORKDIR} &>/dev
/null
40 git clone https
://git.code.sf.net
/p
/ibmtpm20tss
/tss ibmtpm20tss-tss
42 pushd ibmtpm20tss-tss
&>/dev
/null
44 git checkout tags
/v1.6
.0
46 echo "'Git checkout' failed."
50 # A v1.6.0 bug work-around:
51 pushd utils
/regtests
&>/dev
/null
52 # We cannot run the EK certificate tests since rootcerts.txt points to
53 # files we do not have
54 for line
in 303 304 305 405 406 407 543 544 545; do
55 sed -i "${line}s/./\#\0/" testcredential.sh
57 for line
in 727 728;do
58 sed -i "${line}s/./\#\0/" testunseal.sh
60 # We do not run the UEFI tests
61 sed -i '2 i exit 0' testevent.sh
64 autoreconf
--force --install
65 unset CFLAGS LDFLAGS LIBS
66 .
/configure
--disable-tpm-1.2
71 rsa3072
=$
(run_swtpm_ioctl
${SWTPM_INTERFACE} --info 4 |
72 sed -n 's/.*"RSAKeySizes":\[\([0-9,]*\)\].*/\1/p' |
74 if [ -z "$rsa3072" ]; then
75 echo "Modifying test cases related to RSA 3072 keys."
77 patch -p2 < "${ABSTESTDIR}/patches/ibmtss2_1.6_rsa2048only.patch"
79 echo "Patching of testsuite failed"
83 echo "swtpm/libtpms support RSA 3072 bit keys"
86 sed -i 's/export CRYPTOLIBRARY.*/export CRYPTOLIBRARY=openssl/' reg.sh
88 # Adjust test suite to TPM 2.0 revision libtpms is implementing
89 revision
=$
(run_swtpm_ioctl
${SWTPM_INTERFACE} --info 1 |
90 sed 's/.*,"revision":\([^\}]*\).*/\1/')
91 echo "Libtpms implements TPM 2.0 revision ${revision}."
92 if [ $revision -lt 155 ]; then
93 echo "Removing revision 155 test cases."
94 for t
in regtests
/testattest155.sh regtests
/testx509.sh
100 # CAP_ACT was introduced later than 155
101 for line
in 123 124 125; do
102 sed -i "${line}s/./\#\0/" regtests
/testgetcap.sh
106 export TPM_SERVER_NAME
=127.0.0.1
107 export TPM_INTERFACE_TYPE
=socsim
108 export TPM_COMMAND_PORT
=${SWTPM_SERVER_PORT}
109 export TPM_PLATFORM_PORT
=${SWTPM_CTRL_PORT}
113 cat <<_EOF_ > powerup
115 \${SWTPM_IOCTL} -i --tcp \${TPM_SERVER_NAME}:\${TPM_PLATFORM_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"