tests: Use regex to compare --print-states sizes output

Older versions of libtpms produced smaller initial state files.
Therefore, use a regular expression to compare the sizes.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
This commit is contained in:
Stefan Berger 2024-06-17 11:55:42 -04:00 committed by Stefan Berger
parent 76b58d7e09
commit f756ee8a28

View File

@ -101,7 +101,8 @@ if [ "${SWTPM_IFACE}" = socket ]; then
exit 1
fi
exp='\{ "type": "swtpm", "states": \[ \{"name": "permall", "size": 1315\} \] \}'
# sizes: libtpms v0.7: 1181 ; >= v0.8: 1315
exp='^\{ "type": "swtpm", "states": \[ \{"name": "permall", "size": 1[0-9]{3}\} \] \}$'
if ! [[ ${msg} =~ ${exp} ]]; then
echo "Unexpected response from ${SWTPM_IFACE} TPM to --print-states:"
echo "Actual : ${msg}"