[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 |
|
---|
[30] | 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 |
|
---|
[19] | 111 | isok=`test -t 1 2>&1 | wc -c`
|
---|
| 112 | if [ "$isok" -eq 0 ]; then
|
---|
| 113 | test -t 1
|
---|
| 114 | isok=$?
|
---|
| 115 | fi
|
---|
[1] | 116 |
|
---|
| 117 | # The following two are the ANSI sequences for start and end embolden
|
---|
[19] | 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
|
---|
[1] | 136 |
|
---|
[19] | 137 |
|
---|
| 138 | usage() {
|
---|
| 139 | echo "test.sh [options] <test_number> [hostname]"
|
---|
| 140 | echo " [-q|--quiet|-v|--verbose] [-s|--stoponerr] [--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"
|
---|
[22] | 150 | echo " ${S}test.sh 8${E} -- Suidcheck"
|
---|
[19] | 151 |
|
---|
| 152 | echo " ${S}test.sh 10${E} -- Test c/s init/check (testrc_2.in)"
|
---|
| 153 | echo " ${S}test.sh 11${E} -- Test full c/s init/check (testrc_2.in)"
|
---|
| 154 | echo " ${S}test.sh 12${E} -- Test full c/s w/gpg (testrc_2.in)"
|
---|
| 155 | echo " ${S}test.sh 13${E} -- Test full c/s w/mysql (testrc_2.in)"
|
---|
| 156 | echo " ${S}test.sh 14${E} -- Test full c/s w/postgres (testrc_2.in)"
|
---|
[22] | 157 | echo " ${S}test.sh all${E} -- All tests"
|
---|
| 158 | }
|
---|
| 159 | scripts () {
|
---|
[19] | 160 | echo
|
---|
[22] | 161 | echo "Scripts used by tests:"
|
---|
[19] | 162 | echo " (1) testcompile.sh (2) testhash.sh (3) testrun_1.sh (4) testrun_1a.sh"
|
---|
[22] | 163 | echo " (5) testext.sh (6) testtimesrv.sh (7) testrun_1b.sh (8) testrun_1c.sh"
|
---|
| 164 | echo " (10) testrun_2.sh (11) testrun_2a.sh (12) testrun_2b.sh (13) testrun_2c.sh"
|
---|
| 165 | echo " (14) testrun_2d.sh"
|
---|
[19] | 166 | }
|
---|
| 167 |
|
---|
| 168 | #
|
---|
| 169 | # Option parsing
|
---|
| 170 | #
|
---|
| 171 | verbose=
|
---|
| 172 | quiet=
|
---|
| 173 | stoponerr=
|
---|
| 174 | color=auto
|
---|
| 175 | cleanup=on
|
---|
| 176 | doall=
|
---|
[22] | 177 | usevalgrind=
|
---|
[19] | 178 |
|
---|
| 179 | while [ $# -gt 0 ]
|
---|
| 180 | do
|
---|
| 181 | case "$1" in
|
---|
| 182 | -h|--help) usage; exit 0;;
|
---|
[22] | 183 | --scripts) usage; scripts; exit 0;;
|
---|
[19] | 184 | -v|--verbose) verbose=on; quiet= ;;
|
---|
| 185 | -q|--quiet) quiet=on; verbose= ;;
|
---|
| 186 | -s|--stoponerr) stoponerr=on;;
|
---|
| 187 | --no-cleanup) cleanup= ;;
|
---|
| 188 | --really-all) doall=on;;
|
---|
[22] | 189 | --valgrind) usevalgrind=on;;
|
---|
[19] | 190 | --srcdir=*) TOP_SRCDIR=`echo $1 | sed s,--srcdir=,,`; export TOP_SRCDIR;;
|
---|
| 191 | --color=*)
|
---|
| 192 | arg=`echo $1 | sed s,--color=,,`
|
---|
| 193 | case $arg in
|
---|
| 194 | auto) ;;
|
---|
| 195 | never|none|no)
|
---|
| 196 | S=
|
---|
| 197 | R=
|
---|
| 198 | G=
|
---|
| 199 | B=
|
---|
| 200 | E=
|
---|
| 201 | ;;
|
---|
| 202 | always|yes)
|
---|
| 203 | S='[1;30m'
|
---|
| 204 | R=[31m
|
---|
| 205 | G=[32m
|
---|
| 206 | G=[36m
|
---|
| 207 | E=[m
|
---|
| 208 | ;;
|
---|
| 209 | *) echo "Invalid argument $1"; exit 1;;
|
---|
| 210 | esac
|
---|
| 211 | ;;
|
---|
| 212 | -*) echo "Invalid argument $1"; exit 1;;
|
---|
| 213 | *) break;;
|
---|
| 214 | esac
|
---|
| 215 | shift
|
---|
| 216 | done
|
---|
| 217 |
|
---|
| 218 | export verbose
|
---|
| 219 | export quiet
|
---|
| 220 | export stoponerr
|
---|
| 221 | export cleanup
|
---|
| 222 | export doall
|
---|
| 223 | export S; export R; export G; export B; export E;
|
---|
| 224 |
|
---|
[1] | 225 | SCRIPTDIR=.
|
---|
| 226 |
|
---|
[19] | 227 | #
|
---|
| 228 | # 'make test' will copy the 'test' subdirectory and replace TEST_SRCDIR
|
---|
| 229 | #
|
---|
[1] | 230 | TEST_SRCDIR="XXXSRCXXX";
|
---|
| 231 | if test "x${TOP_SRCDIR}" = x; then
|
---|
| 232 | # not within source tree, and not called with 'make testN'
|
---|
| 233 | if test -f "${TEST_SRCDIR}/src/samhain.c"; then
|
---|
| 234 | TOP_SRCDIR="${TEST_SRCDIR}"; export TOP_SRCDIR
|
---|
| 235 | if test -f test/testcompile.sh; then
|
---|
| 236 | SCRIPTDIR=test
|
---|
| 237 | fi
|
---|
| 238 | # not within source tree, not called by 'make', and in 'test' subdir
|
---|
| 239 | elif test -f "../${TEST_SRCDIR}/src/samhain.c"; then
|
---|
| 240 | cd ..
|
---|
| 241 | SCRIPTDIR=test
|
---|
| 242 | TOP_SRCDIR="${TEST_SRCDIR}"; export TOP_SRCDIR
|
---|
| 243 | # within source tree, and not called with 'make testN'
|
---|
| 244 | else
|
---|
| 245 | if test -f ../src/samhain.c; then
|
---|
| 246 | cd ..
|
---|
| 247 | SCRIPTDIR=test
|
---|
| 248 | TOP_SRCDIR=.
|
---|
| 249 | export TOP_SRCDIR
|
---|
| 250 | elif test -f ./src/samhain.c; then
|
---|
| 251 | SCRIPTDIR=test
|
---|
| 252 | TOP_SRCDIR=.
|
---|
| 253 | export TOP_SRCDIR
|
---|
| 254 | else
|
---|
[19] | 255 | echo "Please use --srcdir=DIR, where DIR should be the"
|
---|
[1] | 256 | echo "top directory in the samhain source tree."
|
---|
| 257 | exit 1
|
---|
| 258 | fi
|
---|
| 259 | fi
|
---|
| 260 | else
|
---|
[19] | 261 | # called by make, or with --srcdir=TOP_SRCDIR
|
---|
| 262 | if test -f "${TOP_SRCDIR}/src/samhain.c"; then
|
---|
| 263 | SCRIPTDIR="${TOP_SRCDIR}/test"
|
---|
| 264 | elif test -f "../${TOP_SRCDIR}/src/samhain.c"; then
|
---|
| 265 | cd ..; SCRIPTDIR="${TOP_SRCDIR}/test"
|
---|
[1] | 266 | else
|
---|
[19] | 267 | echo "Please use --srcdir=DIR, where DIR should be the"
|
---|
| 268 | echo "top directory in the samhain source tree."
|
---|
| 269 | exit 1
|
---|
[1] | 270 | fi
|
---|
| 271 | fi
|
---|
| 272 |
|
---|
| 273 | export SCRIPTDIR
|
---|
| 274 |
|
---|
| 275 | PW_DIR=`pwd`; export PW_DIR
|
---|
[29] | 276 |
|
---|
[19] | 277 | #
|
---|
[29] | 278 | # group/world writeable will cause problems
|
---|
[19] | 279 | #
|
---|
[29] | 280 | chmod go-w .
|
---|
[19] | 281 | #
|
---|
[29] | 282 | #
|
---|
| 283 | #
|
---|
[19] | 284 | if test x$UID != x; then
|
---|
| 285 | TRUST="--with-trusted=0,2,$UID"
|
---|
| 286 | else
|
---|
| 287 | TRUST="--with-trusted=0,2,500"
|
---|
| 288 | fi
|
---|
| 289 | export TRUST
|
---|
| 290 | #
|
---|
| 291 | # find a good 'make'
|
---|
| 292 | #
|
---|
| 293 | MAKE=`which gmake`
|
---|
| 294 | if test "x$?" = x1 ; then
|
---|
| 295 | MAKE="make -s"
|
---|
| 296 | else
|
---|
| 297 | MAKE=`which gmake | sed -e "s%\([a-z:]\) .*%\1%g"`
|
---|
| 298 | if test "x$MAKE" = x; then
|
---|
| 299 | MAKE="make -s"
|
---|
| 300 | elif test "x$MAKE" = xno; then
|
---|
| 301 | MAKE="make -s"
|
---|
| 302 | else
|
---|
| 303 | if test "x$MAKE" = "xwhich:"; then
|
---|
| 304 | MAKE="make -s"
|
---|
| 305 | else
|
---|
| 306 | MAKE="gmake -s"
|
---|
| 307 | gmake -v >/dev/null 2>&1 || MAKE="make -s"
|
---|
| 308 | fi
|
---|
| 309 | fi
|
---|
| 310 | fi
|
---|
| 311 | export MAKE
|
---|
[1] | 312 |
|
---|
[19] | 313 | failcount=0
|
---|
| 314 | okcount=0
|
---|
| 315 | skipcount=0
|
---|
| 316 | global_count=0
|
---|
| 317 | last_count=0
|
---|
| 318 |
|
---|
| 319 | # args: #test, #total, status, optional msg
|
---|
| 320 | log_msg ()
|
---|
| 321 | {
|
---|
| 322 | if [ x"$COLUMNS" != x ]; then
|
---|
| 323 | TERMWIDTH=$COLUMNS
|
---|
| 324 | elif [ x"$COLS" != x ]; then
|
---|
| 325 | TERMWIDTH=$COLS
|
---|
| 326 | else
|
---|
| 327 | TERMWIDTH=80
|
---|
| 328 | fi
|
---|
| 329 | cols=66;
|
---|
| 330 | #
|
---|
| 331 | if [ $1 -eq 0 ]; then
|
---|
| 332 | msg=" ${4}"
|
---|
| 333 | else
|
---|
| 334 | if [ ${1} -eq 1 ]; then
|
---|
| 335 | global_count=${last_count}
|
---|
| 336 | fi
|
---|
| 337 | let "v = $1 + global_count" >/dev/null
|
---|
| 338 | last_count=${v}
|
---|
| 339 | dd=''; if [ $v -lt 10 ]; then dd=" "; fi
|
---|
| 340 | dt=''; if [ $2 -lt 10 ]; then dt=" "; fi
|
---|
| 341 | if [ -z "$4" ]; then
|
---|
| 342 | msg=" test ${dd}${v}/${dt}${2}"
|
---|
| 343 | else
|
---|
| 344 | msg=" test ${dd}${v}/${dt}${2} ${4}"
|
---|
| 345 | fi
|
---|
| 346 | fi
|
---|
| 347 | #
|
---|
| 348 | if [ x"$3" = xfailure ]; then
|
---|
| 349 | ccode=$R
|
---|
| 350 | elif [ x"$3" = xsuccess ]; then
|
---|
| 351 | ccode=$G
|
---|
| 352 | else
|
---|
| 353 | ccode=$B
|
---|
| 354 | fi
|
---|
| 355 | if [ -z "${R}" ]; then
|
---|
| 356 | echo " [${3}] ${msg}"
|
---|
| 357 | else
|
---|
| 358 | # len=${#...} is not bourne shell
|
---|
| 359 | # also, need to account for terminal control sequences
|
---|
| 360 | len=`echo "$msg" | awk '/1;30m/ { print length()-10; }; !/1;30m/ { print length();}'`
|
---|
| 361 | let "cols = cols - len" >/dev/null
|
---|
| 362 | moveto='['$cols'C'
|
---|
| 363 | echo "${msg}${moveto}${ccode}[${3}]${E}"
|
---|
| 364 | fi
|
---|
| 365 | }
|
---|
| 366 |
|
---|
| 367 | log_fail () {
|
---|
| 368 | log_msg "$1" "$2" failure "$3";
|
---|
| 369 | let "failcount = failcount + 1" >/dev/null;
|
---|
| 370 | test -z "$stoponerr" || exit 1;
|
---|
| 371 | }
|
---|
| 372 | log_ok () {
|
---|
| 373 | log_msg "$1" "$2" success "$3";
|
---|
| 374 | let "okcount = okcount + 1" >/dev/null;
|
---|
| 375 | }
|
---|
| 376 | log_skip () {
|
---|
| 377 | log_msg "$1" "$2" skipped "$3";
|
---|
| 378 | let "skipcount = skipcount + 1" >/dev/null;
|
---|
| 379 | }
|
---|
| 380 |
|
---|
| 381 | log_msg_fail () { log_msg 0 0 failure "$1"; }
|
---|
| 382 | log_msg_ok () { log_msg 0 0 success "$1"; }
|
---|
| 383 | log_msg_skip () { log_msg 0 0 skipped "$1"; }
|
---|
| 384 |
|
---|
| 385 | log_start () {
|
---|
| 386 | if [ -z "$quiet" ]; then
|
---|
| 387 | echo;
|
---|
| 388 | echo "${S}__ START TEST ${1} __${E}";
|
---|
| 389 | echo;
|
---|
| 390 | fi
|
---|
| 391 | }
|
---|
| 392 | log_end () {
|
---|
| 393 | if [ -n "$verbose" ]; then
|
---|
| 394 | echo;
|
---|
| 395 | echo "${S}__ END TEST ${1} __${E}";
|
---|
| 396 | echo;
|
---|
| 397 | fi
|
---|
| 398 | }
|
---|
| 399 |
|
---|
[51] | 400 | # This looks silly, but with solaris10/i386 on vmware,
|
---|
| 401 | # 'sleep' occasionally does not sleep...
|
---|
| 402 |
|
---|
| 403 | one_sec_sleep () {
|
---|
| 404 | onesdate=`date`
|
---|
| 405 | onestest=0
|
---|
| 406 | while [ $onestest -eq 0 ]; do
|
---|
| 407 | sleep 1
|
---|
| 408 | twosdate=`date`
|
---|
| 409 | if [ "x$twosdate" = "x$onesdate" ]; then
|
---|
| 410 | onestest=0
|
---|
| 411 | else
|
---|
| 412 | onestest=1
|
---|
| 413 | fi
|
---|
| 414 | done
|
---|
| 415 | }
|
---|
| 416 |
|
---|
| 417 | five_sec_sleep () {
|
---|
| 418 | for f in 1 2 3 4 5; do
|
---|
| 419 | one_sec_sleep
|
---|
| 420 | done
|
---|
| 421 | }
|
---|
| 422 |
|
---|
[19] | 423 | do_cleanup () {
|
---|
| 424 | rm -f testrc_1.dyn
|
---|
| 425 | rm -f testrc_2
|
---|
[27] | 426 | rm -f testrc_22
|
---|
[19] | 427 | rm -f ./.samhain_file
|
---|
| 428 | rm -f ./.samhain_log*
|
---|
[27] | 429 | rm -f ./.samhain_lock*
|
---|
[22] | 430 | test -d testrun_testdata && chmod -R 0700 testrun_testdata
|
---|
| 431 | test -d .quarantine && rm -rf .quarantine
|
---|
| 432 | rm -rf testrun_testdata
|
---|
[19] | 433 | rm -f test_log_db
|
---|
| 434 | rm -f test_log_prelude
|
---|
[27] | 435 | rm -f test_log_valgrind*
|
---|
[22] | 436 | rm -f test_log_yulectl
|
---|
| 437 | rm -f yule.html
|
---|
[27] | 438 | rm -f yule.html2
|
---|
[19] | 439 | }
|
---|
| 440 |
|
---|
| 441 | print_summary ()
|
---|
| 442 | {
|
---|
| 443 | let "gcount = okcount + skipcount + failcount" >/dev/null;
|
---|
| 444 | [ -z "$quiet" ] && {
|
---|
| 445 | echo
|
---|
| 446 | echo "__ ${S}Tests: ${gcount} Ok: ${okcount} Skipped: ${skipcount} Failed: ${failcount}${E}"
|
---|
| 447 | }
|
---|
| 448 | if [ $failcount -eq 0 ]; then
|
---|
| 449 | [ -z "$quiet" ] && { echo "__ ${G}All tests passed successfully.${E}"; echo; }
|
---|
| 450 | elif [ $failcount -eq 1 ]; then
|
---|
| 451 | [ -z "$quiet" ] && { echo "__ ${R}There was 1 failure.${E}"; echo; }
|
---|
| 452 | else
|
---|
| 453 | [ -z "$quiet" ] && { echo "__ ${R}There were $failcount failures.${E}"; echo; }
|
---|
| 454 | fi
|
---|
| 455 | [ -z "$cleanup" ] || do_cleanup;
|
---|
| 456 | }
|
---|
| 457 |
|
---|
| 458 | find_path () { (
|
---|
| 459 | save_IFS=$IFS; IFS=:
|
---|
| 460 |
|
---|
| 461 | for dir in $PATH; do
|
---|
| 462 | IFS=$as_save_IFS
|
---|
| 463 | test -z "$dir" && dir=.
|
---|
| 464 | if test -f "$dir/$1"; then
|
---|
| 465 | echo "$dir/$1";
|
---|
| 466 | break;
|
---|
| 467 | fi
|
---|
| 468 | done
|
---|
| 469 | IFS=${save_IFS};
|
---|
| 470 | ); }
|
---|
| 471 |
|
---|
| 472 | find_hostname () {
|
---|
| 473 | tmp=`hostname -f 2>/dev/null`
|
---|
| 474 | if [ $? -ne 0 ]; then
|
---|
| 475 | tmp=`hostname 2>/dev/null`
|
---|
| 476 | fi
|
---|
| 477 | if [ -z "$tmp" ]; then
|
---|
| 478 | tmp="localhost"
|
---|
| 479 | fi
|
---|
[30] | 480 | #
|
---|
| 481 | # first one is hostname, others are aliases
|
---|
| 482 | #
|
---|
| 483 | tmp2=`cat /etc/hosts | egrep "^ *[0123456789].* $tmp" | awk '{ print $2 }'`
|
---|
| 484 | if [ -z "$tmp2" ]; then
|
---|
| 485 | echo "$tmp"
|
---|
| 486 | else
|
---|
| 487 | echo "$tmp2"
|
---|
| 488 | fi
|
---|
[19] | 489 | }
|
---|
| 490 |
|
---|
| 491 | rm -f ./test_log
|
---|
| 492 |
|
---|
| 493 | # first one is hostname, others are aliases
|
---|
| 494 | #
|
---|
| 495 | hostname=`cat /etc/hosts | egrep "^ *127.0.0.1" | awk '{ print $2 }'`
|
---|
| 496 | if [ x"$hostname" = xlocalhost ]; then
|
---|
| 497 | hostname="127.0.0.1"
|
---|
| 498 | fi
|
---|
| 499 |
|
---|
[22] | 500 | # Seems that 'valgrind' causes random hangs :-(
|
---|
| 501 | #
|
---|
| 502 | if [ -z "$usevalgrind" ]; then
|
---|
| 503 | VALGRIND=
|
---|
| 504 | else
|
---|
| 505 | VALGRIND=`find_path valgrind`;
|
---|
| 506 | fi
|
---|
| 507 | [ -z "$VALGRIND" ] || {
|
---|
| 508 | VALGRIND="$VALGRIND --quiet --tool=memcheck --suppressions=.test.supp";
|
---|
| 509 | export VALGRIND;
|
---|
| 510 | [ -z "$verbose" ] || log_msg_ok "using valgrind"
|
---|
| 511 | cat > ".test.supp" <<End-of-data
|
---|
| 512 | #
|
---|
| 513 | # there are unitialized bytes in the struct...
|
---|
| 514 | #
|
---|
| 515 | {
|
---|
| 516 | pushdata_01
|
---|
| 517 | Memcheck:Param
|
---|
| 518 | write(buf)
|
---|
| 519 | obj:/lib/ld-*.so
|
---|
| 520 | fun:sh_hash_pushdata
|
---|
| 521 | fun:sh_files_filecheck
|
---|
| 522 | fun:sh_dirs_chk
|
---|
| 523 | }
|
---|
| 524 | {
|
---|
| 525 | pushdata_02
|
---|
| 526 | Memcheck:Param
|
---|
| 527 | write(buf)
|
---|
| 528 | obj:/lib/ld-*.so
|
---|
| 529 | fun:sh_hash_pushdata
|
---|
| 530 | fun:sh_files_filecheck
|
---|
| 531 | fun:sh_files_checkdir
|
---|
| 532 | }
|
---|
| 533 | {
|
---|
| 534 | pushdata_03
|
---|
| 535 | Memcheck:Param
|
---|
| 536 | write(buf)
|
---|
| 537 | obj:/lib/ld-*.so
|
---|
| 538 | fun:sh_hash_pushdata
|
---|
| 539 | fun:sh_hash_writeout
|
---|
| 540 | fun:main
|
---|
| 541 | }
|
---|
| 542 |
|
---|
| 543 | End-of-data
|
---|
| 544 | }
|
---|
| 545 |
|
---|
[1] | 546 | if test x$1 = x1; then
|
---|
[19] | 547 | . ${SCRIPTDIR}/testcompile.sh
|
---|
| 548 | testcompile
|
---|
| 549 | print_summary
|
---|
| 550 | exit $?
|
---|
[1] | 551 | fi
|
---|
| 552 | if test x$1 = x2; then
|
---|
[19] | 553 | . ${SCRIPTDIR}/testhash.sh
|
---|
| 554 | testhash
|
---|
| 555 | print_summary
|
---|
| 556 | exit $?
|
---|
[1] | 557 | fi
|
---|
| 558 | if test x$1 = x3; then
|
---|
[19] | 559 | . ${SCRIPTDIR}/testrun_1.sh
|
---|
| 560 | testrun1
|
---|
| 561 | print_summary
|
---|
| 562 | exit $?
|
---|
[1] | 563 | fi
|
---|
| 564 | if test x$1 = x4; then
|
---|
[19] | 565 | . ${SCRIPTDIR}/testrun_1.sh
|
---|
| 566 | . ${SCRIPTDIR}/testrun_1a.sh
|
---|
| 567 | testrun1a
|
---|
| 568 | print_summary
|
---|
| 569 | exit $?
|
---|
[1] | 570 | fi
|
---|
| 571 | if test x$1 = x5; then
|
---|
[19] | 572 | . ${SCRIPTDIR}/testext.sh
|
---|
| 573 | testext0
|
---|
| 574 | print_summary
|
---|
| 575 | exit $?
|
---|
[1] | 576 | fi
|
---|
| 577 | if test x$1 = x6; then
|
---|
[19] | 578 | . ${SCRIPTDIR}/testtimesrv.sh
|
---|
| 579 | testtime0
|
---|
| 580 | print_summary
|
---|
| 581 | exit $?
|
---|
[1] | 582 | fi
|
---|
| 583 | if test x$1 = x7; then
|
---|
[19] | 584 | . ${SCRIPTDIR}/testrun_1b.sh
|
---|
| 585 | testrun1b
|
---|
| 586 | print_summary
|
---|
| 587 | exit $?
|
---|
[1] | 588 | fi
|
---|
[22] | 589 | if test x$1 = x8; then
|
---|
| 590 | . ${SCRIPTDIR}/testrun_1.sh
|
---|
| 591 | . ${SCRIPTDIR}/testrun_1c.sh
|
---|
| 592 | testrun1c
|
---|
| 593 | print_summary
|
---|
| 594 | exit $?
|
---|
| 595 | fi
|
---|
[1] | 596 | if test x$1 = x10; then
|
---|
[19] | 597 | . ${SCRIPTDIR}/testrun_2.sh
|
---|
| 598 | testrun2 $hostname
|
---|
| 599 | print_summary
|
---|
| 600 | exit $?
|
---|
[1] | 601 | fi
|
---|
| 602 | if test x$1 = x11; then
|
---|
[19] | 603 | . ${SCRIPTDIR}/testrun_2a.sh
|
---|
| 604 | testrun2a $hostname
|
---|
| 605 | print_summary
|
---|
| 606 | exit $?
|
---|
[1] | 607 | fi
|
---|
| 608 | if test x$1 = x12; then
|
---|
[19] | 609 | . ${SCRIPTDIR}/testrun_2a.sh
|
---|
| 610 | . ${SCRIPTDIR}/testrun_2b.sh
|
---|
| 611 | testrun2b $hostname
|
---|
| 612 | print_summary
|
---|
| 613 | exit $?
|
---|
[1] | 614 | fi
|
---|
| 615 | if test x$1 = x13; then
|
---|
[19] | 616 | . ${SCRIPTDIR}/testrun_2a.sh
|
---|
| 617 | . ${SCRIPTDIR}/testrun_2c.sh
|
---|
| 618 | testrun2c $hostname
|
---|
| 619 | print_summary
|
---|
| 620 | exit $?
|
---|
[1] | 621 | fi
|
---|
| 622 | if test x$1 = x14; then
|
---|
[19] | 623 | . ${SCRIPTDIR}/testrun_2a.sh
|
---|
| 624 | . ${SCRIPTDIR}/testrun_2d.sh
|
---|
| 625 | testrun2d $hostname
|
---|
| 626 | print_summary
|
---|
| 627 | exit $?
|
---|
[1] | 628 | fi
|
---|
| 629 | if test x$1 = xall; then
|
---|
[19] | 630 | TEST_MAX=0
|
---|
| 631 | . ${SCRIPTDIR}/testcompile.sh
|
---|
| 632 | let "TEST_MAX = TEST_MAX + MAXTEST" >/dev/null
|
---|
| 633 | . ${SCRIPTDIR}/testhash.sh
|
---|
| 634 | let "TEST_MAX = TEST_MAX + MAXTEST" >/dev/null
|
---|
| 635 | . ${SCRIPTDIR}/testrun_1.sh
|
---|
| 636 | let "TEST_MAX = TEST_MAX + MAXTEST" >/dev/null
|
---|
| 637 | . ${SCRIPTDIR}/testrun_1a.sh
|
---|
| 638 | let "TEST_MAX = TEST_MAX + MAXTEST" >/dev/null
|
---|
| 639 | . ${SCRIPTDIR}/testext.sh
|
---|
| 640 | let "TEST_MAX = TEST_MAX + MAXTEST" >/dev/null
|
---|
| 641 | . ${SCRIPTDIR}/testtimesrv.sh
|
---|
| 642 | let "TEST_MAX = TEST_MAX + MAXTEST" >/dev/null
|
---|
| 643 | . ${SCRIPTDIR}/testrun_1b.sh
|
---|
| 644 | let "TEST_MAX = TEST_MAX + MAXTEST" >/dev/null
|
---|
[22] | 645 | . ${SCRIPTDIR}/testrun_1c.sh
|
---|
| 646 | let "TEST_MAX = TEST_MAX + MAXTEST" >/dev/null
|
---|
[19] | 647 | . ${SCRIPTDIR}/testrun_2.sh
|
---|
| 648 | let "TEST_MAX = TEST_MAX + MAXTEST" >/dev/null
|
---|
| 649 | . ${SCRIPTDIR}/testrun_2a.sh
|
---|
| 650 | let "TEST_MAX = TEST_MAX + MAXTEST" >/dev/null
|
---|
| 651 | . ${SCRIPTDIR}/testrun_2b.sh
|
---|
| 652 | let "TEST_MAX = TEST_MAX + MAXTEST" >/dev/null
|
---|
| 653 | . ${SCRIPTDIR}/testrun_2c.sh
|
---|
| 654 | let "TEST_MAX = TEST_MAX + MAXTEST" >/dev/null
|
---|
| 655 | . ${SCRIPTDIR}/testrun_2d.sh
|
---|
| 656 | let "TEST_MAX = TEST_MAX + MAXTEST" >/dev/null
|
---|
| 657 | #
|
---|
| 658 | # ${SCRIPTDIR}/testtimesrv.sh
|
---|
| 659 | # ${SCRIPTDIR}/testrun_1b.sh
|
---|
| 660 | # ${SCRIPTDIR}/testrun_2.sh $2
|
---|
| 661 | # ${SCRIPTDIR}/testrun_2a.sh $2
|
---|
| 662 | #
|
---|
| 663 | MAXTEST=${TEST_MAX}; export MAXTEST
|
---|
| 664 | testcompile
|
---|
| 665 | testhash
|
---|
| 666 | #
|
---|
| 667 | . ${SCRIPTDIR}/testrun_1.sh
|
---|
| 668 | MAXTEST=${TEST_MAX}; export MAXTEST
|
---|
| 669 | testrun1
|
---|
| 670 | #
|
---|
| 671 | . ${SCRIPTDIR}/testrun_1a.sh
|
---|
| 672 | MAXTEST=${TEST_MAX}; export MAXTEST
|
---|
| 673 | testrun1a
|
---|
| 674 | #
|
---|
| 675 | testext0
|
---|
| 676 | #
|
---|
| 677 | . ${SCRIPTDIR}/testtimesrv.sh
|
---|
| 678 | MAXTEST=${TEST_MAX}; export MAXTEST
|
---|
| 679 | testtime0
|
---|
| 680 | #
|
---|
| 681 | . ${SCRIPTDIR}/testrun_1b.sh
|
---|
| 682 | MAXTEST=${TEST_MAX}; export MAXTEST
|
---|
| 683 | testrun1b
|
---|
| 684 | #
|
---|
[22] | 685 | . ${SCRIPTDIR}/testrun_1.sh
|
---|
| 686 | . ${SCRIPTDIR}/testrun_1c.sh
|
---|
| 687 | MAXTEST=${TEST_MAX}; export MAXTEST
|
---|
| 688 | testrun1c
|
---|
| 689 | #
|
---|
[19] | 690 | . ${SCRIPTDIR}/testrun_2.sh
|
---|
| 691 | MAXTEST=${TEST_MAX}; export MAXTEST
|
---|
| 692 | testrun2 $hostname
|
---|
| 693 | #
|
---|
| 694 | . ${SCRIPTDIR}/testrun_2a.sh
|
---|
| 695 | MAXTEST=${TEST_MAX}; export MAXTEST
|
---|
| 696 | testrun2a $hostname
|
---|
| 697 | #
|
---|
| 698 | . ${SCRIPTDIR}/testrun_2b.sh
|
---|
| 699 | MAXTEST=${TEST_MAX}; export MAXTEST
|
---|
| 700 | testrun2b $hostname
|
---|
| 701 | #
|
---|
| 702 | . ${SCRIPTDIR}/testrun_2c.sh
|
---|
| 703 | MAXTEST=${TEST_MAX}; export MAXTEST
|
---|
| 704 | testrun2c $hostname
|
---|
| 705 | #
|
---|
| 706 | . ${SCRIPTDIR}/testrun_2d.sh
|
---|
| 707 | MAXTEST=${TEST_MAX}; export MAXTEST
|
---|
| 708 | testrun2d $hostname
|
---|
| 709 | #
|
---|
| 710 | print_summary
|
---|
| 711 | exit 0
|
---|
[1] | 712 | fi
|
---|
| 713 |
|
---|
[19] | 714 | usage;
|
---|
[1] | 715 |
|
---|
[19] | 716 | exit 1;
|
---|
[1] | 717 |
|
---|
[60] | 718 | # gpg -a --clearsign --not-dash-escaped testrc.gpg
|
---|
| 719 | # gpg -a --clearsign --not-dash-escaped .samhain_file
|
---|
| 720 | # tar czvf foo.tgz testrc.gpg.asc .samhain_file.asc
|
---|
| 721 | # cat foo.tgz >>test/test.sh
|
---|
| 722 |
|
---|
[19] | 723 | __ARCHIVE_FOLLOWS__
|
---|
[60] | 724 | £ÉúDíÏoãDÇœ UbN\'€8*Û:IÓJpãÔ-ŠùÑBU!o2M
|
---|
| 725 | þz&éf/#§šgGâßa%7U$ÄHšU{àÚš |
---|
| 726 | ã$M¶Ûª.¬4Ù |
---|
| 727 | Ï÷Þ×3!39΀§dän2;3ã.ïÕ]ýzïÕëóq.~Æ7ëqû\³ |
---|
| 728 | môž< |
---|
| 729 | äo'q²È&)+:2¯êL|
|
---|
| 730 | aùp×a!(-aDÀø²p% |
---|
| 731 | R°×dŒ3ãK |
---|
| 732 |
|
---|
| 733 | "ÒZ'å |
---|
| 734 | JÍÃO,ÔJAIÏF$H |
---|
| 735 | CŠ²dGÁPCËiØ1ûYðØVTäF$ ÀÛP74¬ªyši§ ¿iG(« LgeSÖzGLÀŠd{éEgÀËi:K9%ðiúkIÑ9€8r&ù-pþ |
---|
| 736 | xŸ\ãŠS«º·'4nœÈöo
|
---|
| 737 | ËiÝ0QØÐÑžýâc]Ö_PUÿlêCs?$ýT÷Ð(*&ö+ú¶1Že:ý`&³VdE=o¥ãušyhèÇÈcuÄÖë1×6WÜ¢4C§ÝhTâäÜAÉ/Ö
|
---|
| 738 | ù]nÞ1ÆP2kbÅÐCÔêwõ!ÃÈô:Íò 2I³ª*"B~ºF@Àñ³ÚÝ®ü=§Î |
---|
| 739 | ®.npÉ
|
---|
| 740 | Ö±Áâ]GœhósM¹§Œð]))zöÁ{(âž] |
---|
| 741 | NâUi×òÂKîœùÔ'|ÄÇp4çÑøûá{Þ¹ð¯GCºV}ÑtE4w¬ðáXÄ÷0êÐ
|
---|
| 742 | Š)Xöÿ¶DU÷ ÅËÒû¯n
|
---|
| 743 | ËÚÝú>sþ[:®ÙÿÝ^Þ{ŸÿÏxœ^gÿ÷¹ÙþÿBx1ûÿO¿üÐùý¯œ:à |
---|
| 744 | œ_y>¬^ýËïOE§,>/G)ÀÑö7žîÑÑÙ³ú.µ>>é>ý£[p.®|Cèðýã³'à.(|u¹;ô.§&žý;ýú[?öÓÿîøXù\9Žýfr
|
---|
| 745 | ݧ
|
---|
| 746 | nÁ¹žNZÊõÃÃfѶËõR§]Žª¥b»Ø²Ú |
---|
| 747 | ë°T¬5:õF±TkÚ]ÈÙÿíèôìôQÉ79îëšÇŸ(øhŒ|®šÏÑš(»\Ž¬b«}xPjV«õZµa7êµJŲJr»b[Tfë VªÖ+TßÎN®Ñ$Ñu?ì×OÊߟ³àŒp¥&ÚïhjØ
|
---|
| 748 | «ÒŽ«õN˲[Z³U/µ*õ]?,µ*öA£ZîXV¥n7;Ã:=îþùëcg®úrR ZþÅS\%c§ž7{¢äâI`nÝ+
|
---|
| 749 | ©D@ÌMûBgÝéœEa-^ú|7¢EgædFü8(íFdLOñÉ |
---|
| 750 | ûâ |
---|
| 751 | Á`0 |
---|
| 752 | Á`0 |
---|
| 753 | Á`0 |
---|
| 754 | F¿ès(( |
---|