source: trunk/test/testhash.sh@ 290

Last change on this file since 290 was 257, checked in by katerina, 15 years ago

Fix for issues with debug code and testsuite (tickets #174, #175).

File size: 4.1 KB
RevLine 
[1]1#! /bin/sh
2
[27]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
[19]22RCFILE="$PW_DIR/testrc_1.dyn"; export RCFILE
23LOGFILE="$PW_DIR/.samhain_log"; export LOGFILE
[1]24
[159]25MAXTEST=2; export MAXTEST
[1]26
27testhash ()
28{
[19]29 log_start "HASH FUNCTION"
[257]30
31 C_LOGFILE=""
32
33 ls /lib/libpcre* >/dev/null 2>&1
34 if [ $? -eq 0 ]; then
35 C_LOGFILE=" --enable-logfile-monitor "
36 else
37 ls /usr/lib/libpcre* >/dev/null 2>&1
38 if [ $? -eq 0 ]; then
39 C_LOGFILE=" --enable-logfile-monitor "
40 else
41 ls /usr/local/lib/libpcre* >/dev/null 2>&1
42 if [ $? -eq 0 ]; then
43 C_LOGFILE=" --enable-logfile-monitor "
44 fi
45 fi
46 fi
47 if [ x"${C_LOGFILE}" = x ]; then
48 log_msg_ok "Not testing --enable-logfile-monitor";
49 fi
50
[1]51 #
52 # test standalone compilation
53 #
54 TEST="${S}standalone agent${E}"
55 #
56 if test -r "Makefile"; then
57 $MAKE distclean
58 fi
59 #
[257]60 ${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 '--enable-login-watch' '--enable-mounts-check' ${C_LOGFILE} '--enable-process-check' '--enable-port-check' '--enable-suidcheck' '--with-rnd=unix'
[1]61 #
[19]62 fail=0
63 #
[1]64 if test x$? = x0; then
[19]65 [ -z "$verbose" ] || log_msg_ok "configure...";
[1]66 $MAKE > /dev/null 2>> test_log
67 if test x$? = x0; then
[19]68 [ -z "$verbose" ] || log_msg_ok "make...";
[1]69 else
[19]70 [ -z "$quiet" ] && log_msg_fail "make...";
71 fail=1
[1]72 fi
73 else
[19]74 [ -z "$quiet" ] && log_msg_fail "configure...";
75 fail=1
[1]76 fi
[19]77 #
78 if [ $fail -eq 1 ]; then
79 [ -z "$quiet" ] && log_fail 1 ${MAXTEST};
80 return 1
81 fi
82 #
[1]83 echo "Test results of the TIGER hash algorithm" > testhash.tmp
84 echo >> testhash.tmp
85 echo "(use samhain -H string to test)" >> testhash.tmp
86 echo >> testhash.tmp
87 ./samhain -H "" >> testhash.tmp
88 ./samhain -H "abc" >> testhash.tmp
89 ./samhain -H "Tiger" >> testhash.tmp
90 ./samhain -H "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-" >> testhash.tmp
91 ./samhain -H "ABCDEFGHIJKLMNOPQRSTUVWXYZ=abcdefghijklmnopqrstuvwxyz+0123456789" >> testhash.tmp
92 ./samhain -H "Tiger - A Fast New Hash Function, by Ross Anderson and Eli Biham" >> testhash.tmp
93 ./samhain -H "Tiger - A Fast New Hash Function, by Ross Anderson and Eli Biham, proceedings of Fast Software Encryption 3, Cambridge." >> testhash.tmp
94 ./samhain -H "Tiger - A Fast New Hash Function, by Ross Anderson and Eli Biham, proceedings of Fast Software Encryption 3, Cambridge, 1996." >> testhash.tmp
95 ./samhain -H "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-" >> testhash.tmp
[19]96 #
97 RESU=`diff testhash.tmp ${SCRIPTDIR}/testtiger.txt 2>/dev/null`
[1]98 if test "x${RESU}" = "x"; then
[19]99 [ -z "$quiet" ] && log_ok 1 ${MAXTEST};
[1]100 else
[19]101 [ -z "$quiet" ] && log_fail 1 ${MAXTEST};
102 return 1
[1]103 fi
[159]104 #
105 #
106 #
107 TEST="${S}files${E}"
108 #
109 case $SCRIPTDIR in
110 /*)
111 testpath="${SCRIPTDIR}/testtiger.txt";;
112 *)
113 testpath="`pwd`/${SCRIPTDIR}/testtiger.txt";;
114 esac
115 #
116 RESU=`./samhain -H ${testpath}`
117 #
118 if test x"$RESU" = x"${testpath}: 8125E439 4E7E20F9 24FD8E37 BC4D90C7 FC67F40C 1681F05D"; then
119 [ -z "$quiet" ] && log_ok 2 ${MAXTEST};
120 else
121 [ -z "$quiet" ] && log_fail 2 ${MAXTEST};
122 return 1
123 fi
124 #
[19]125 log_end "HASH FUNCTION"
126 return 0
[1]127}
128
129
130
Note: See TracBrowser for help on using the repository browser.