Changeset 19 for trunk/test/testhash.sh


Ignore:
Timestamp:
Feb 12, 2006, 10:49:56 PM (19 years ago)
Author:
rainer
Message:

Rewrite of test suite, checksum for growing logs, fix for minor bug with dead client detection.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/testhash.sh

    r1 r19  
    11#! /bin/sh
    22
     3RCFILE="$PW_DIR/testrc_1.dyn";  export RCFILE
     4LOGFILE="$PW_DIR/.samhain_log"; export LOGFILE
    35
    4 # The following two are the ANSI sequences for start and end embolden
    5 case $TERM in
    6 vt*|ansi*|con*|xterm*|linux*|screen*)
    7   S=[1m
    8   E=[m
    9   ;;
    10 *)
    11   S=
    12   E=
    13   ;;
    14 esac
    15 
    16 PW_DIR=`pwd`
    17 
    18 if test x$UID != x; then
    19   TRUST="--with-trusted=0,2,$UID"
    20 else
    21   TRUST="--with-trusted=0,2"
    22 fi
    23 
    24 #echo; echo "${S}__ STARTING TEST HASH FUNCTION __${E}"; echo;
    25 #echo Working directory: $PW_DIR
    26 
    27 MAKE=`which gmake`
    28 if test "x$?" = x1 ; then
    29     MAKE="make -s"
    30 else
    31     MAKE=`which gmake | sed -e "s%\([a-z:]\) .*%\1%g"`
    32     if test "x$MAKE" = x; then
    33         MAKE="make -s"
    34     elif test "x$MAKE" = xno; then
    35         MAKE="make -s"
    36     else
    37         if test "x$MAKE" = "xwhich:"; then
    38                 MAKE="make -s"
    39         else
    40                 MAKE="gmake -s"
    41                 gmake -v >/dev/null 2>&1 || MAKE="make -s"
    42         fi
    43     fi
    44 fi
    45 
    46 
     6MAXTEST=1; export MAXTEST
    477
    488testhash ()
    499{
     10        log_start "HASH FUNCTION"
    5011        #
    5112        # test standalone compilation
     
    5718        fi
    5819        #
    59         ${TOP_SRCDIR}/configure --quiet  --prefix=$PW_DIR --localstatedir=$PW_DIR --with-config-file=$PW_DIR/samhainrc.test  > /dev/null 2>> test_log 
     20        ${TOP_SRCDIR}/configure --quiet $TRUST --prefix=$PW_DIR --localstatedir=$PW_DIR --with-config-file=$RCFILE --with-log-file=$LOGFILE --with-pid-file=$PW_DIR/.samhain_lock --with-data-file=$PW_DIR/.samhain_file --enable-debug
     21        #
     22        fail=0
    6023        #
    6124        if test x$? = x0; then
    62                 echo "PASS: configure ${TEST}";
     25                [ -z "$verbose" ] || log_msg_ok  "configure...";
    6326                $MAKE  > /dev/null 2>> test_log
    6427                if test x$? = x0; then
    65                     echo "PASS: $MAKE  ${TEST}";
     28                    [ -z "$verbose" ] || log_msg_ok "make...";
    6629                else
    67                     echo "FAIL: $MAKE  ${TEST} (see ./test_log)";
     30                    [ -z "$quiet" ] &&   log_msg_fail "make...";
     31                    fail=1
    6832                fi
    6933        else
    70                 echo "FAIL: configure  ${TEST} (see ./test_log)";
     34                [ -z "$quiet" ] && log_msg_fail "configure...";
     35                fail=1
    7136        fi
    72 
     37        #
     38        if [ $fail -eq 1 ]; then
     39            [ -z "$quiet" ] && log_fail 1 ${MAXTEST};
     40            return 1
     41        fi
     42        #
    7343        echo "Test results of the TIGER hash algorithm" > testhash.tmp
    7444        echo >> testhash.tmp
     
    8454        ./samhain -H "Tiger - A Fast New Hash Function, by Ross Anderson and Eli Biham, proceedings of Fast Software Encryption 3, Cambridge, 1996." >> testhash.tmp
    8555        ./samhain -H "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-" >> testhash.tmp
    86 
    87         # echo
    88         # echo "${S}diff testhash.tmp testtiger.txt (empty == success):${E}"
    89         # echo
    90         RESU=`diff testhash.tmp ${SCRIPTDIR}/testtiger.txt`
     56        #
     57        RESU=`diff testhash.tmp ${SCRIPTDIR}/testtiger.txt 2>/dev/null`
    9158        if test "x${RESU}" = "x"; then
    92             echo "PASS: test_hash"
     59            [ -z "$quiet" ] && log_ok   1 ${MAXTEST};
    9360        else
    94             echo "FAIL: test_hash"
     61            [ -z "$quiet" ] && log_fail 1 ${MAXTEST};
     62            return 1
    9563        fi
     64        log_end "HASH FUNCTION"
     65        return 0
    9666}
    9767
    9868
    9969
    100         testhash
    101 
    102 
    103 #echo; echo "${S}__ END TEST HASH FUNCTION __${E}"; echo;
    104 
    105 exit
    106 
Note: See TracChangeset for help on using the changeset viewer.