]>
git.proxmox.com Git - swtpm.git/blob - tests/_test_setbuffersize
3 # For the license, see the LICENSE file in the root directory.
6 ROOT
=${abs_top_builddir:-$(pwd)/..}
7 TESTDIR
=${abs_top_testdir:-$(dirname "$0")}
9 VTPM_NAME
="vtpm-test-setbuffersize"
10 SWTPM_DEV_NAME
="/dev/${VTPM_NAME}"
11 export TPM_PATH
=$
(mktemp
-d)
12 STATE_FILE
=$TPM_PATH/tpm-00.permall
13 VOLATILE_STATE_FILE
=$TPM_PATH/tpm-00.volatilestate
14 SWTPM_CMD_UNIX_PATH
=${TPM_PATH}/unix-cmd.sock
15 SWTPM_CTRL_UNIX_PATH
=${TPM_PATH}/unix-ctrl.sock
16 SWTPM_INTERFACE
=${SWTPM_INTERFACE:-cuse}
17 OUTFILE
=${TPM_PATH}/output
22 if [ -n "$pid" ]; then
30 [ "${SWTPM_INTERFACE}" == cuse
] && source ${TESTDIR}/test_cuse
31 source ${TESTDIR}/common
33 rm -f $STATE_FILE $VOLATILE_STATE_FILE 2>/dev
/null
35 run_swtpm
${SWTPM_INTERFACE}
37 kill_quiet
-0 ${SWTPM_PID}
39 echo "Error: ${SWTPM_INTERFACE} TPM did not start."
43 # Check the buffer size
44 run_swtpm_ioctl
${SWTPM_INTERFACE} -b 0 > ${OUTFILE}
46 echo "Error: Could not get the buffersize of the ${SWTPM_INTERFACE} TPM."
51 if [ -z "$(grep "TPM buffersize
" ${OUTFILE} | grep 4096)" ]; then
52 echo "Error: The TPM buffersize of the ${SWTPM_INTERFACE} TPM is not 4096."
57 run_swtpm_ioctl
${SWTPM_INTERFACE} -b 4000 > ${OUTFILE}
59 echo "Error: Could not set the buffersize of the ${SWTPM_INTERFACE} TPM."
64 if [ -z "$(grep "TPM buffersize
" ${OUTFILE} | grep 4000)" ]; then
65 echo "Error: The TPM buffersize of the ${SWTPM_INTERFACE} TPM is not 4000."
70 run_swtpm_ioctl
${SWTPM_INTERFACE} -i
72 echo "Error: Could not initialize the ${SWTPM_INTERFACE} TPM."
76 # Set the buffer size -- should fail
77 ERR
="$(run_swtpm_ioctl ${SWTPM_INTERFACE} -b 4096 2>&1)"
79 echo "Error: Could set the buffersize while the ${SWTPM_INTERFACE} TPM is running."
82 exp
="TPM result from PTM_SET_BUFFERSIZE: 0xa"
83 if [ "$ERR" != "$exp" ]; then
84 echo "Error: Unexpected error message"
90 kill_quiet
-0 ${SWTPM_PID} 2>/dev
/null
92 echo "Error: ${SWTPM_INTERFACE} TPM not running anymore after INIT."
96 run_swtpm_ioctl
${SWTPM_INTERFACE} -s
98 echo "Error: Could not shut down the ${SWTPM_INTERFACE} TPM."
102 if wait_process_gone
${SWTPM_PID} 4; then
103 echo "Error: ${SWTPM_INTERFACE} TPM should not be running anymore."
107 if [ ! -e $STATE_FILE ]; then
108 echo "Error: TPM state file $STATE_FILE does not exist."