1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
|
# SPDX-License-Identifier: BSD-3-Clause
source helpers.sh
start_up
out=out.yaml
cleanup() {
rm -f $out
shut_down
}
trap cleanup EXIT
function yaml_to_list() {
python << pyscript
from __future__ import print_function
import sys
import yaml
with open("$1") as f:
try:
y = yaml.safe_load(f)
print(' '.join(y))
except yaml.YAMLError as exc:
sys.exit(exc)
pyscript
}
tpm2 getcap -l | grep -v 'vendor' > $out
caplist=$(yaml_to_list $out)
for c in $caplist; do
tpm2 getcap "$c" > $out
yaml_verify $out
done;
# negative tests
trap - ERR
# Regression test, ensure that getcap -c never accepts prefix matches
tpm2 getcap -Q --capability="comma" 2>/dev/null
if [ $? -eq -1 ]; then
echo "Expected \"tpm2 getcap -Q --capability=\"comma\"\" to fail."
exit 1
fi
exit 0
|