summaryrefslogtreecommitdiffstats
path: root/test/testrun_1g.sh
blob: 1361c08215fab373904beb522972ba8fb572b9a2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
#! /bin/sh

#
# Copyright Rainer Wichmann (2006)
#
# License Information:
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#

BUILDOPTS="--quiet $TRUST --enable-debug --enable-xml-log --enable-login-watch --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"
export BUILDOPTS

MAXTEST=1; export MAXTEST

testrun_deltadb ()
{
    tcount=1

    if test -r "Makefile"; then
	$MAKE distclean >/dev/null 
    fi
    
    ${TOP_SRCDIR}/configure ${BUILDOPTS} 
    
    if test x$? = x0; then
	[ -z "$verbose" ] ||     log_msg_ok "configure..."; 
	$MAKE  >/dev/null 2>>test_log
	if test x$? = x0; then
	    [ -z "$verbose" ] || log_msg_ok "make..."; 
	else
	    [ -z "$quiet" ] &&   log_msg_fail "make..."; 
	    return 1
	fi
	
    else
	[ -z "$quiet" ] &&       log_msg_fail "configure...";
	return 1
    fi

    prep_init
    check_err $? ${tcount}; errval=$?

    if [ $errval -eq 0 ]; then
	prep_testdata
	check_err $? ${tcount}; errval=$?
    fi
    if [ $errval -eq 0 ]; then
	prep_testpolicy   1
	check_err $? ${tcount}; errval=$?
    fi

    rm "${BASE}/a/a/b/x"
    rm -f file.*.*-*-*-*-*

    ./samhain --create-database=./tmp_list_file

    check_err $? ${tcount}; errval=$?
    if [ $errval -eq 0 ]; then
	num=$( ./samhain -a -d file.*.*-*-*-*-* | grep "1970-01-01T00:00:00" >/dev/null | wc -l )
	if [ $num -ne 1 ]; then
	    [ -z "$verbose" ] || log_msg_ok "list...";
	else
	    [ -z "$quiet" ] &&       log_msg_fail "list...";
	    log_fail ${tcount} ${MAXTEST};
	fi
    else
	[ -z "$quiet" ] &&       log_msg_fail "create...";
	log_fail ${tcount} ${MAXTEST};
    fi

    if [ $errval -eq 0 ]; then
	./samhain --verify-database file.*.*-*-*-*-*
    fi

    check_err $? ${tcount}; errval=$?
    if [ $errval -eq 0 ]; then
	echo "o_O" > "${BASE}/a/a/b/y"
	./samhain --verify-database file.*.*-*-*-*-*
    fi
    if [ $? -eq 0 ]; then
	[ -z "$quiet" ] &&       log_msg_fail "detect modify...";
	check_err 1 ${tcount}; errval=1
    fi

    if [ $errval -eq 0 ]; then
	[ -z "$quiet" ] && log_ok ${tcount} ${MAXTEST};
    fi

    [ -z "$cleanup" ] || rm -f file.*.*-*-*-*-*
    return 0
}

testrun1g ()
{
    log_start "RUN CL Create DeltaDB"

    testrun_deltadb

    log_end "RUN CL Create DeltaDB"
    return 0
}