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