1 | #! /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 |
|
---|
26 | if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
|
---|
27 | emulate sh
|
---|
28 | NULLCMD=:
|
---|
29 | elif test -n "${BASH_VERSION+set}" && (set -o posix) >/dev/null 2>&1; then
|
---|
30 | set -o posix
|
---|
31 | fi
|
---|
32 |
|
---|
33 | # -----------------------------------------------------------------------
|
---|
34 | # Make sure we support functions (from the autoconf manual)
|
---|
35 | # -----------------------------------------------------------------------
|
---|
36 |
|
---|
37 | TSHELL="${TSHELL-/bin/sh}"
|
---|
38 | if test x"$1" = "x--re-executed"
|
---|
39 | then
|
---|
40 | shift
|
---|
41 | elif "$TSHELL" -c 'foo () { (exit 0); exit 0; }; foo' >/dev/null 2>&1
|
---|
42 | then
|
---|
43 | :
|
---|
44 | else
|
---|
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; }
|
---|
67 | fi
|
---|
68 |
|
---|
69 | # -----------------------------------------------------------------------
|
---|
70 | # Make sure we support 'let' (from the autoconf manual)
|
---|
71 | # -----------------------------------------------------------------------
|
---|
72 |
|
---|
73 | TSHELL="${TSHELL-/bin/sh}"
|
---|
74 | if test x"$1" = "x--re-run"
|
---|
75 | then
|
---|
76 | shift
|
---|
77 | elif "$TSHELL" -c 'a=5; let "a = a + 5"' >/dev/null 2>&1
|
---|
78 | then
|
---|
79 | :
|
---|
80 | else
|
---|
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; }
|
---|
106 | fi
|
---|
107 |
|
---|
108 |
|
---|
109 | umask 0022
|
---|
110 |
|
---|
111 | isok=`test -t 1 2>&1 | wc -c`
|
---|
112 | if [ "$isok" -eq 0 ]; then
|
---|
113 | test -t 1
|
---|
114 | isok=$?
|
---|
115 | fi
|
---|
116 |
|
---|
117 | # The following two are the ANSI sequences for start and end embolden
|
---|
118 | if [ x"$isok" = x0 ]; then
|
---|
119 | case $TERM in
|
---|
120 | vt*|ansi*|con*|xterm*|linux*|screen*|rxvt*)
|
---|
121 | S='[1;30m'
|
---|
122 | R=[31m
|
---|
123 | G=[32m
|
---|
124 | B=[36m
|
---|
125 | E=[m
|
---|
126 | ;;
|
---|
127 | *)
|
---|
128 | S=
|
---|
129 | R=
|
---|
130 | G=
|
---|
131 | B=
|
---|
132 | E=
|
---|
133 | ;;
|
---|
134 | esac
|
---|
135 | fi
|
---|
136 |
|
---|
137 |
|
---|
138 | usage() {
|
---|
139 | echo "test.sh [options] <test_number> [hostname]"
|
---|
140 | echo " [-q|--quiet|-v|--verbose] [-s|--stoponerr] [-n|--no-cleanup]"
|
---|
141 | echo " [--srcdir=top_srcdir] [--color=always|never|auto]"
|
---|
142 | echo
|
---|
143 | echo " ${S}test.sh 1${E} -- Compile with many different options"
|
---|
144 | echo " ${S}test.sh 2${E} -- Hash function (testrc_1)"
|
---|
145 | echo " ${S}test.sh 3${E} -- Standalone init/check"
|
---|
146 | echo " ${S}test.sh 4${E} -- Microstealth init/check"
|
---|
147 | echo " ${S}test.sh 5${E} -- External program call (testrc_1ext.in)"
|
---|
148 | echo " ${S}test.sh 6${E} -- Controlling the daemon"
|
---|
149 | echo " ${S}test.sh 7${E} -- GnuPG signed files / prelude log"
|
---|
150 | echo " ${S}test.sh 8${E} -- Suidcheck"
|
---|
151 | echo " ${S}test.sh 9${E} -- Process check"
|
---|
152 | echo " ${S}test.sh 10${E} -- Port check"
|
---|
153 | echo " ${S}test.sh 11${E} -- CL verify option"
|
---|
154 | echo " ${S}test.sh 12${E} -- CL create DeltaDB"
|
---|
155 | echo " ${S}test.sh 13${E} -- CL create/verify partial DB"
|
---|
156 |
|
---|
157 | echo " ${S}test.sh 20${E} -- Test c/s init/check (testrc_2.in)"
|
---|
158 | echo " ${S}test.sh 21${E} -- Test full c/s init/check (testrc_2.in)"
|
---|
159 | echo " ${S}test.sh 22${E} -- Test full c/s w/gpg (testrc_2.in)"
|
---|
160 | echo " ${S}test.sh 23${E} -- Test full c/s w/mysql (testrc_2.in)"
|
---|
161 | echo " ${S}test.sh 24${E} -- Test full c/s w/postgres (testrc_2.in)"
|
---|
162 | echo " ${S}test.sh 25${E} -- Test server w/yulectl (testrc_2.in)"
|
---|
163 | echo " ${S}test.sh 26${E} -- Test c/s case one (testrc_2.in)"
|
---|
164 | echo " ${S}test.sh 27${E} -- Test c/s case two (testrc_2.in)"
|
---|
165 | echo " ${S}test.sh all${E} -- All tests"
|
---|
166 | }
|
---|
167 | scripts () {
|
---|
168 | echo
|
---|
169 | echo "Scripts used by tests:"
|
---|
170 | echo " (1) testcompile.sh (2) testhash.sh (3) testrun_1.sh (4) testrun_1a.sh"
|
---|
171 | echo " (5) testext.sh (6) testtimesrv.sh (7) testrun_1b.sh (8) testrun_1c.sh"
|
---|
172 | echo " (9) testrun_1d.sh (10) testrun_1e.sh (11) testrun_1f.sh (12) testrun_1g.sh"
|
---|
173 | echo " (13) testrun_1h.sh"
|
---|
174 | echo " (20) testrun_2.sh (21) testrun_2a.sh (22) testrun_2b.sh (23) testrun_2c.sh"
|
---|
175 | echo " (24) testrun_2d.sh (25) testrun_2e.sh (26) testrun_2f.sh (27) testrun_2g.sh"
|
---|
176 | }
|
---|
177 |
|
---|
178 | #
|
---|
179 | # Option parsing
|
---|
180 | #
|
---|
181 | verbose=
|
---|
182 | quiet=
|
---|
183 | stoponerr=
|
---|
184 | color=auto
|
---|
185 | cleanup=on
|
---|
186 | doall=
|
---|
187 | usevalgrind=
|
---|
188 |
|
---|
189 | while [ $# -gt 0 ]
|
---|
190 | do
|
---|
191 | case "$1" in
|
---|
192 | -h|--help) usage; exit 0;;
|
---|
193 | --scripts) usage; scripts; exit 0;;
|
---|
194 | -v|--verbose) verbose=on; quiet= ;;
|
---|
195 | -q|--quiet) quiet=on; verbose= ;;
|
---|
196 | -s|--stoponerr) stoponerr=on;;
|
---|
197 | -n|--no-cleanup) cleanup= ;;
|
---|
198 | --really-all) doall=on;;
|
---|
199 | --valgrind) usevalgrind=on;;
|
---|
200 | --srcdir=*) TOP_SRCDIR=`echo $1 | sed s,--srcdir=,,`; export TOP_SRCDIR;;
|
---|
201 | --color=*)
|
---|
202 | arg=`echo $1 | sed s,--color=,,`
|
---|
203 | case $arg in
|
---|
204 | auto) ;;
|
---|
205 | never|none|no)
|
---|
206 | S=
|
---|
207 | R=
|
---|
208 | G=
|
---|
209 | B=
|
---|
210 | E=
|
---|
211 | ;;
|
---|
212 | always|yes)
|
---|
213 | S='[1;30m'
|
---|
214 | R=[31m
|
---|
215 | G=[32m
|
---|
216 | G=[36m
|
---|
217 | E=[m
|
---|
218 | ;;
|
---|
219 | *) echo "Invalid argument $1"; exit 1;;
|
---|
220 | esac
|
---|
221 | ;;
|
---|
222 | -*) echo "Invalid argument $1"; exit 1;;
|
---|
223 | *) break;;
|
---|
224 | esac
|
---|
225 | shift
|
---|
226 | done
|
---|
227 |
|
---|
228 | export verbose
|
---|
229 | export quiet
|
---|
230 | export stoponerr
|
---|
231 | export cleanup
|
---|
232 | export doall
|
---|
233 | export S; export R; export G; export B; export E;
|
---|
234 |
|
---|
235 | SCRIPTDIR=.
|
---|
236 |
|
---|
237 | #
|
---|
238 | # 'make test' will copy the 'test' subdirectory and replace TEST_SRCDIR
|
---|
239 | #
|
---|
240 | TEST_SRCDIR="XXXSRCXXX";
|
---|
241 | if test "x${TOP_SRCDIR}" = x; then
|
---|
242 | # not within source tree, and not called with 'make testN'
|
---|
243 | if test -f "${TEST_SRCDIR}/src/samhain.c"; then
|
---|
244 | TOP_SRCDIR="${TEST_SRCDIR}"; export TOP_SRCDIR
|
---|
245 | if test -f test/testcompile.sh; then
|
---|
246 | SCRIPTDIR=test
|
---|
247 | fi
|
---|
248 | # not within source tree, not called by 'make', and in 'test' subdir
|
---|
249 | elif test -f "../${TEST_SRCDIR}/src/samhain.c"; then
|
---|
250 | cd ..
|
---|
251 | SCRIPTDIR=test
|
---|
252 | TOP_SRCDIR="${TEST_SRCDIR}"; export TOP_SRCDIR
|
---|
253 | # within source tree, and not called with 'make testN'
|
---|
254 | else
|
---|
255 | if test -f ../src/samhain.c; then
|
---|
256 | cd ..
|
---|
257 | SCRIPTDIR=test
|
---|
258 | TOP_SRCDIR=.
|
---|
259 | export TOP_SRCDIR
|
---|
260 | elif test -f ./src/samhain.c; then
|
---|
261 | SCRIPTDIR=test
|
---|
262 | TOP_SRCDIR=.
|
---|
263 | export TOP_SRCDIR
|
---|
264 | else
|
---|
265 | echo "Please use --srcdir=DIR, where DIR should be the"
|
---|
266 | echo "top directory in the samhain source tree."
|
---|
267 | exit 1
|
---|
268 | fi
|
---|
269 | fi
|
---|
270 | else
|
---|
271 | # called by make, or with --srcdir=TOP_SRCDIR
|
---|
272 | if test -f "${TOP_SRCDIR}/src/samhain.c"; then
|
---|
273 | SCRIPTDIR="${TOP_SRCDIR}/test"
|
---|
274 | elif test -f "../${TOP_SRCDIR}/src/samhain.c"; then
|
---|
275 | cd ..; SCRIPTDIR="${TOP_SRCDIR}/test"
|
---|
276 | else
|
---|
277 | echo "Please use --srcdir=DIR, where DIR should be the"
|
---|
278 | echo "top directory in the samhain source tree."
|
---|
279 | exit 1
|
---|
280 | fi
|
---|
281 | fi
|
---|
282 |
|
---|
283 | export SCRIPTDIR
|
---|
284 |
|
---|
285 | PW_DIR=`pwd`; export PW_DIR
|
---|
286 |
|
---|
287 | #
|
---|
288 | # group/world writeable will cause problems
|
---|
289 | #
|
---|
290 | chmod go-w .
|
---|
291 | #
|
---|
292 | #
|
---|
293 | #
|
---|
294 | if test x$UID != x -a x$UID != x0; then
|
---|
295 | TRUST="--with-trusted=0,2,$UID"
|
---|
296 | else
|
---|
297 | TRUST="--with-trusted=0,2,1000"
|
---|
298 | fi
|
---|
299 | export TRUST
|
---|
300 | #
|
---|
301 | # find a good 'make'
|
---|
302 | #
|
---|
303 | MAKE=`which gmake`
|
---|
304 | if test "x$?" = x1 ; then
|
---|
305 | MAKE="make -s -j 3"
|
---|
306 | else
|
---|
307 | MAKE=`which gmake | sed -e "s%\([a-z:]\) .*%\1%g"`
|
---|
308 | if test "x$MAKE" = x; then
|
---|
309 | MAKE="make -s"
|
---|
310 | elif test "x$MAKE" = xno; then
|
---|
311 | MAKE="make -s"
|
---|
312 | else
|
---|
313 | if test "x$MAKE" = "xwhich:"; then
|
---|
314 | MAKE="make -s"
|
---|
315 | else
|
---|
316 | MAKE="gmake -s"
|
---|
317 | gmake -v >/dev/null 2>&1 || MAKE="make -s"
|
---|
318 | fi
|
---|
319 | fi
|
---|
320 | fi
|
---|
321 | export MAKE
|
---|
322 |
|
---|
323 | failcount=0
|
---|
324 | okcount=0
|
---|
325 | skipcount=0
|
---|
326 | global_count=0
|
---|
327 | last_count=0
|
---|
328 |
|
---|
329 | # args: #test, #total, status, optional msg
|
---|
330 | log_msg ()
|
---|
331 | {
|
---|
332 | if [ x"$COLUMNS" != x ]; then
|
---|
333 | TERMWIDTH=$COLUMNS
|
---|
334 | elif [ x"$COLS" != x ]; then
|
---|
335 | TERMWIDTH=$COLS
|
---|
336 | else
|
---|
337 | TERMWIDTH=80
|
---|
338 | fi
|
---|
339 | cols=66;
|
---|
340 | #
|
---|
341 | if [ $1 -eq 0 ]; then
|
---|
342 | msg=" ${4}"
|
---|
343 | else
|
---|
344 | if [ ${1} -eq 1 ]; then
|
---|
345 | global_count=${last_count}
|
---|
346 | fi
|
---|
347 | let "v = $1 + global_count" >/dev/null
|
---|
348 | last_count=${v}
|
---|
349 | dd=''; if [ $v -lt 10 ]; then dd=" "; fi
|
---|
350 | dt=''; if [ $2 -lt 10 ]; then dt=" "; fi
|
---|
351 | if [ -z "$4" ]; then
|
---|
352 | msg=" test ${dd}${v}/${dt}${2}"
|
---|
353 | else
|
---|
354 | msg=" test ${dd}${v}/${dt}${2} ${4}"
|
---|
355 | fi
|
---|
356 | fi
|
---|
357 | #
|
---|
358 | if [ x"$3" = xfailure ]; then
|
---|
359 | ccode=$R
|
---|
360 | elif [ x"$3" = xsuccess ]; then
|
---|
361 | ccode=$G
|
---|
362 | else
|
---|
363 | ccode=$B
|
---|
364 | fi
|
---|
365 | if [ -z "${R}" ]; then
|
---|
366 | echo " [${3}] ${msg}"
|
---|
367 | else
|
---|
368 | # len=${#...} is not bourne shell
|
---|
369 | # also, need to account for terminal control sequences
|
---|
370 | len=`echo "$msg" | awk '/1;30m/ { print length()-10; }; !/1;30m/ { print length();}'`
|
---|
371 | let "cols = cols - len" >/dev/null
|
---|
372 | if [ $cols -ge 0 ]; then
|
---|
373 | moveto='['$cols'C'
|
---|
374 | echo "${msg}${moveto}${ccode}[${3}]${E}"
|
---|
375 | else
|
---|
376 | echo "${msg}${ccode}[${3}]${E}"
|
---|
377 | fi
|
---|
378 | fi
|
---|
379 | }
|
---|
380 |
|
---|
381 | log_fail () {
|
---|
382 | [ -z "$quiet" ] && log_msg "$1" "$2" failure "$3";
|
---|
383 | let "failcount = failcount + 1" >/dev/null;
|
---|
384 | test -z "$stoponerr" || exit 1;
|
---|
385 | }
|
---|
386 | log_ok () {
|
---|
387 | [ -z "$quiet" ] && log_msg "$1" "$2" success "$3";
|
---|
388 | let "okcount = okcount + 1" >/dev/null;
|
---|
389 | }
|
---|
390 | log_skip () {
|
---|
391 | [ -z "$quiet" ] && log_msg "$1" "$2" skipped "$3";
|
---|
392 | let "skipcount = skipcount + 1" >/dev/null;
|
---|
393 | }
|
---|
394 |
|
---|
395 | log_msg_fail () { log_msg 0 0 failure "$1"; }
|
---|
396 | log_msg_ok () { log_msg 0 0 success "$1"; }
|
---|
397 | log_msg_skip () { log_msg 0 0 skipped "$1"; }
|
---|
398 |
|
---|
399 | log_start () {
|
---|
400 | if [ -z "$quiet" ]; then
|
---|
401 | echo;
|
---|
402 | echo "${S}__ START TEST ${1} __${E}";
|
---|
403 | echo;
|
---|
404 | fi
|
---|
405 | }
|
---|
406 | log_end () {
|
---|
407 | if [ -n "$verbose" ]; then
|
---|
408 | echo;
|
---|
409 | echo "${S}__ END TEST ${1} __${E}";
|
---|
410 | echo;
|
---|
411 | fi
|
---|
412 | }
|
---|
413 |
|
---|
414 | # This looks silly, but with solaris10/i386 on vmware,
|
---|
415 | # 'sleep' occasionally does not sleep...
|
---|
416 |
|
---|
417 | one_sec_sleep () {
|
---|
418 | onesdate=`date`
|
---|
419 | onestest=0
|
---|
420 | while [ $onestest -eq 0 ]; do
|
---|
421 | sleep 1
|
---|
422 | twosdate=`date`
|
---|
423 | if [ "x$twosdate" = "x$onesdate" ]; then
|
---|
424 | onestest=0
|
---|
425 | else
|
---|
426 | onestest=1
|
---|
427 | fi
|
---|
428 | done
|
---|
429 | }
|
---|
430 |
|
---|
431 | five_sec_sleep () {
|
---|
432 | for f in 1 2 3 4 5; do
|
---|
433 | one_sec_sleep
|
---|
434 | done
|
---|
435 | }
|
---|
436 |
|
---|
437 | do_cleanup () {
|
---|
438 | rm -f testrc_1.dyn
|
---|
439 | rm -f testrc_2
|
---|
440 | rm -f testrc_22
|
---|
441 | rm -f testrc_1ext
|
---|
442 | rm -f ./.samhain_file
|
---|
443 | rm -f file.*.*-*-*-*-*
|
---|
444 | rm -f ./.samhain_log*
|
---|
445 | rm -f ./.samhain_lock*
|
---|
446 | test -d testrun_testdata && chmod -f -R 0700 testrun_testdata
|
---|
447 | test -d .quarantine && rm -rf .quarantine
|
---|
448 | rm -rf testrun_testdata
|
---|
449 | rm -f test_log_db
|
---|
450 | rm -f test_log_prelude
|
---|
451 | rm -f test_log_valgrind*
|
---|
452 | rm -f test_log_yulectl
|
---|
453 | rm -f yule.html
|
---|
454 | rm -f yule.html2
|
---|
455 | rm -f test_dnmalloc
|
---|
456 | rm -f tmp_list_file
|
---|
457 | rm -f test_filter.txt
|
---|
458 | }
|
---|
459 |
|
---|
460 | print_summary ()
|
---|
461 | {
|
---|
462 | # let "gcount = okcount + skipcount + failcount" >/dev/null;
|
---|
463 | gcount=$MAXTEST;
|
---|
464 | let "failcount = gcount - okcount - skipcount" >/dev/null;
|
---|
465 |
|
---|
466 | [ -z "$quiet" ] && {
|
---|
467 | echo
|
---|
468 | echo "__ ${S}Tests: ${gcount} Ok: ${okcount} Skipped: ${skipcount} Failed: ${failcount}${E}"
|
---|
469 | }
|
---|
470 | if [ $failcount -eq 0 ]; then
|
---|
471 | [ -z "$quiet" ] && { echo "__ ${G}All tests passed successfully.${E}"; echo; }
|
---|
472 | elif [ $failcount -eq 1 ]; then
|
---|
473 | [ -z "$quiet" ] && { echo "__ ${R}There was 1 failure.${E}"; echo; }
|
---|
474 | else
|
---|
475 | [ -z "$quiet" ] && { echo "__ ${R}There were $failcount failures.${E}"; echo; }
|
---|
476 | fi
|
---|
477 | [ -z "$cleanup" ] || do_cleanup;
|
---|
478 | }
|
---|
479 |
|
---|
480 | find_path () { (
|
---|
481 | save_IFS=$IFS; IFS=:
|
---|
482 |
|
---|
483 | for dir in $PATH; do
|
---|
484 | IFS=$as_save_IFS
|
---|
485 | test -z "$dir" && dir=.
|
---|
486 | if test -f "$dir/$1"; then
|
---|
487 | echo "$dir/$1";
|
---|
488 | break;
|
---|
489 | fi
|
---|
490 | done
|
---|
491 | IFS=${save_IFS};
|
---|
492 | ); }
|
---|
493 |
|
---|
494 | find_hostname () {
|
---|
495 |
|
---|
496 | uname -a | grep Linux >/dev/null
|
---|
497 | if [ $? -eq 0 ]; then
|
---|
498 | tmp=`hostname -f 2>/dev/null`
|
---|
499 | if [ $? -ne 0 ]; then
|
---|
500 | tmp=`hostname 2>/dev/null`
|
---|
501 | fi
|
---|
502 | else
|
---|
503 | tmp=`hostname 2>/dev/null`
|
---|
504 | fi
|
---|
505 | if [ -z "$tmp" ]; then
|
---|
506 | tmp="localhost"
|
---|
507 | fi
|
---|
508 | #
|
---|
509 | # first one is hostname, others are aliases
|
---|
510 | #
|
---|
511 | tmp2=`cat /etc/hosts | egrep "^ *[0123456789].* $tmp" | awk '{ print $2 }'`
|
---|
512 | if [ -z "$tmp2" ]; then
|
---|
513 | echo "$tmp"
|
---|
514 | else
|
---|
515 | echo "$tmp2"
|
---|
516 | fi
|
---|
517 | }
|
---|
518 |
|
---|
519 | rm -f ./test_log
|
---|
520 |
|
---|
521 | # first one is hostname, others are aliases
|
---|
522 | #
|
---|
523 | hostname=`cat /etc/hosts | egrep "^ *127.0.0.1" | awk '{ print $2 }'`
|
---|
524 | if [ x"$hostname" = xlocalhost ]; then
|
---|
525 | hostname="127.0.0.1"
|
---|
526 | fi
|
---|
527 |
|
---|
528 | # Seems that 'valgrind' causes random hangs :-(
|
---|
529 | #
|
---|
530 | if [ -z "$usevalgrind" ]; then
|
---|
531 | VALGRIND=
|
---|
532 | else
|
---|
533 | VALGRIND=`find_path valgrind`;
|
---|
534 | fi
|
---|
535 | [ -z "$VALGRIND" ] || {
|
---|
536 | VALGRIND="$VALGRIND --quiet --tool=memcheck --suppressions=.test.supp";
|
---|
537 | export VALGRIND;
|
---|
538 | [ -z "$verbose" ] || log_msg_ok "using valgrind"
|
---|
539 | cat > ".test.supp" <<End-of-data
|
---|
540 | #
|
---|
541 | # there are unitialized bytes in the struct...
|
---|
542 | #
|
---|
543 | {
|
---|
544 | pushdata_01
|
---|
545 | Memcheck:Param
|
---|
546 | write(buf)
|
---|
547 | obj:/lib/ld-*.so
|
---|
548 | fun:sh_hash_pushdata
|
---|
549 | fun:sh_files_filecheck
|
---|
550 | fun:sh_dirs_chk
|
---|
551 | }
|
---|
552 | {
|
---|
553 | pushdata_02
|
---|
554 | Memcheck:Param
|
---|
555 | write(buf)
|
---|
556 | obj:/lib/ld-*.so
|
---|
557 | fun:sh_hash_pushdata
|
---|
558 | fun:sh_files_filecheck
|
---|
559 | fun:sh_files_checkdir
|
---|
560 | }
|
---|
561 | {
|
---|
562 | pushdata_03
|
---|
563 | Memcheck:Param
|
---|
564 | write(buf)
|
---|
565 | obj:/lib/ld-*.so
|
---|
566 | fun:sh_hash_pushdata
|
---|
567 | fun:sh_hash_writeout
|
---|
568 | fun:main
|
---|
569 | }
|
---|
570 |
|
---|
571 | End-of-data
|
---|
572 | }
|
---|
573 |
|
---|
574 | if test x$1 = x1; then
|
---|
575 | . ${SCRIPTDIR}/testcompile.sh
|
---|
576 | testcompile
|
---|
577 | print_summary
|
---|
578 | exit $?
|
---|
579 | fi
|
---|
580 | if test x$1 = x2; then
|
---|
581 | . ${SCRIPTDIR}/testhash.sh
|
---|
582 | testhash
|
---|
583 | print_summary
|
---|
584 | exit $?
|
---|
585 | fi
|
---|
586 | if test x$1 = x3; then
|
---|
587 | . ${SCRIPTDIR}/testrun_1.sh
|
---|
588 | testrun1
|
---|
589 | print_summary
|
---|
590 | exit $?
|
---|
591 | fi
|
---|
592 | if test x$1 = x4; then
|
---|
593 | . ${SCRIPTDIR}/testrun_1.sh
|
---|
594 | . ${SCRIPTDIR}/testrun_1a.sh
|
---|
595 | testrun1a
|
---|
596 | print_summary
|
---|
597 | exit $?
|
---|
598 | fi
|
---|
599 | if test x$1 = x5; then
|
---|
600 | . ${SCRIPTDIR}/testext.sh
|
---|
601 | testext0
|
---|
602 | print_summary
|
---|
603 | exit $?
|
---|
604 | fi
|
---|
605 | if test x$1 = x6; then
|
---|
606 | . ${SCRIPTDIR}/testtimesrv.sh
|
---|
607 | testtime0
|
---|
608 | print_summary
|
---|
609 | exit $?
|
---|
610 | fi
|
---|
611 | if test x$1 = x7; then
|
---|
612 | . ${SCRIPTDIR}/testrun_1b.sh
|
---|
613 | testrun1b
|
---|
614 | print_summary
|
---|
615 | exit $?
|
---|
616 | fi
|
---|
617 | if test x$1 = x8; then
|
---|
618 | . ${SCRIPTDIR}/testrun_1.sh
|
---|
619 | . ${SCRIPTDIR}/testrun_1c.sh
|
---|
620 | testrun1c
|
---|
621 | print_summary
|
---|
622 | exit $?
|
---|
623 | fi
|
---|
624 | if test x$1 = x9; then
|
---|
625 | . ${SCRIPTDIR}/testrun_1.sh
|
---|
626 | . ${SCRIPTDIR}/testrun_1d.sh
|
---|
627 | testrun1d
|
---|
628 | print_summary
|
---|
629 | exit $?
|
---|
630 | fi
|
---|
631 | if test x$1 = x10; then
|
---|
632 | . ${SCRIPTDIR}/testrun_1.sh
|
---|
633 | . ${SCRIPTDIR}/testrun_1e.sh
|
---|
634 | testrun1e
|
---|
635 | print_summary
|
---|
636 | exit $?
|
---|
637 | fi
|
---|
638 | if test x$1 = x11; then
|
---|
639 | . ${SCRIPTDIR}/testrun_1.sh
|
---|
640 | . ${SCRIPTDIR}/testrun_1f.sh
|
---|
641 | testrun1f
|
---|
642 | print_summary
|
---|
643 | exit $?
|
---|
644 | fi
|
---|
645 | if test x$1 = x12; then
|
---|
646 | . ${SCRIPTDIR}/testrun_1.sh
|
---|
647 | . ${SCRIPTDIR}/testrun_1g.sh
|
---|
648 | testrun1g
|
---|
649 | print_summary
|
---|
650 | exit $?
|
---|
651 | fi
|
---|
652 | if test x$1 = x13; then
|
---|
653 | . ${SCRIPTDIR}/testrun_1.sh
|
---|
654 | . ${SCRIPTDIR}/testrun_1h.sh
|
---|
655 | testrun1h
|
---|
656 | print_summary
|
---|
657 | exit $?
|
---|
658 | fi
|
---|
659 | if test x$1 = x20; then
|
---|
660 | . ${SCRIPTDIR}/testrun_2.sh
|
---|
661 | testrun2 $hostname
|
---|
662 | print_summary
|
---|
663 | exit $?
|
---|
664 | fi
|
---|
665 | if test x$1 = x21; then
|
---|
666 | . ${SCRIPTDIR}/testrun_2a.sh
|
---|
667 | testrun2a $hostname
|
---|
668 | print_summary
|
---|
669 | exit $?
|
---|
670 | fi
|
---|
671 | if test x$1 = x22; then
|
---|
672 | . ${SCRIPTDIR}/testrun_2a.sh
|
---|
673 | . ${SCRIPTDIR}/testrun_2b.sh
|
---|
674 | testrun2b $hostname
|
---|
675 | print_summary
|
---|
676 | exit $?
|
---|
677 | fi
|
---|
678 | if test x$1 = x23; then
|
---|
679 | . ${SCRIPTDIR}/testrun_2a.sh
|
---|
680 | . ${SCRIPTDIR}/testrun_2c.sh
|
---|
681 | testrun2c $hostname
|
---|
682 | print_summary
|
---|
683 | exit $?
|
---|
684 | fi
|
---|
685 | if test x$1 = x24; then
|
---|
686 | . ${SCRIPTDIR}/testrun_2a.sh
|
---|
687 | . ${SCRIPTDIR}/testrun_2d.sh
|
---|
688 | testrun2d $hostname
|
---|
689 | print_summary
|
---|
690 | exit $?
|
---|
691 | fi
|
---|
692 | if test x$1 = x25; then
|
---|
693 | . ${SCRIPTDIR}/testrun_2e.sh
|
---|
694 | testrun2e $hostname
|
---|
695 | print_summary
|
---|
696 | exit $?
|
---|
697 | fi
|
---|
698 | if test x$1 = x26; then
|
---|
699 | . ${SCRIPTDIR}/testrun_2f.sh
|
---|
700 | testrun2f $hostname
|
---|
701 | print_summary
|
---|
702 | exit $?
|
---|
703 | fi
|
---|
704 | if test x$1 = x27; then
|
---|
705 | . ${SCRIPTDIR}/testrun_2g.sh
|
---|
706 | testrun2g $hostname
|
---|
707 | print_summary
|
---|
708 | exit $?
|
---|
709 | fi
|
---|
710 | if test x$1 = xall; then
|
---|
711 | TEST_MAX=0
|
---|
712 | . ${SCRIPTDIR}/testcompile.sh
|
---|
713 | let "TEST_MAX = TEST_MAX + MAXTEST" >/dev/null
|
---|
714 | . ${SCRIPTDIR}/testhash.sh
|
---|
715 | let "TEST_MAX = TEST_MAX + MAXTEST" >/dev/null
|
---|
716 | . ${SCRIPTDIR}/testrun_1.sh
|
---|
717 | let "TEST_MAX = TEST_MAX + MAXTEST" >/dev/null
|
---|
718 | . ${SCRIPTDIR}/testrun_1a.sh
|
---|
719 | let "TEST_MAX = TEST_MAX + MAXTEST" >/dev/null
|
---|
720 | . ${SCRIPTDIR}/testext.sh
|
---|
721 | let "TEST_MAX = TEST_MAX + MAXTEST" >/dev/null
|
---|
722 | . ${SCRIPTDIR}/testtimesrv.sh
|
---|
723 | let "TEST_MAX = TEST_MAX + MAXTEST" >/dev/null
|
---|
724 | . ${SCRIPTDIR}/testrun_1b.sh
|
---|
725 | let "TEST_MAX = TEST_MAX + MAXTEST" >/dev/null
|
---|
726 | . ${SCRIPTDIR}/testrun_1c.sh
|
---|
727 | let "TEST_MAX = TEST_MAX + MAXTEST" >/dev/null
|
---|
728 | . ${SCRIPTDIR}/testrun_1d.sh
|
---|
729 | let "TEST_MAX = TEST_MAX + MAXTEST" >/dev/null
|
---|
730 | . ${SCRIPTDIR}/testrun_1e.sh
|
---|
731 | let "TEST_MAX = TEST_MAX + MAXTEST" >/dev/null
|
---|
732 | . ${SCRIPTDIR}/testrun_1f.sh
|
---|
733 | let "TEST_MAX = TEST_MAX + MAXTEST" >/dev/null
|
---|
734 | . ${SCRIPTDIR}/testrun_1g.sh
|
---|
735 | let "TEST_MAX = TEST_MAX + MAXTEST" >/dev/null
|
---|
736 | . ${SCRIPTDIR}/testrun_1h.sh
|
---|
737 | let "TEST_MAX = TEST_MAX + MAXTEST" >/dev/null
|
---|
738 | . ${SCRIPTDIR}/testrun_2.sh
|
---|
739 | let "TEST_MAX = TEST_MAX + MAXTEST" >/dev/null
|
---|
740 | . ${SCRIPTDIR}/testrun_2a.sh
|
---|
741 | let "TEST_MAX = TEST_MAX + MAXTEST" >/dev/null
|
---|
742 | . ${SCRIPTDIR}/testrun_2b.sh
|
---|
743 | let "TEST_MAX = TEST_MAX + MAXTEST" >/dev/null
|
---|
744 | . ${SCRIPTDIR}/testrun_2c.sh
|
---|
745 | let "TEST_MAX = TEST_MAX + MAXTEST" >/dev/null
|
---|
746 | . ${SCRIPTDIR}/testrun_2d.sh
|
---|
747 | let "TEST_MAX = TEST_MAX + MAXTEST" >/dev/null
|
---|
748 | . ${SCRIPTDIR}/testrun_2e.sh
|
---|
749 | let "TEST_MAX = TEST_MAX + MAXTEST" >/dev/null
|
---|
750 | . ${SCRIPTDIR}/testrun_2f.sh
|
---|
751 | let "TEST_MAX = TEST_MAX + MAXTEST" >/dev/null
|
---|
752 | . ${SCRIPTDIR}/testrun_2g.sh
|
---|
753 | let "TEST_MAX = TEST_MAX + MAXTEST" >/dev/null
|
---|
754 | #
|
---|
755 | # ${SCRIPTDIR}/testtimesrv.sh
|
---|
756 | # ${SCRIPTDIR}/testrun_1b.sh
|
---|
757 | # ${SCRIPTDIR}/testrun_2.sh $2
|
---|
758 | # ${SCRIPTDIR}/testrun_2a.sh $2
|
---|
759 | #
|
---|
760 | MAXTEST=${TEST_MAX}; export MAXTEST
|
---|
761 | testcompile
|
---|
762 | testhash
|
---|
763 | #
|
---|
764 | . ${SCRIPTDIR}/testrun_1.sh
|
---|
765 | MAXTEST=${TEST_MAX}; export MAXTEST
|
---|
766 | testrun1
|
---|
767 | #
|
---|
768 | . ${SCRIPTDIR}/testrun_1a.sh
|
---|
769 | MAXTEST=${TEST_MAX}; export MAXTEST
|
---|
770 | testrun1a
|
---|
771 | #
|
---|
772 | testext0
|
---|
773 | #
|
---|
774 | . ${SCRIPTDIR}/testtimesrv.sh
|
---|
775 | MAXTEST=${TEST_MAX}; export MAXTEST
|
---|
776 | testtime0
|
---|
777 | #
|
---|
778 | . ${SCRIPTDIR}/testrun_1b.sh
|
---|
779 | MAXTEST=${TEST_MAX}; export MAXTEST
|
---|
780 | testrun1b
|
---|
781 | #
|
---|
782 | . ${SCRIPTDIR}/testrun_1.sh
|
---|
783 | . ${SCRIPTDIR}/testrun_1c.sh
|
---|
784 | MAXTEST=${TEST_MAX}; export MAXTEST
|
---|
785 | testrun1c
|
---|
786 | #
|
---|
787 | . ${SCRIPTDIR}/testrun_1.sh
|
---|
788 | . ${SCRIPTDIR}/testrun_1d.sh
|
---|
789 | MAXTEST=${TEST_MAX}; export MAXTEST
|
---|
790 | testrun1d
|
---|
791 | #
|
---|
792 | . ${SCRIPTDIR}/testrun_1.sh
|
---|
793 | . ${SCRIPTDIR}/testrun_1e.sh
|
---|
794 | MAXTEST=${TEST_MAX}; export MAXTEST
|
---|
795 | testrun1e
|
---|
796 | #
|
---|
797 | . ${SCRIPTDIR}/testrun_1.sh
|
---|
798 | . ${SCRIPTDIR}/testrun_1f.sh
|
---|
799 | MAXTEST=${TEST_MAX}; export MAXTEST
|
---|
800 | testrun1f
|
---|
801 | #
|
---|
802 | . ${SCRIPTDIR}/testrun_1.sh
|
---|
803 | . ${SCRIPTDIR}/testrun_1g.sh
|
---|
804 | MAXTEST=${TEST_MAX}; export MAXTEST
|
---|
805 | testrun1g
|
---|
806 | #
|
---|
807 | . ${SCRIPTDIR}/testrun_1.sh
|
---|
808 | . ${SCRIPTDIR}/testrun_1h.sh
|
---|
809 | MAXTEST=${TEST_MAX}; export MAXTEST
|
---|
810 | testrun1h
|
---|
811 | #
|
---|
812 | . ${SCRIPTDIR}/testrun_2.sh
|
---|
813 | MAXTEST=${TEST_MAX}; export MAXTEST
|
---|
814 | testrun2 $hostname
|
---|
815 | #
|
---|
816 | . ${SCRIPTDIR}/testrun_2a.sh
|
---|
817 | MAXTEST=${TEST_MAX}; export MAXTEST
|
---|
818 | testrun2a $hostname
|
---|
819 | #
|
---|
820 | . ${SCRIPTDIR}/testrun_2b.sh
|
---|
821 | MAXTEST=${TEST_MAX}; export MAXTEST
|
---|
822 | testrun2b $hostname
|
---|
823 | #
|
---|
824 | . ${SCRIPTDIR}/testrun_2c.sh
|
---|
825 | MAXTEST=${TEST_MAX}; export MAXTEST
|
---|
826 | testrun2c $hostname
|
---|
827 | #
|
---|
828 | . ${SCRIPTDIR}/testrun_2d.sh
|
---|
829 | MAXTEST=${TEST_MAX}; export MAXTEST
|
---|
830 | testrun2d $hostname
|
---|
831 | #
|
---|
832 | . ${SCRIPTDIR}/testrun_2e.sh
|
---|
833 | MAXTEST=${TEST_MAX}; export MAXTEST
|
---|
834 | testrun2e $hostname
|
---|
835 | #
|
---|
836 | . ${SCRIPTDIR}/testrun_2f.sh
|
---|
837 | MAXTEST=${TEST_MAX}; export MAXTEST
|
---|
838 | testrun2f $hostname
|
---|
839 | #
|
---|
840 | . ${SCRIPTDIR}/testrun_2g.sh
|
---|
841 | MAXTEST=${TEST_MAX}; export MAXTEST
|
---|
842 | testrun2g $hostname
|
---|
843 | #
|
---|
844 | print_summary
|
---|
845 | exit 0
|
---|
846 | fi
|
---|
847 |
|
---|
848 | usage;
|
---|
849 |
|
---|
850 | exit 1;
|
---|
851 |
|
---|
852 | # gpg -a --clearsign --not-dash-escaped testrc.gpg
|
---|
853 | # gpg -a --clearsign --not-dash-escaped .samhain_file
|
---|
854 | # tar czvf foo.tgz testrc.gpg.asc .samhain_file.asc
|
---|
855 | # cat foo.tgz >>test/test.sh
|
---|
856 |
|
---|
857 | __ARCHIVE_FOLLOWS__
|
---|
858 | p{Uí=lÛFÇé©Å!sÑ-diD&%r |
---|
859 | #QŽÖ |
---|
860 | ÙQ0ÒbÍ€d+Kеk¢@75kå¡l}!KaDÔ:µC=öÐÕ |
---|
861 | ¥ØRA
|
---|
862 | 8MûÄñþw÷ã;Ùñ(Å#ÛêR 1ìÜ[2?=^º0þ@bŒ~ËÒ^ÆÇR4ãcXôåž3IÑvd |
---|
863 | BÊUY¯î÷ºöÿ)7]n |
---|
864 | bD11QBpIH&yQ6EÙÎ/Àä"ÏÉtBž&ع² |
---|
865 | pÍ,B¡,bL KÈRseèäUêȶe6xDZÔ{EÙ §jENkÐ0 |
---|
866 | h!YÓÊP3·ÉŸqG(kºi;P)Êl8î |
---|
867 | Ø:ÚQml¹JÔTÂî1³6²JjÙcR |
---|
868 | Û¯ëŠÅ. %d8Iä:ì7ÁÙ×
|
---|
869 | ¶@sü9!1RÉÙeC+OªgMªÞŸÔQ |
---|
870 | ÓBi Iýb±Šõç5Û-ã\ |
---|
871 | MÇ}.TËæT#g+÷c4l`g6Á¬jgxŒÏ
|
---|
872 | Ñ |
---|
873 | e[Óbz±p£9ÀÆjg6AHFºiànxVÇõ+Gª#ñÒ®@¢e«ŠÅ4QÓ, |
---|
874 | ;±4H i9ᢊ
|
---|
875 | |
---|
876 | |
---|
877 | ># èÚ±z
|
---|
878 | §+nhÔÝÁåð&SN0ZIŒ8Œ«h8ÛÂZb<^~$J+³QÕ(î| |
---|
879 | Ý
|
---|
880 | ëvzYüÖËüô¢w;ÁÖü§tÂ|:}OºãÒŽ^_âJÅto ,ÑR"ž÷(
|
---|
881 | € £«|# |
---|
882 | àr"zè
|
---|
883 | Š¹÷_ÿþÇõ<Nm¹ÿÇ%]ÃüÏŸ:ÿ³¬ÿ,ÿ3vó?KûIþŒüÿëo?õc¢ |
---|
884 | `Þ{Òïñ;C]ÁeTÿª^^qËçNãTÆpëPÃÃÓÆ7]= |
---|
885 | <ûkPqjï
|
---|
886 | Á£?Ô/O |
---|
887 | PÔãӧà&š|9=¬üþðÉêÆÌš |
---|
888 | üöþ0k!ÏDù/ÂúqªúMeð¬2šžÕît·[ýÝf³ßkµúµn£Õì4v[ûÝ~³ÛÚoWö:m¬7÷zZ
|
---|
889 | ¿zõ"¬ |
---|
890 | Œ&žñ墣úw_Snùhÿ8uiÁõ«ûµN£±Ûk÷;j»ßݯï |
---|
891 | tkœfµW7v»Õ^§^ëvêõÇ»œNïåàNÏzäÆ÷·Ÿ-5OA_ |
---|
892 | óÚj¿çÊVüâæ(¯ ¢Éó$Ûﮢì
|
---|
893 | » |
---|
894 | ž^HM |
---|
895 | øb[Œy'ñ
|
---|
896 | ëhIæŒëw5o2 |
---|
897 | ÒÐb!f|81œ|·o
|
---|
898 | @ @ @ ð.ò7<Ì(
|
---|