]>
Commit | Line | Data |
---|---|---|
03c7fe45 SB |
1 | #!/usr/bin/env bash |
2 | ||
3 | if [ ${SWTPM_TEST_EXPENSIVE:-0} -eq 0 ]; then | |
4 | exit 77 | |
5 | fi | |
6 | ||
7 | ROOT=${abs_top_builddir:-$(pwd)/..} | |
8 | TESTDIR=${abs_top_testdir:-$(dirname "$0")} | |
9 | ||
10 | SWTPM_SERVER_PORT=65426 | |
11 | SWTPM_SERVER_NAME=localhost | |
12 | SWTPM_CTRL_PORT=65427 | |
13 | SWTPM_INTERFACE=socket+socket | |
14 | ||
15 | function 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 | ||
25 | trap "cleanup" EXIT | |
26 | ||
27 | source ${TESTDIR}/common | |
28 | WORKDIR=$(mktemp -d) | |
29 | ||
30 | REGLOG=${WORKDIR}/reglog | |
31 | ||
32 | SWTPM_SERVER_NO_DISCONNECT="1" run_swtpm ${SWTPM_INTERFACE} \ | |
33 | --tpm2 \ | |
34 | --tpmstate dir=${WORKDIR} \ | |
35 | --flags not-need-init | |
36 | ||
37 | pushd ${WORKDIR} &>/dev/null | |
38 | ||
39 | git clone https://git.code.sf.net/p/ibmtpm20tss/tss ibmtpm20tss-tss | |
40 | ||
4ba6012c | 41 | pushd ibmtpm20tss-tss &>/dev/null |
03c7fe45 | 42 | |
8dc2415d | 43 | git checkout tags/v1.3.0 |
03c7fe45 SB |
44 | if [ $? -ne 0 ]; then |
45 | echo "'Git checkout' failed." | |
46 | exit 1 | |
47 | fi | |
48 | ||
4ba6012c | 49 | autoreconf --force --install |
8dc2415d SB |
50 | #FIXME: Need to pass LIBS on Ubuntu to avoid X509_free linker errors |
51 | CFLAGS="" LDFLAGS="" LIBS="-lz -lssl -lcrypto" ./configure --disable-tpm-1.2 | |
03c7fe45 | 52 | make -j4 |
4ba6012c SB |
53 | |
54 | pushd utils | |
8dc2415d | 55 | |
4ba6012c | 56 | sed -i 's/export CRYPTOLIBRARY.*/export CRYPTOLIBRARY=openssl/' reg.sh |
03c7fe45 | 57 | |
8dc2415d SB |
58 | # Adjust test suite to TPM 2.0 revision libtpms is implementing |
59 | revision=$(run_swtpm_ioctl ${SWTPM_INTERFACE} --info 1 | | |
60 | sed 's/.*,"revision":\([^\}]*\).*/\1/') | |
61 | echo "Libtpms implements TPM 2.0 revision ${revision}." | |
62 | if [ $revision -lt 155 ]; then | |
63 | echo "Removing revision 155 test cases." | |
64 | for t in regtests/testattest155.sh regtests/testx509.sh | |
65 | do | |
66 | rm "${t}" | |
67 | touch "${t}" | |
68 | chmod 777 "${t}" | |
69 | done | |
70 | fi | |
71 | ||
03c7fe45 | 72 | export TPM_SERVER_NAME=localhost |
a1c9aedd | 73 | export TPM_INTERFACE_TYPE=socsim |
03c7fe45 SB |
74 | export TPM_COMMAND_PORT=${SWTPM_SERVER_PORT} |
75 | export TPM_PLATFORM_PORT=${SWTPM_CTRL_PORT} | |
76 | ||
77 | export SWTPM_IOCTL | |
78 | ||
79 | cat <<_EOF_ > powerup | |
80 | #!/usr/bin/env bash | |
81 | \${SWTPM_IOCTL} -i --tcp \${TPM_SERVER_NAME}:\${TPM_PLATFORM_PORT} | |
82 | exit \$? | |
83 | _EOF_ | |
84 | chmod 755 powerup | |
85 | ||
86 | ./startup | |
87 | if [ $? -ne 0 ]; then | |
88 | echo "Startup of TPM2 failed" | |
89 | exit 1 | |
90 | fi | |
91 | ||
92 | ./reg.sh -a 2>&1 | tee ${REGLOG} | |
93 | ||
94 | ret=0 | |
95 | ||
96 | if [ -n "$(grep -E "^ ERROR:" ${REGLOG})" ]; then | |
97 | echo "There were test failures running the IBM TSS 2 tests" | |
98 | grep -E "^ ERROR:" ${REGLOG} -B2 -A2 | |
99 | ret=1 | |
100 | fi | |
101 | ||
102 | # Shut down | |
103 | run_swtpm_ioctl ${SWTPM_INTERFACE} -s | |
104 | if [ $? -ne 0 ]; then | |
105 | echo "Error: Could not shut down the ${SWTPM_INTERFACE} TPM." | |
106 | ret=1 | |
107 | fi | |
108 | ||
109 | if wait_process_gone ${SWTPM_PID} 4; then | |
110 | echo "Error: ${SWTPM_INTERFACE} TPM should not be running anymore." | |
111 | ret=1 | |
112 | fi | |
113 | ||
4ba6012c | 114 | popd &>/dev/null |
03c7fe45 SB |
115 | popd &>/dev/null |
116 | popd &>/dev/null | |
117 | ||
118 | [ $ret -eq 0 ] && echo "OK" | |
119 | ||
120 | exit $ret |