tests: Wrap the fuzzer test in a script

Wrap the fuzzer test in a script to we can set up a per fuzzer
temporary directory where the NvChip file is written into.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
This commit is contained in:
Stefan Berger 2018-12-09 14:10:11 -05:00 committed by Stefan Berger
parent bc4aab3613
commit ba56737b93
2 changed files with 35 additions and 1 deletions

2
README
View File

@ -88,7 +88,7 @@ Fuzz testing is known to work with Fedora 28 or later. It requires that the
Ex:
$ ./configure --with-openssl --with-tpm2 --enable-sanitizers --enable-fuzzer CC=clang
$ make && make -C tests fuzz
$ tests/fuzz tests/corpus-execute-command
$ tests/run-fuzzer.sh
Maintainers
-----------

34
tests/run-fuzzer.sh Executable file
View File

@ -0,0 +1,34 @@
#!/usr/bin/env bash
# For the license, see the LICENSE file in the root directory.
DIR=${PWD}/$(dirname "$0")
ROOT=${DIR}/..
WORKDIR=$(mktemp -d)
export LD_LIBRARY_PATH=${ROOT}/src/.libs
if ! [ -d ${LD_LIBRARY_PATH} ]; then
echo "Wrong path to libtpms library: ${LD_LIBRARY_PATH}"
exit 1
fi
if ! [ -f "$(readlink -f ${LD_LIBRARY_PATH}/libtpms.so)" ]; then
echo "Cannot find libtpms at ${LD_LIBRARY_PATH}/libtpms.so"
exit 1
fi
function cleanup()
{
rm -rf ${WORKDIR}
}
trap "cleanup" QUIT EXIT
pushd $WORKDIR
${DIR}/fuzz $@ ${DIR}/corpus-execute-command
rc=$?
popd
exit $rc