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