diff --git a/tools/runtest b/tools/runtest index a3c9331..b21aa96 100755 --- a/tools/runtest +++ b/tools/runtest @@ -89,9 +89,22 @@ 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` + workingpath=`pwd` + workingbasename=`basename "$workingpath"` + parentpath=`dirname "$workingpath"` + parentbasename=`basename "$parentpath"` + + # try to autodetect the test program name based on the working directory + if [ "$workingbasename" = "tests" ]; then + program="${parentbasename}_test.exe.so" + elif [ -d "tests" ]; then + program="tests/${workingbasename}_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