#! /bin/sh

goal="check automatic byte swapping"
bru=${BRU:-bru}

# Parse our args.  Options include:
#
#	-s	Print our one line test goal and quit
#

while true
do
	case $1 in
		-d)	dflag="on"
			shift
			;;
		-g)	echo $goal
			exit 0
			;;
		*bru*)	bru=$1
			shift
			;;
		*)	break
			;;
	esac
done

if [ "$dflag" != "on" ]
then
	trap "rm -rf bru.out bru.out2 ; exit 1" 1 2 13 15
fi

# First clean up any stuff that may be left from a previous test.

rm -f bru.out bru.out2

# Run test.  Always recompile to avoid problems with imported
# binaries from "foreign" machines.

cc -o cswap cswap.c

$bru -cvf bru.out cswap.c
echo "bru exit status was $?"
$bru -ivf bru.out
echo "bru exit status was $?"

./cswap <bru.out >bru.out2

$bru -ivf bru.out2
echo "bru exit status was $?"

if [ "$dflag" != "on" ]
then
	rm -rf bru.out bru.out2
fi

exit 0




