]>
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 | ||
41 | pushd ibmtpm20tss-tss/utils &>/dev/null | |
42 | ||
43 | git checkout 8440ed | |
44 | if [ $? -ne 0 ]; then | |
45 | echo "'Git checkout' failed." | |
46 | exit 1 | |
47 | fi | |
48 | ||
49 | make -j4 | |
50 | make | |
51 | ||
52 | export TPM_SERVER_NAME=localhost | |
53 | export TPM_SERVER_TYPE=raw | |
54 | export TPM_COMMAND_PORT=${SWTPM_SERVER_PORT} | |
55 | export TPM_PLATFORM_PORT=${SWTPM_CTRL_PORT} | |
56 | ||
57 | export SWTPM_IOCTL | |
58 | ||
59 | cat <<_EOF_ > powerup | |
60 | #!/usr/bin/env bash | |
61 | \${SWTPM_IOCTL} -i --tcp \${TPM_SERVER_NAME}:\${TPM_PLATFORM_PORT} | |
62 | exit \$? | |
63 | _EOF_ | |
64 | chmod 755 powerup | |
65 | ||
66 | ./startup | |
67 | if [ $? -ne 0 ]; then | |
68 | echo "Startup of TPM2 failed" | |
69 | exit 1 | |
70 | fi | |
71 | ||
72 | ./reg.sh -a 2>&1 | tee ${REGLOG} | |
73 | ||
74 | ret=0 | |
75 | ||
76 | if [ -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 | |
80 | fi | |
81 | ||
82 | # Shut down | |
83 | run_swtpm_ioctl ${SWTPM_INTERFACE} -s | |
84 | if [ $? -ne 0 ]; then | |
85 | echo "Error: Could not shut down the ${SWTPM_INTERFACE} TPM." | |
86 | ret=1 | |
87 | fi | |
88 | ||
89 | if wait_process_gone ${SWTPM_PID} 4; then | |
90 | echo "Error: ${SWTPM_INTERFACE} TPM should not be running anymore." | |
91 | ret=1 | |
92 | fi | |
93 | ||
94 | popd &>/dev/null | |
95 | popd &>/dev/null | |
96 | ||
97 | [ $ret -eq 0 ] && echo "OK" | |
98 | ||
99 | exit $ret |