From 7a76e9d632756a4d3f044d6742a5defb83ce6ae7 Mon Sep 17 00:00:00 2001 From: Yann Herklotz Date: Thu, 2 Apr 2020 14:53:39 +0100 Subject: Add tests --- test/test_all.sh | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100755 test/test_all.sh (limited to 'test/test_all.sh') diff --git a/test/test_all.sh b/test/test_all.sh new file mode 100755 index 0000000..67b5c8f --- /dev/null +++ b/test/test_all.sh @@ -0,0 +1,45 @@ +mytmpdir=$(mktemp -d 2>/dev/null || mktemp -d -t 'mytmpdir') +echo "--------------------------------------------------" +echo "Created working directory: $mytmpdir" +echo "--------------------------------------------------" + +if [[ -z $1 ]]; then + test_dir=. +else + test_dir=$1 +fi + +test_command() { + local loc=$(command -v $1) + if [[ $? -eq 0 ]]; then + echo "Found $1: $loc" + else + echo "Could not find $1" + exit 1 + fi +} + +test_command iverilog +test_command gcc + +echo "--------------------------------------------------" + +for cfile in $test_dir/*.c; do + echo "Testing $cfile" + outbase=$mytmpdir/$(basename $cfile) + gcc -o $outbase.gcc $cfile + $outbase.gcc + expected=$? + ./bin/coqup --hls -drtl -o $outbase.v $cfile + iverilog -o $outbase.iverilog $outbase.v + actual=$($outbase.iverilog | sed -E -e 's/[^0-9]+([0-9]+)/\1/') + if [[ $expected = $actual ]]; then + echo "OK" + else + echo "FAILED: $expected != $actual" + fi +done + +echo "--------------------------------------------------" + +rm -rf $mytmpdir -- cgit