blob: c4e076fa1b057c534b66e90fd6e21e9a0b549a23 [file] [log] [blame]
#! /bin/sh
#
# Copyright 2018 Gavin D. Howard
#
# Permission to use, copy, modify, and/or distribute this software for any
# purpose with or without fee is hereby granted.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
# REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
# AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
# INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
# LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
# OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
# PERFORMANCE OF THIS SOFTWARE.
#
set -e
script="$0"
testdir=$(dirname "${script}")
scriptdir="$testdir/scripts"
if [ "$#" -gt 0 ]; then
bc="$1"
shift
else
bc="$testdir/../bc"
fi
out1="$testdir/../.log_bc.txt"
out2="$testdir/../.log_test.txt"
for s in $scriptdir/*.bc; do
f=$(basename -- "$s")
name="${f%.*}"
if [ "$f" = "timeconst.bc" ]; then
continue
fi
echo "Running script: $f"
orig="$testdir/$name.txt"
results="$scriptdir/$name.txt"
if [ -f "$orig" ]; then
res="$orig"
elif [ -f "$results" ]; then
res="$results"
else
echo "halt" | bc -lq "$s" > "$out1"
res="$out1"
fi
echo "halt" | "$bc" "$@" -lq "$s" > "$out2"
diff "$res" "$out2"
done
rm -rf "$out1" "$out2"