mirror of
https://github.com/stefanberger/libtpms
synced 2025-12-25 21:26:46 +00:00
tests: Refactor repetitive test scripts to use one common script
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
This commit is contained in:
parent
eb8a76807a
commit
ddbc966ccc
@ -83,6 +83,7 @@ EXTRA_DIST = \
|
||||
tpm2_createprimary.sh \
|
||||
tpm2_pcr_read.c \
|
||||
tpm2_pcr_read.sh \
|
||||
tpm2_run_test.sh \
|
||||
tpm2_selftest.c \
|
||||
tpm2_selftest.sh \
|
||||
fuzz.sh
|
||||
|
||||
@ -2,36 +2,7 @@
|
||||
|
||||
# For the license, see the LICENSE file in the root directory.
|
||||
|
||||
ROOT=${abs_top_builddir:-$(pwd)/..}
|
||||
TESTDIR=${abs_top_testdir:-$(dirname "$0")}
|
||||
DIR=${PWD}
|
||||
DIR=$(dirname "$0")
|
||||
|
||||
WORKDIR=$(mktemp -d)
|
||||
|
||||
. ${TESTDIR}/common
|
||||
|
||||
function cleanup()
|
||||
{
|
||||
rm -rf ${WORKDIR}
|
||||
}
|
||||
|
||||
trap "cleanup" QUIT EXIT
|
||||
|
||||
pushd $WORKDIR &>/dev/null
|
||||
|
||||
${DIR}/tpm2_createprimary
|
||||
rc=$?
|
||||
|
||||
fs=$(get_filesize NVChip)
|
||||
[ $? -ne 0 ] && exit 1
|
||||
exp=176832
|
||||
if [ $fs -ne $exp ]; then
|
||||
echo "Error: Unexpected size of NVChip file."
|
||||
echo "Expected: $exp"
|
||||
echo "Got : $fs"
|
||||
rc=1
|
||||
fi
|
||||
|
||||
popd &>/dev/null
|
||||
|
||||
exit $rc
|
||||
"${DIR}/tpm2_run_test.sh" tpm2_createprimary
|
||||
exit $?
|
||||
|
||||
@ -2,36 +2,7 @@
|
||||
|
||||
# For the license, see the LICENSE file in the root directory.
|
||||
|
||||
ROOT=${abs_top_builddir:-$(pwd)/..}
|
||||
TESTDIR=${abs_top_testdir:-$(dirname "$0")}
|
||||
DIR=${PWD}
|
||||
DIR=$(dirname "$0")
|
||||
|
||||
WORKDIR=$(mktemp -d)
|
||||
|
||||
. ${TESTDIR}/common
|
||||
|
||||
function cleanup()
|
||||
{
|
||||
rm -rf ${WORKDIR}
|
||||
}
|
||||
|
||||
trap "cleanup" QUIT EXIT
|
||||
|
||||
pushd $WORKDIR &>/dev/null
|
||||
|
||||
${DIR}/tpm2_pcr_read
|
||||
rc=$?
|
||||
|
||||
fs=$(get_filesize NVChip)
|
||||
[ $? -ne 0 ] && exit 1
|
||||
exp=176832
|
||||
if [ $fs -ne $exp ]; then
|
||||
echo "Error: Unexpected size of NVChip file."
|
||||
echo "Expected: $exp"
|
||||
echo "Got : $fs"
|
||||
rc=1
|
||||
fi
|
||||
|
||||
popd &>/dev/null
|
||||
|
||||
exit $rc
|
||||
"${DIR}/tpm2_run_test.sh" tpm2_pcr_read
|
||||
exit $?
|
||||
|
||||
38
tests/tpm2_run_test.sh
Executable file
38
tests/tpm2_run_test.sh
Executable file
@ -0,0 +1,38 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# For the license, see the LICENSE file in the root directory.
|
||||
|
||||
ROOT=${abs_top_builddir:-$(pwd)/..}
|
||||
TESTDIR=${abs_top_testdir:-$(dirname "$0")}
|
||||
DIR=${PWD}
|
||||
|
||||
WORKDIR=$(mktemp -d)
|
||||
|
||||
. "${TESTDIR}/common"
|
||||
|
||||
function cleanup()
|
||||
{
|
||||
rm -rf "${WORKDIR}"
|
||||
}
|
||||
|
||||
trap "cleanup" QUIT EXIT
|
||||
|
||||
pushd "$WORKDIR" &>/dev/null || exit 1
|
||||
|
||||
"${DIR}/${1}"
|
||||
rc=$?
|
||||
|
||||
if ! fs=$(get_filesize NVChip); then
|
||||
exit 1
|
||||
fi
|
||||
exp=176832
|
||||
if [ "$fs" -ne "$exp" ]; then
|
||||
echo "Error: Unexpected size of NVChip file."
|
||||
echo "Expected: $exp"
|
||||
echo "Got : $fs"
|
||||
rc=1
|
||||
fi
|
||||
|
||||
popd &>/dev/null || exit 1
|
||||
|
||||
exit $rc
|
||||
@ -2,36 +2,7 @@
|
||||
|
||||
# For the license, see the LICENSE file in the root directory.
|
||||
|
||||
ROOT=${abs_top_builddir:-$(pwd)/..}
|
||||
TESTDIR=${abs_top_testdir:-$(dirname "$0")}
|
||||
DIR=${PWD}
|
||||
DIR=$(dirname "$0")
|
||||
|
||||
WORKDIR=$(mktemp -d)
|
||||
|
||||
. ${TESTDIR}/common
|
||||
|
||||
function cleanup()
|
||||
{
|
||||
rm -rf ${WORKDIR}
|
||||
}
|
||||
|
||||
trap "cleanup" QUIT EXIT
|
||||
|
||||
pushd $WORKDIR &>/dev/null
|
||||
|
||||
${DIR}/tpm2_selftest
|
||||
rc=$?
|
||||
|
||||
fs=$(get_filesize NVChip)
|
||||
[ $? -ne 0 ] && exit 1
|
||||
exp=176832
|
||||
if [ $fs -ne $exp ]; then
|
||||
echo "Error: Unexpected size of NVChip file."
|
||||
echo "Expected: $exp"
|
||||
echo "Got : $fs"
|
||||
rc=1
|
||||
fi
|
||||
|
||||
popd &>/dev/null
|
||||
|
||||
exit $rc
|
||||
"${DIR}/tpm2_run_test.sh" tpm2_selftest
|
||||
exit $?
|
||||
|
||||
Loading…
Reference in New Issue
Block a user