1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/libe2access/host/run_test Tue Dec 28 01:37:59 2021 +0100
1.3 @@ -0,0 +1,64 @@
1.4 +#!/bin/sh
1.5 +
1.6 +# Run a test program with its own image.
1.7 +#
1.8 +# Copyright (C) 2021 Paul Boddie <paul@boddie.org.uk>
1.9 +#
1.10 +# This program is free software; you can redistribute it and/or
1.11 +# modify it under the terms of the GNU General Public License as
1.12 +# published by the Free Software Foundation; either version 2 of
1.13 +# the License, or (at your option) any later version.
1.14 +#
1.15 +# This program is distributed in the hope that it will be useful,
1.16 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
1.17 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1.18 +# GNU General Public License for more details.
1.19 +#
1.20 +# You should have received a copy of the GNU General Public License
1.21 +# along with this program; if not, write to the Free Software
1.22 +# Foundation, Inc., 51 Franklin Street, Fifth Floor,
1.23 +# Boston, MA 02110-1301, USA
1.24 +
1.25 +THISDIR=`dirname "$0"`
1.26 +PROGNAME=`basename "$0"`
1.27 +
1.28 +# Obtain any option.
1.29 +
1.30 +if [ "$1" = '-k' ] ; then
1.31 + KEEP_IMAGE="$1"
1.32 + shift 1
1.33 +else
1.34 + KEEP_IMAGE=
1.35 +fi
1.36 +
1.37 +# Obtain the test name.
1.38 +
1.39 +TEST="$1"
1.40 +TESTPROG="$THISDIR/$TEST"
1.41 +
1.42 +if [ ! "$TEST" ] || [ ! -e "$TESTPROG" ] ; then
1.43 + echo "Usage: $PROGNAME [ -k ] <test>" 1>&2
1.44 + exit 1
1.45 +fi
1.46 +
1.47 +# Indicate the library location.
1.48 +
1.49 +export LD_LIBRARY_PATH="$THISDIR":"$LD_LIBRARY_PATH"
1.50 +
1.51 +# Make an image to use for testing.
1.52 +
1.53 +IMAGE=`"$THISDIR/mkfs"`
1.54 +
1.55 +# Run the test program.
1.56 +
1.57 +"$TESTPROG" "$IMAGE"
1.58 +
1.59 +# Show the image filename or remove the image.
1.60 +
1.61 +if [ "$KEEP_IMAGE" ] ; then
1.62 + echo "$IMAGE"
1.63 +else
1.64 + rm "$IMAGE"
1.65 +fi
1.66 +
1.67 +# vim: tabstop=4 expandtab shiftwidth=4