Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/test.sh

    r19 r30  
    11#! /bin/sh
     2
     3#
     4# Copyright Rainer Wichmann (2006)
     5#
     6# License Information:
     7# This program is free software; you can redistribute it and/or modify
     8# it under the terms of the GNU General Public License as published by
     9# the Free Software Foundation; either version 2 of the License, or
     10# (at your option) any later version.
     11#
     12# This program is distributed in the hope that it will be useful,
     13# but WITHOUT ANY WARRANTY; without even the implied warranty of
     14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     15# GNU General Public License for more details.
     16#
     17# You should have received a copy of the GNU General Public License
     18# along with this program; if not, write to the Free Software
     19# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
     20#
     21
     22# -----------------------------------------------------------------------
     23# Be Bourne compatible
     24# -----------------------------------------------------------------------
     25
     26if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
     27  emulate sh
     28  NULLCMD=:
     29elif test -n "${BASH_VERSION+set}" && (set -o posix) >/dev/null 2>&1; then
     30  set -o posix
     31fi
     32
     33# -----------------------------------------------------------------------
     34# Make sure we support functions (from the autoconf manual)
     35# -----------------------------------------------------------------------
     36
     37TSHELL="${TSHELL-/bin/sh}"
     38if test x"$1" = "x--re-executed"
     39then
     40    shift
     41elif "$TSHELL" -c 'foo () { (exit 0); exit 0; }; foo' >/dev/null 2>&1
     42then
     43    :
     44else
     45    for cmd in sh bash ash bsh ksh zsh sh5; do
     46        X="$PATH:/bin:/usr/bin:/usr/afsws/bin:/usr/ucb:/usr/xpg4/bin";
     47        OLD_IFS=${IFS}
     48        IFS=':'; export IFS
     49        for dir in $X; do
     50            shell="$dir/$cmd"
     51            if (test -f "$shell" || test -f "$shell.exe")
     52            then
     53                if "$shell" -c  'foo () { (exit 0); exit 0; }; foo' >/dev/null 2>&1
     54                then
     55                    TSHELL="$shell"; export TSHELL
     56                    IFS=${OLD_IFS}; export IFS
     57                    exec "$shell" "$0" --re-executed ${1+"$@"}
     58                fi
     59            fi
     60        done
     61        IFS=${OLD_IFS}; export IFS
     62    done
     63    echo "-----------------------------------------------------------------"
     64    echo "ERROR: Unable to locate a shell interpreter with function support" >&2
     65    echo "-----------------------------------------------------------------"
     66    { (exit 1); exit 1; }
     67fi
     68
     69# -----------------------------------------------------------------------
     70# Make sure we support 'let' (from the autoconf manual)
     71# -----------------------------------------------------------------------
     72
     73TSHELL="${TSHELL-/bin/sh}"
     74if test x"$1" = "x--re-run"
     75then
     76    shift
     77elif "$TSHELL" -c 'a=5; let "a = a + 5"' >/dev/null 2>&1
     78then
     79    :
     80else
     81    for cmd in sh bash ash bsh ksh zsh sh5; do
     82        X="$PATH:/bin:/usr/bin:/usr/afsws/bin:/usr/ucb:/usr/xpg4/bin";
     83        OLD_IFS=${IFS}
     84        IFS=':'; export IFS
     85        for dir in $X; do
     86            shell="$dir/$cmd"
     87            if (test -f "$shell" || test -f "$shell.exe")
     88            then
     89                if "$shell" -c  'foo () { (exit 0); exit 0; }; foo' >/dev/null 2>&1
     90                then
     91                    if "$shell" -c  'a=5; let "a = a + 5"' >/dev/null 2>&1
     92                    then
     93                        TSHELL="$shell"; export TSHELL
     94                        IFS=${OLD_IFS}; export IFS
     95                        exec "$shell" "$0" --re-run ${1+"$@"}
     96                    fi
     97                fi
     98            fi
     99        done
     100        IFS=${OLD_IFS}; export IFS
     101    done
     102    echo "-----------------------------------------------------------------"
     103    echo "ERROR: Unable to locate a shell interpreter with support for 'let'" >&2
     104    echo "-----------------------------------------------------------------"
     105    { (exit 1); exit 1; }
     106fi
     107
     108
     109umask 0022
    2110
    3111isok=`test -t 1 2>&1 | wc -c`
     
    40148    echo "  ${S}test.sh  6${E}  -- Controlling the daemon"
    41149    echo "  ${S}test.sh  7${E}  -- GnuPG signed files / prelude log"
     150    echo "  ${S}test.sh  8${E}  -- Suidcheck"
    42151
    43152    echo "  ${S}test.sh 10${E}  -- Test c/s init/check      (testrc_2.in)"
     
    46155    echo "  ${S}test.sh 13${E}  -- Test full c/s w/mysql    (testrc_2.in)"
    47156    echo "  ${S}test.sh 14${E}  -- Test full c/s w/postgres (testrc_2.in)"
    48     echo "  ${S}test.sh all${E} -- All except 12+"
    49    
     157    echo "  ${S}test.sh all${E} -- All tests"
     158}
     159scripts () {
    50160    echo
    51     echo "Scripts used by tests (located in ${SCRIPTDIR}):"
     161    echo "Scripts used by tests:"
    52162    echo "  (1) testcompile.sh (2) testhash.sh     (3) testrun_1.sh   (4) testrun_1a.sh"
    53     echo "  (5) testext.sh     (6) testtimesrv.sh  (7) testrun_1b.sh (10) testrun_2.sh"
    54     echo " (11) testrun_2a.sh (12) testrun_2b.sh  (13) testrun_2c.sh (14) testrun_2d.sh"
     163    echo "  (5) testext.sh     (6) testtimesrv.sh  (7) testrun_1b.sh  (8) testrun_1c.sh"
     164    echo " (10) testrun_2.sh  (11) testrun_2a.sh  (12) testrun_2b.sh (13) testrun_2c.sh"
     165    echo " (14) testrun_2d.sh"
    55166}
    56167
     
    64175cleanup=on
    65176doall=
     177usevalgrind=
    66178
    67179while [ $# -gt 0 ]
     
    69181    case "$1" in
    70182        -h|--help)     usage; exit 0;;
     183        --scripts)     usage; scripts; exit 0;;
    71184        -v|--verbose)  verbose=on; quiet= ;;
    72185        -q|--quiet)    quiet=on; verbose= ;;
     
    74187        --no-cleanup) cleanup= ;;
    75188        --really-all) doall=on;;
     189        --valgrind) usevalgrind=on;;
    76190        --srcdir=*)    TOP_SRCDIR=`echo $1 | sed s,--srcdir=,,`; export TOP_SRCDIR;;
    77191        --color=*)     
     
    160274
    161275PW_DIR=`pwd`; export PW_DIR
     276
     277#
     278# group/world writeable will cause problems
     279#
     280chmod go-w .
    162281#
    163282#
     
    282401    rm -f testrc_1.dyn
    283402    rm -f testrc_2
     403    rm -f testrc_22
    284404    rm -f ./.samhain_file
    285405    rm -f ./.samhain_log*
    286     rm -f ./.samhain_lock
    287     test -d testrun_data && chmod -R 0700 testrun_data
    288     rm -rf testrun_data
     406    rm -f ./.samhain_lock*
     407    test -d testrun_testdata && chmod -R 0700 testrun_testdata
     408    test -d .quarantine && rm -rf .quarantine
     409    rm -rf testrun_testdata
    289410    rm -f test_log_db
    290411    rm -f test_log_prelude
     412    rm -f test_log_valgrind*
     413    rm -f test_log_yulectl
     414    rm -f yule.html
     415    rm -f yule.html2
    291416}
    292417
     
    330455        tmp="localhost"
    331456    fi
    332     echo "$tmp"
     457    #
     458    # first one is hostname, others are aliases
     459    #
     460    tmp2=`cat /etc/hosts | egrep "^ *[0123456789].* $tmp" | awk '{ print $2 }'`
     461    if [ -z "$tmp2" ]; then
     462        echo "$tmp"
     463    else
     464        echo "$tmp2"
     465    fi
    333466}
    334467
     
    341474    hostname="127.0.0.1"
    342475fi
     476
     477# Seems that 'valgrind' causes random hangs :-(
     478#
     479if [ -z "$usevalgrind" ]; then
     480    VALGRIND=
     481else
     482    VALGRIND=`find_path valgrind`;
     483fi
     484[ -z "$VALGRIND" ] || {
     485    VALGRIND="$VALGRIND --quiet --tool=memcheck --suppressions=.test.supp";
     486    export VALGRIND;
     487    [ -z "$verbose" ] || log_msg_ok "using valgrind"
     488cat > ".test.supp" <<End-of-data
     489#
     490# there are unitialized bytes in the struct...
     491#
     492{
     493   pushdata_01
     494   Memcheck:Param
     495   write(buf)
     496   obj:/lib/ld-*.so
     497   fun:sh_hash_pushdata
     498   fun:sh_files_filecheck
     499   fun:sh_dirs_chk
     500}
     501{
     502   pushdata_02
     503   Memcheck:Param
     504   write(buf)
     505   obj:/lib/ld-*.so
     506   fun:sh_hash_pushdata
     507   fun:sh_files_filecheck
     508   fun:sh_files_checkdir
     509}
     510{
     511   pushdata_03
     512   Memcheck:Param
     513   write(buf)
     514   obj:/lib/ld-*.so
     515   fun:sh_hash_pushdata
     516   fun:sh_hash_writeout
     517   fun:main
     518}
     519
     520End-of-data
     521}
    343522
    344523if test x$1 = x1; then
     
    385564    exit $?
    386565fi
     566if test x$1 = x8; then
     567    . ${SCRIPTDIR}/testrun_1.sh
     568    . ${SCRIPTDIR}/testrun_1c.sh
     569    testrun1c
     570    print_summary
     571    exit $?
     572fi
    387573if test x$1 = x10; then
    388574    . ${SCRIPTDIR}/testrun_2.sh
     
    434620    . ${SCRIPTDIR}/testrun_1b.sh
    435621    let "TEST_MAX = TEST_MAX + MAXTEST" >/dev/null
     622    . ${SCRIPTDIR}/testrun_1c.sh
     623    let "TEST_MAX = TEST_MAX + MAXTEST" >/dev/null
    436624    . ${SCRIPTDIR}/testrun_2.sh
    437625    let "TEST_MAX = TEST_MAX + MAXTEST" >/dev/null
     
    471659    MAXTEST=${TEST_MAX}; export MAXTEST
    472660    testrun1b
     661    #
     662    . ${SCRIPTDIR}/testrun_1.sh
     663    . ${SCRIPTDIR}/testrun_1c.sh
     664    MAXTEST=${TEST_MAX}; export MAXTEST
     665    testrun1c
    473666    #
    474667    . ${SCRIPTDIR}/testrun_2.sh
Note: See TracChangeset for help on using the changeset viewer.