swtpm/tests/test_tpm2_pcap
Stefan Berger 7d89462256 tests: Add a test for the --pcap command line option
Add a test for the --pcap option exercising its file, file descriptor, mode
and truncate parameters and check that the pcap file has the expected size
and mode bits.

On Cygwin the mode bits that are actually set for the user depend somewhat
on the mode bits set for the group. Therefore, some adjustments need to be
made to the expected mode bits.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2026-02-27 14:56:36 -05:00

43 lines
987 B
Bash
Executable File

#!/usr/bin/env bash
TESTDIR=${abs_top_testdir:-$(dirname "$0")}
ROOT=${abs_top_builddir:-$(dirname "$0")/..}
source "${TESTDIR}/common"
skip_test_no_tpm20 "${SWTPM_EXE}"
cd "$(dirname "$0")" || exit 1
export SWTPM_IOCTL_BUFFERSIZE=100
export SWTPM_INTERFACE=cuse
bash _test_tpm2_pcap
ret=$?
[ $ret -ne 0 ] && [ $ret -ne 77 ] && exit $ret
export SWTPM_IOCTL_BUFFERSIZE=4096
export SWTPM_INTERFACE=cuse
bash _test_tpm2_pcap
ret=$?
[ $ret -ne 0 ] && [ $ret -ne 77 ] && exit $ret
export SWTPM_INTERFACE=socket+socket
export SWTPM_SERVER_NAME=localhost
export SWTPM_SERVER_PORT=65486
export SWTPM_CTRL_PORT=65487
bash _test_tpm2_pcap
ret=$?
[ $ret -ne 0 ] && [ $ret -ne 77 ] && exit $ret
export SWTPM_INTERFACE=socket+unix
export SWTPM_SERVER_NAME=localhost
export SWTPM_SERVER_PORT=65486
bash _test_tpm2_pcap
ret=$?
[ $ret -ne 0 ] && [ $ret -ne 77 ] && exit $ret
export SWTPM_INTERFACE=unix+unix
bash _test_tpm2_pcap
ret=$?
[ $ret -ne 0 ] && [ $ret -ne 77 ] && exit $ret
exit 0