Revision: 77206
          http://sourceforge.net/p/brlcad/code/77206
Author:   brlcad
Date:     2020-09-24 06:43:37 +0000 (Thu, 24 Sep 2020)
Log Message:
-----------
eliminate usage of /dev/null throughout the benchmark as it's not necessary if 
we restructure things a bit.  output is simply caputured and ignored/logged as 
desired.  also do a little better reporting on the logfile.

Modified Paths:
--------------
    brlcad/trunk/bench/run.sh

Modified: brlcad/trunk/bench/run.sh
===================================================================
--- brlcad/trunk/bench/run.sh   2020-09-23 22:31:52 UTC (rev 77205)
+++ brlcad/trunk/bench/run.sh   2020-09-24 06:43:37 UTC (rev 77206)
@@ -68,46 +68,31 @@
 # force locale setting to C so things like date output as expected
 LC_ALL=C
 
-# stop git shell & msys2 arg manipulation (/dev/null, -F/dev/debug)
-export MSYS_NO_PATHCONV=1 MSYS2_ARG_CONV_EXCL="\*"
-
-# Windows has a special NUL device instead of /dev/null
-if test -f NUL ; then
-    echo "INTERNAL ERROR: NUL file is in the way (delete it)"
-    exit 1
-fi
-out=`cat NUL 2>&1`
-ret=$?
-if test "x$ret" = "x0" ; then
-    export NUL=NUL
-elif test -e /dev/null ; then
-    export NUL=/dev/null
-else
-    echo "INTERNAL ERROR: cannot determine a suitable null device"
-    exit 1
-fi
-
 # commands that this script expects
 for __cmd in echo pwd ; do
-    echo "test" | $__cmd > $NUL 2>&1
+    out=`echo "test" | $__cmd 2>&1`
     if test ! x$? = x0 ; then
        echo "INTERNAL ERROR: $__cmd command is required"
+       echo "                (output was [$out])"
        exit 1
     fi
 done
-echo "test" | grep "test" > $NUL 2>&1
+out=`echo "test" | grep "test" 2>&1`
 if test ! x$? = x0 ; then
     echo "INTERNAL ERROR: grep command is required"
+    echo "                (output was [$out])"
     exit 1
 fi
-echo "test" | tr "test" "test" > $NUL 2>&1
+out=`echo "test" | tr "test" "test" 2>&1`
 if test ! x$? = x0 ; then
     echo "INTERNAL ERROR: tr command is required"
+    echo "                (output was [$out])"
     exit 1
 fi
-echo "test" | sed "s/test/test/" > $NUL 2>&1
+out=`echo "test" | sed "s/test/test/" 2>&1`
 if test ! x$? = x0 ; then
     echo "INTERNAL ERROR: sed command is required"
+    echo "                (output was [$out])"
     exit 1
 fi
 
@@ -410,12 +395,14 @@
 
 # where to write results
 LOGFILE=run-$$-benchmark.log
-touch "$LOGFILE"
+if test -e $LOGFILE ; then
+    echo "WARNING: $LOGFILE already exists.  Appending."
+else
+    touch "$LOGFILE"
+fi
 if test ! -w "$LOGFILE" ; then
-    if test "x$LOGFILE" != "x/dev/null" -a "x$LOGFILE" != "xNUL" ; then
-       echo "ERROR: Unable to log to $LOGFILE"
-    fi
-    LOGFILE=$NUL
+    echo "WARNING: Unable to log to $LOGFILE"
+    LOGFILE=
 fi
 
 VERBOSE_ECHO=:
@@ -434,7 +421,13 @@
 $ECHO "B R L - C A D   B E N C H M A R K"
 $ECHO "================================="
 $ECHO "Running $THIS on `date`"
-$ECHO "Logging output to $LOGFILE"
+if test "x$LOGFILE" != "x" ; then
+    $ECHO "Logging output to $LOGFILE"
+elif test "x$QUIET" != "x" ; then
+    $ECHO "Logging output to STDOUT"
+else
+    $ECHO "Logging output is OFF"
+fi
 $ECHO "`uname -a 2>&1`"
 $ECHO
 
@@ -603,8 +596,11 @@
     $ECHO "Using [$ELP] for ELP"
 fi
 
+# stop git shell & msys2 arg manipulation
+export MSYS_NO_PATHCONV=1 MSYS2_ARG_CONV_EXCL="-F/dev/debug"
+
 # sanity check: make sure $RT runs
-eval \"$RT\" -s1 -F/dev/debug \"${DB}/moss.g\" LIGHT > $NUL 2>&1
+out=`eval \"$RT\" -s1 -F/dev/debug \"${DB}/moss.g\" LIGHT 2>&1`
 ret=$?
 if test ! "x${ret}" = "x0" ; then
     $ECHO
@@ -612,23 +608,26 @@
     "$RT"
     $ECHO
     $ECHO "ERROR:  RT does not seem to work as expected"
+    $ECHO "        (output was [$out])"
     exit 2
 fi
 
 # sanity check: make sure $CMP runs
-eval \"$CMP\" $NUL $NUL > $NUL 2>&1
+out=`echo "" | eval \"$CMP\" - - 2>&1`
 ret=$?
 if test ! "x${ret}" = "x0" ; then
     $ECHO
     $ECHO "ERROR:  CMP does not seem to work as expected"
+    $ECHO "        (output was [$out])"
     exit 2
 fi
 
 # sanity check: make sure $ELP runs
-eval \"$ELP\" 0 > $NUL 2>&1
+out=`eval \"$ELP\" 0 2>&1`
 if test ! "x${ret}" = "x0" ; then
     $ECHO
     $ECHO "ERROR:  ELP does not seem to work as expected"
+    $ECHO "        (output was [$out])"
     exit 2
 fi
 
@@ -688,7 +687,8 @@
 
 
 # if expr works, let the user know about how long this might take
-if test "x`expr 1 - 1 2>$NUL`" = "x0" ; then
+zero=`expr 1 - 1 2>&1`
+if test "x$zero" = "x0" ; then
     mintime="`expr 6 \* $TIMEFRAME`"
     if test $mintime -lt 1 ; then
        mintime=0 # zero is okay
@@ -710,6 +710,7 @@
     $ECHO
 else
     $ECHO "WARNING: expr is unavailable, unable to compute statistics"
+    $ECHO "         (output of 1 - 1 was [$zero])"
     $ECHO
 fi
 
@@ -876,13 +877,13 @@
     if test "x$sqrt_number" = "x" ; then
        $ECHO "ERROR: cannot compute the square root of nothing" 1>&2
        exit 1
-    elif test $sqrt_number -lt 0 > $NUL 2>&1 ; then
+    elif test $sqrt_number -lt 0 ; then
        $ECHO "ERROR: square root of negative numbers is only in your 
imagination" 1>&2
        exit 1
     fi
 
     sqrt_have_dc=yes
-    echo "1 1 + p" | dc >$NUL 2>&1
+    out=`echo "1 1 + p" | dc 2>&1`
     if test ! x$? = x0 ; then
        sqrt_have_dc=no
     fi
@@ -892,7 +893,7 @@
        sqrt_root=`echo "$sqrt_number v p" | dc`
     else
        sqrt_have_bc=yes
-       echo "1 + 1" | bc >$NUL 2>&1
+       out=`echo "1 + 1" | bc 2>&1`
        if test ! "x$?" = "x0" ; then
            sqrt_have_bc=no
        fi
@@ -1242,13 +1243,13 @@
 
     # see if we have a calculator
     perf_have_dc=yes
-    echo "1 1 + p" | dc >$NUL 2>&1
+    out=`echo "1 1 + p" | dc 2>&1`
     if test ! x$? = x0 ; then
        perf_have_dc=no
     fi
 
     perf_have_bc=yes
-    echo "1 + 1" | bc >$NUL 2>&1
+    out=`echo "1 + 1" | bc 2>&1`
     if test ! x$? = x0 ; then
        perf_have_bc=no
     fi

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.



_______________________________________________
BRL-CAD Source Commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/brlcad-commits

Reply via email to