"Fossies" - the Fresh Open Source Software Archive

Member "shtool-2.0.8/test.sh" (2 Apr 2008, 2327 Bytes) of package /linux/misc/old/shtool-2.0.8.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Bash source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file.

    1 #!/bin/sh
    2 ##
    3 ##  test.sh -- GNU shtool test suite driver
    4 ##  Copyright (c) 1999-2008 Ralf S. Engelschall <rse@engelschall.com>
    5 ##
    6 ##  This file is part of shtool and free software; you can redistribute
    7 ##  it and/or modify it under the terms of the GNU General Public
    8 ##  License as published by the Free Software Foundation; either version
    9 ##  2 of the License, or (at your option) any later version.
   10 ##
   11 ##  This file is distributed in the hope that it will be useful,
   12 ##  but WITHOUT ANY WARRANTY; without even the implied warranty of
   13 ##  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
   14 ##  General Public License for more details.
   15 ##
   16 ##  You should have received a copy of the GNU General Public License
   17 ##  along with this program; if not, write to the Free Software
   18 ##  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
   19 ##  USA, or contact Ralf S. Engelschall <rse@engelschall.com>.
   20 ##
   21 
   22 shtool=../shtool
   23 testdb=../test.db
   24 
   25 #   move to a subdirectory
   26 rm -rf test.sd >/dev/null 2>&1
   27 mkdir test.sd || exit 1
   28 cd test.sd || exit 1
   29 
   30 #   make sure the tool and database exists
   31 test -f $shtool || exit 1
   32 test -f $testdb || exit 1
   33 
   34 #   iterate over all tool tests
   35 TOOLS=`grep '^@begin' $testdb | sed -e 's/^@begin{//' -e 's/}.*$//'`
   36 failed=0
   37 passed=0
   38 ran=0
   39 for tool in $TOOLS; do
   40     rm -rf ./* >/dev/null 2>&1
   41     echo "${tool}..............." | awk '{ printf("%s", substr($0, 0, 15)); }'
   42     sed -e "/^@begin{$tool}/,/^@end{$tool}/p" -e '1,$d' $testdb |\
   43     sed -e '/^@begin/d' -e '/^@end/d' \
   44         -e 's/\([^\\]\)[    ]*$/\1 || exit 1/g' \
   45         -e "s;shtool;$shtool;g" >run.sh
   46     echo "exit 0" >>run.sh
   47     sh -x run.sh >run.log 2>&1
   48     if [ $? -ne 0 ]; then
   49         #   generate report
   50         echo "FAILED"
   51         echo "+---Test------------------------------"
   52         cat run.sh | sed -e 's/^/| /g'
   53         echo "+---Trace-----------------------------"
   54         cat run.log | sed -e 's/^/| /g'
   55         failed=`expr $failed + 1`
   56         echo "+-------------------------------------"
   57     else
   58         passed=`expr $passed + 1`
   59         echo "ok"
   60     fi
   61     ran=`expr $ran + 1`
   62 done
   63 
   64 #   cleanup
   65 cd ..
   66 rm -rf test.sd >/dev/null 2>&1
   67 
   68 #   result
   69 if [ $failed -gt 0 ]; then
   70     echo "FAILED: passed: $passed/$ran, failed: $failed/$ran"
   71 else
   72     echo "OK: passed: $passed/$ran"
   73 fi
   74 exit 0
   75