swtpm/tests/test_cuse
Stefan Berger 0da1dcc8a3 tests: Derive support for CUSE from SWTPM_EXE help screen
Use 'swtpm --help | grep cuse' to determine whether CUSE interface
is supported and CUSE related tests need to run. Make sure that
SWTPM_EXE is available when test_cuse is sourced.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2024-08-26 20:00:14 -04:00

32 lines
634 B
Plaintext

# shellcheck shell=bash
# For the license, see the LICENSE file in the root directory.
if ! [[ "$(uname -s)" =~ Linux ]]; then
echo "Need Linux to run test with CUSE interface."
exit 77
fi
if [ "$(id -u)" -ne 0 ]; then
echo "Need to be root to run test with CUSE interface."
exit 77
fi
if [ -z "${SWTPM_EXE}" ]; then
echo "Error: SWTPM_EXE must be set"
exit 1
fi
if ! ${SWTPM_EXE} --help | grep -q cuse; then
echo "Skipping test: swtpm was not compiled with CUSE interface"
exit 77
fi
if [ ! -c /dev/cuse ]; then
if ! modprobe cuse; then
echo "Skipping test using CUSE module: module not available"
exit 77
fi
fi