diff --git a/tools/runtest b/tools/runtest index a3c9331..9368ce9 100755 --- a/tools/runtest +++ b/tools/runtest @@ -89,9 +89,17 @@ done # we must have found an input file if [ ! -f "$infile" ]; then usage; fi -# set program to the .c file base name if not specified otherwise if [ -z "$program" ]; then - program=`basename "$infile" .c` + # try to autodetect the test program name based on the working directory + if [ "$(basename $PWD)" = "tests" ]; then + program="$(basename $(dirname $PWD))_test.exe.so" + elif [ -d "tests" ]; then + program="tests/$(basename $PWD)_test.exe.so" + fi + if [ ! -f "$program" ]; then + echo "Can't find the test program, use the -p argument to specify one" 2>&1 + usage + fi fi # check/detect topobjdir