3 if ! [[ "$(uname -s)" =~ Linux
]]; then
4 echo "This test currently only runs on Linux."
8 if [ "$(id -u)" -ne 0 ]; then
9 echo "Need to be root to run this test."
13 STATEDIR
="$(mktemp -d)" ||
exit 1
14 STATEIMG
=$STATEDIR/tpm2.img
17 trap "cleanup" SIGTERM EXIT
21 if [ -n "$STATEFILE" ]; then
26 if [ -z "$(type -P fallocate)" ]; then
27 echo "This test requires the fallocate tool."
31 if [ -z "$(fallocate --help 2>&1 | grep -E "\
-\
-posix")" ]; then
32 echo "This test requires fallocate to support --posix."
36 if [ -z "$(type -P losetup)" ]; then
37 echo "This test requires the losetup tool."
42 fallocate
--posix -l $
((4 * 1024 * 1024)) "$STATEIMG"
44 STATEFILE
=$
(losetup
--show -f $STATEIMG)
46 export SWTPM_TEST_LINEAR_FILE
=1
47 export TPM_COMMAND_PORT
=65462
50 # don't exec so cleanup will remove the loop device
51 $
(dirname $0)/test_tpm2_save_load_state_2