leaptable-compiler/run-test.sh

55 lines
1.1 KiB
Bash
Raw Normal View History

2012-01-07 17:39:43 +00:00
#!/bin/bash
2009-01-03 22:59:27 +00:00
# leaptable-compiler/test.sh
2012-01-07 17:39:43 +00:00
#
# Copyright: ©20092012, Laurence Withers
# Author: Laurence Withers <l@lwithers.me.uk>
# License: GPLv3
2009-01-03 22:59:27 +00:00
#
# Running this script on its own will display a summary of all the
# available tests; running it with arguments runs the relevant test.
# This runs a test, setting the correct library path.
run_test() {
EXE=obj/tests/$1
shift
if [ ! -x ${EXE} ]
then
echo "No such test '${EXE}'"
return 1
fi
2012-01-07 17:39:43 +00:00
LD_LIBRARY_PATH="obj:${LD_LIBRARY_PATH}" "${EXE}" "$@" || return 1
2009-01-03 22:59:27 +00:00
return 0
}
# This prints summary output from each test app.
print_tests() {
echo "Available tests"
echo "---------------------------------------------------------------------"
for EXE in obj/tests/*
do
2012-01-07 17:39:43 +00:00
[ -x "${EXE}" ] || continue
NAME="$(echo "${EXE}" | sed 's,obj/tests/,,')"
2009-01-03 22:59:27 +00:00
echo -ne "${NAME}\t"
2012-01-07 17:39:43 +00:00
LD_LIBRARY_PATH="obj:${LD_LIBRARY_PATH}" "${EXE}" --print-summary
2009-01-03 22:59:27 +00:00
done
}
2012-01-07 17:39:43 +00:00
2009-01-03 22:59:27 +00:00
# Main script
if [ $# -eq 0 ]
then
print_tests
exit 0
fi
2012-01-07 17:39:43 +00:00
run_test "$@"
2009-01-03 22:59:27 +00:00
# vim: expandtab:ts=4:sw=4