Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/testrun_1.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#
    221
    322RCFILE="$PW_DIR/testrc_1.dyn";  export RCFILE
     
    2241testrun1_setup=0
    2342
    24 MAXTEST=10; export MAXTEST
     43MAXTEST=11; export MAXTEST
    2544
    2645test_dirs () {
     
    4665        fi
    4766    done
     67}
     68
     69#
     70# combine file check schedule with one-shot mode
     71#
     72TESTPOLICY_11="
     73[ReadOnly]
     74dir=99${BASE}
     75"
     76
     77mod_testdata_11 () {
     78    sleep 1
     79    echo "foobar" >"${BASE}/c/x"; # bad
     80    chmod 0555  "${BASE}/a/y";    # bad
     81    ORIGINAL='SetFilecheckTime=60'
     82    REPLACEMENT='FileCheckScheduleOne = 6 12 * * *'
     83    ex $RCFILE <<EOF
     84%s/${ORIGINAL}/${REPLACEMENT}/g
     85wq
     86EOF
     87}
     88
     89chk_testdata_11 () {
     90    # CDIRS="a b c a/a a/b a/c a/a/a a/a/b a/a/c a/a/a/a a/a/a/b a/a/a/c";
     91    tmp=`grep CRIT $LOGFILE | wc -l`
     92    if [ $tmp -ne 2 ]; then
     93        [ -z "$verbose" ] || log_msg_fail "policy count";
     94        return 1
     95    fi
     96    egrep "CRIT.*POLICY \[ReadOnly\] C-------TS.*${BASE}/c/x" $LOGFILE >/dev/null 2>&1
     97    if [ $? -ne 0 ]; then
     98        [ -z "$verbose" ] || log_msg_fail "${BASE}/c/x";
     99        return 1
     100    fi
     101    egrep "CRIT.*POLICY \[ReadOnly\] -----M--T-.*${BASE}/a/y" $LOGFILE >/dev/null 2>&1
     102    if [ $? -ne 0 ]; then
     103        [ -z "$verbose" ] || log_msg_fail "${BASE}/a/y";
     104        return 1
     105    fi
     106    CDIRS="a a/a a/b a/c c b a/a/a a/a/b a/a/c a/a/a/a a/a/a/b a/a/a/c";
     107    NDIRS="";
     108    test_dirs;
     109    return $?
    48110}
    49111
     
    749811run_init ()
    750812{
    751     ./samhain -t init -p none
     813    rm -f test_log_valgrind
     814
     815    ${VALGRIND} ./samhain -t init -p none 2>>test_log_valgrind
    752816
    753817    if test x$? = x0; then
     
    761825run_check ()
    762826{
    763     ./samhain -t check -p none -l debug
     827    ${VALGRIND} ./samhain -t check -p none -l debug 2>>test_log_valgrind
    764828
    765829    if test x$? = x0; then
     
    778842run_update ()
    779843{
    780     ./samhain -t update -p none -l debug
     844    ${VALGRIND} ./samhain -t update -p none -l debug 2>>test_log_valgrind
    781845
    782846    if test x$? = x0; then
     
    792856    rm -rf $LOGFILE
    793857
    794     ./samhain -t check -p none -l debug
     858    ${VALGRIND} ./samhain -t check -p none -l debug 2>>test_log_valgrind
    795859
    796860    if test x$? = x0; then
     
    801865            return 1
    802866        fi
    803         tmp=`./samhain -j -L $LOGFILE | grep ERR | wc -l`
     867        #
     868        # wtmp may not be readable
     869        #
     870        tmp=`./samhain -j -L $LOGFILE | grep ERR | grep -v wtmp | wc -l`
    804871        if [ $tmp -ne 0 ]; then
    805             [ -z "$verbose" ] || log_msg_fail "update not successful(?)";
    806             return 1
    807         fi
     872            [ -z "$verbose" ] || log_msg_fail "errors during check";
     873            return 1
     874        fi
     875        #
     876        [ -z "$VALGRIND" ] || {
     877            tmp=`cat test_log_valgrind 2>/dev/null | wc -l`;
     878            if [ $tmp -ne 0 ]; then
     879                [ -z "$verbose" ] || log_msg_fail "valgrind reports errors";
     880                cat test_log_valgrind
     881                return 1;
     882            fi;
     883        }
    808884        #
    809885        [ -z "$verbose" ] || log_msg_ok    "check(2)...";
     
    816892prep_testdata ()
    817893{
    818     chmod -R 0700 "${BASE}" || {
    819         [ -z "$quiet" ] &&   log_msg_fail "chmod -R 0700 ${BASE}";
    820         return 1;
    821     }
     894    if test -d "$BASE"; then
     895        if [ -d "${BASE}" ]; then
     896            chmod -R 0700 "${BASE}" || {
     897                [ -z "$quiet" ] &&   log_msg_fail "chmod -R 0700 ${BASE}";
     898                return 1;
     899            }
     900        fi
     901    fi
    822902
    823903    rm -rf "${BASE}" || {
     
    872952        if test x$? = x0; then
    873953                [ -z "$verbose" ] ||     log_msg_ok "configure...";
    874                 $MAKE  > /dev/null
     954                $MAKE  >/dev/null 2>>test_log
    875955                if test x$? = x0; then
    876956                    [ -z "$verbose" ] || log_msg_ok "make...";
Note: See TracChangeset for help on using the changeset viewer.