paul@226 | 1 | #!/bin/sh |
paul@226 | 2 | |
paul@226 | 3 | # Run a test program with its own image. |
paul@226 | 4 | # |
paul@226 | 5 | # Copyright (C) 2021 Paul Boddie <paul@boddie.org.uk> |
paul@226 | 6 | # |
paul@226 | 7 | # This program is free software; you can redistribute it and/or |
paul@226 | 8 | # modify it under the terms of the GNU General Public License as |
paul@226 | 9 | # published by the Free Software Foundation; either version 2 of |
paul@226 | 10 | # the License, or (at your option) any later version. |
paul@226 | 11 | # |
paul@226 | 12 | # This program is distributed in the hope that it will be useful, |
paul@226 | 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
paul@226 | 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
paul@226 | 15 | # GNU General Public License for more details. |
paul@226 | 16 | # |
paul@226 | 17 | # You should have received a copy of the GNU General Public License |
paul@226 | 18 | # along with this program; if not, write to the Free Software |
paul@226 | 19 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, |
paul@226 | 20 | # Boston, MA 02110-1301, USA |
paul@226 | 21 | |
paul@226 | 22 | THISDIR=`dirname "$0"` |
paul@226 | 23 | PROGNAME=`basename "$0"` |
paul@226 | 24 | |
paul@226 | 25 | # Obtain any option. |
paul@226 | 26 | |
paul@226 | 27 | if [ "$1" = '-k' ] ; then |
paul@226 | 28 | KEEP_IMAGE="$1" |
paul@226 | 29 | shift 1 |
paul@226 | 30 | else |
paul@226 | 31 | KEEP_IMAGE= |
paul@226 | 32 | fi |
paul@226 | 33 | |
paul@226 | 34 | # Obtain the test name. |
paul@226 | 35 | |
paul@226 | 36 | TEST="$1" |
paul@226 | 37 | TESTPROG="$THISDIR/$TEST" |
paul@226 | 38 | |
paul@226 | 39 | if [ ! "$TEST" ] || [ ! -e "$TESTPROG" ] ; then |
paul@226 | 40 | echo "Usage: $PROGNAME [ -k ] <test>" 1>&2 |
paul@226 | 41 | exit 1 |
paul@226 | 42 | fi |
paul@226 | 43 | |
paul@226 | 44 | # Indicate the library location. |
paul@226 | 45 | |
paul@226 | 46 | export LD_LIBRARY_PATH="$THISDIR":"$LD_LIBRARY_PATH" |
paul@226 | 47 | |
paul@226 | 48 | # Make an image to use for testing. |
paul@226 | 49 | |
paul@226 | 50 | IMAGE=`"$THISDIR/mkfs"` |
paul@226 | 51 | |
paul@226 | 52 | # Run the test program. |
paul@226 | 53 | |
paul@226 | 54 | "$TESTPROG" "$IMAGE" |
paul@226 | 55 | |
paul@226 | 56 | # Show the image filename or remove the image. |
paul@226 | 57 | |
paul@226 | 58 | if [ "$KEEP_IMAGE" ] ; then |
paul@226 | 59 | echo "$IMAGE" |
paul@226 | 60 | else |
paul@226 | 61 | rm "$IMAGE" |
paul@226 | 62 | fi |
paul@226 | 63 | |
paul@226 | 64 | # vim: tabstop=4 expandtab shiftwidth=4 |