From b3891b9a0d86f2e4f7366f3d6937ccaa47f5df3e Mon Sep 17 00:00:00 2001 From: David Mak Date: Fri, 9 Aug 2024 12:26:59 +0800 Subject: [PATCH] standalone: Fix several issues post script refactoring - Add helptext for check_demos.sh - Add back support for using debug NAC3 for running tests - Output error message when argument is not recognized - Fixed last non-demo script argument being ignored - Add back SSE2 requirement to NAC3 (required for mandelbrot) --- nac3standalone/demo/check_demo.sh | 25 ++++++++++++++++++------- nac3standalone/demo/check_demos.sh | 5 +++++ nac3standalone/demo/run_demo.sh | 7 ++++--- 3 files changed, 27 insertions(+), 10 deletions(-) diff --git a/nac3standalone/demo/check_demo.sh b/nac3standalone/demo/check_demo.sh index d31ebe21..477fe120 100755 --- a/nac3standalone/demo/check_demo.sh +++ b/nac3standalone/demo/check_demo.sh @@ -8,12 +8,15 @@ if [ -z "$1" ]; then fi declare -a nac3args -while [ $# -ge 2 ]; do +while [ $# -gt 1 ]; do case "$1" in --help) - echo "Usage: check_demo.sh [-i686] -- demo [NAC3ARGS...]" + echo "Usage: check_demo.sh [--debug] [-i686] -- [NAC3ARGS...] demo" exit ;; + --debug) + debug=1 + ;; -i686) i686=1 ;; @@ -22,18 +25,18 @@ while [ $# -ge 2 ]; do break ;; *) - break + echo "Unrecognized argument \"$1\"" + exit 1 ;; esac shift done -demo="$1" -shift while [ $# -gt 1 ]; do nac3args+=("$1") shift done +demo="$1" echo "### Checking $demo..." @@ -43,12 +46,20 @@ echo ">>>>>> Running $demo with the Python interpreter" if [ -n "$i686" ]; then echo "...... Trying NAC3's 32-bit code generator output" - ./run_demo.sh -i686 --out run_32.log "${nac3args[@]}" "$demo" + if [ -n "$debug" ]; then + ./run_demo.sh --debug -i686 --out run_32.log -- "${nac3args[@]}" "$demo" + else + ./run_demo.sh -i686 --out run_32.log -- "${nac3args[@]}" "$demo" + fi diff -Nau interpreted.log run_32.log fi echo "...... Trying NAC3's 64-bit code generator output" -./run_demo.sh --out run_64.log "${nac3args[@]}" "$demo" +if [ -n "$debug" ]; then + ./run_demo.sh --debug --out run_64.log -- "${nac3args[@]}" "$demo" +else + ./run_demo.sh --out run_64.log -- "${nac3args[@]}" "$demo" +fi diff -Nau interpreted.log run_64.log echo "...... OK" diff --git a/nac3standalone/demo/check_demos.sh b/nac3standalone/demo/check_demos.sh index ae21142b..2fa52923 100755 --- a/nac3standalone/demo/check_demos.sh +++ b/nac3standalone/demo/check_demos.sh @@ -2,6 +2,11 @@ set -e +if [ "$1" == "--help" ]; then + echo "Usage: check_demos.sh [CHECKARGS...] [--] [NAC3ARGS...]" + exit +fi + count=0 for demo in src/*.py; do ./check_demo.sh "$@" "$demo" diff --git a/nac3standalone/demo/run_demo.sh b/nac3standalone/demo/run_demo.sh index 298024f5..bec2eb6e 100755 --- a/nac3standalone/demo/run_demo.sh +++ b/nac3standalone/demo/run_demo.sh @@ -14,7 +14,7 @@ declare -a nac3args while [ $# -ge 1 ]; do case "$1" in --help) - echo "Usage: run_demo.sh [--help] [--out OUTFILE] [--debug] [-i686] -- [NAC3ARGS...]" + echo "Usage: run_demo.sh [--help] [--out OUTFILE] [--debug] [-i686] -- [NAC3ARGS...] demo" exit ;; --out) @@ -32,7 +32,8 @@ while [ $# -ge 1 ]; do break ;; *) - break + echo "Unrecognized argument \"$1\"" + exit 1 ;; esac shift @@ -59,7 +60,7 @@ if [ -z "$i686" ]; then clang -c -std=gnu11 -Wall -Wextra -O3 -o demo.o demo.c clang -o demo module.o demo.o $DEMO_LINALG_STUB -lm -Wl,--no-warn-search-mismatch else - $nac3standalone --triple i686-unknown-linux-gnu "${nac3args[@]}" + $nac3standalone --triple i686-unknown-linux-gnu --target-features +sse2 "${nac3args[@]}" clang -m32 -c -std=gnu11 -Wall -Wextra -O3 -msse2 -o demo.o demo.c clang -m32 -o demo module.o demo.o $DEMO_LINALG_STUB32 -lm -Wl,--no-warn-search-mismatch fi