standalone: Add 32-bit execution tests to check_demo.sh

This commit is contained in:
David Mak 2024-07-26 10:42:40 +08:00
parent 05a8948ff2
commit 8c5ba37d09
2 changed files with 33 additions and 12 deletions

View File

@ -14,12 +14,21 @@ while [ $# -gt 1 ]; do
done
demo="$1"
echo -n "Checking $demo... "
./interpret_demo.py "$demo" > interpreted.log
./run_demo.sh --out run.log "${nac3args[@]}" "$demo"
./run_demo.sh --lli --out run_lli.log "${nac3args[@]}" "$demo"
diff -Nau interpreted.log run.log
diff -Nau interpreted.log run_lli.log
echo "ok"
echo "### Checking $demo..."
rm -f interpreted.log run.log run_lli.log
# Get reference output
echo ">>>>>> Running $demo with the Python interpreter"
./interpret_demo.py "$demo" > interpreted.log
echo "...... Trying NAC3's 32-bit code generator output"
./run_demo.sh -m32 --out run_32.log "${nac3args[@]}" "$demo"
diff -Nau interpreted.log run_32.log
echo "...... Trying NAC3's 64-bit code generator output"
./run_demo.sh --out run_64.log "${nac3args[@]}" "$demo"
diff -Nau interpreted.log run_64.log
echo "...... OK"
rm -f interpreted.log \
run_32.log run_64.log

View File

@ -11,7 +11,7 @@ declare -a nac3args
while [ $# -ge 1 ]; do
case "$1" in
--help)
echo "Usage: run_demo.sh [--help] [--out OUTFILE] [--debug] -- [NAC3ARGS...]"
echo "Usage: run_demo.sh [--help] [--out OUTFILE] [--debug] [-m32] -- [NAC3ARGS...]"
exit
;;
--out)
@ -21,6 +21,9 @@ while [ $# -ge 1 ]; do
--debug)
debug=1
;;
-m32)
m32=1
;;
--)
shift
break
@ -48,10 +51,19 @@ fi
rm -f ./*.o ./*.bc demo
$nac3standalone "${nac3args[@]}"
if [ -z "$m32" ]; then
$nac3standalone "${nac3args[@]}"
clang -c -std=gnu11 -Wall -Wextra -O3 -o demo.o demo.c
clang -lm -o demo module.o demo.o
clang -c -std=gnu11 -Wall -Wextra -O3 -o demo.o demo.c
clang -lm -Wl,--no-warn-search-mismatch -o demo module.o demo.o
else
# Enable SSE2 to avoid rounding errors with X87's 80-bit fp precision computations
$nac3standalone --triple i386-pc-linux-gnu --target-features +sse2 "${nac3args[@]}"
clang -m32 -c -std=gnu11 -Wall -Wextra -O3 -msse2 -o demo.o demo.c
clang -m32 -lm -Wl,--no-warn-search-mismatch -o demo module.o demo.o
fi
if [ -z "$outfile" ]; then
./demo