[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 |
|
---|
| 400 | do_cleanup () {
|
---|
| 401 | rm -f testrc_1.dyn
|
---|
| 402 | rm -f testrc_2
|
---|
[27] | 403 | rm -f testrc_22
|
---|
[19] | 404 | rm -f ./.samhain_file
|
---|
| 405 | rm -f ./.samhain_log*
|
---|
[27] | 406 | rm -f ./.samhain_lock*
|
---|
[22] | 407 | test -d testrun_testdata && chmod -R 0700 testrun_testdata
|
---|
| 408 | test -d .quarantine && rm -rf .quarantine
|
---|
| 409 | rm -rf testrun_testdata
|
---|
[19] | 410 | rm -f test_log_db
|
---|
| 411 | rm -f test_log_prelude
|
---|
[27] | 412 | rm -f test_log_valgrind*
|
---|
[22] | 413 | rm -f test_log_yulectl
|
---|
| 414 | rm -f yule.html
|
---|
[27] | 415 | rm -f yule.html2
|
---|
[19] | 416 | }
|
---|
| 417 |
|
---|
| 418 | print_summary ()
|
---|
| 419 | {
|
---|
| 420 | let "gcount = okcount + skipcount + failcount" >/dev/null;
|
---|
| 421 | [ -z "$quiet" ] && {
|
---|
| 422 | echo
|
---|
| 423 | echo "__ ${S}Tests: ${gcount} Ok: ${okcount} Skipped: ${skipcount} Failed: ${failcount}${E}"
|
---|
| 424 | }
|
---|
| 425 | if [ $failcount -eq 0 ]; then
|
---|
| 426 | [ -z "$quiet" ] && { echo "__ ${G}All tests passed successfully.${E}"; echo; }
|
---|
| 427 | elif [ $failcount -eq 1 ]; then
|
---|
| 428 | [ -z "$quiet" ] && { echo "__ ${R}There was 1 failure.${E}"; echo; }
|
---|
| 429 | else
|
---|
| 430 | [ -z "$quiet" ] && { echo "__ ${R}There were $failcount failures.${E}"; echo; }
|
---|
| 431 | fi
|
---|
| 432 | [ -z "$cleanup" ] || do_cleanup;
|
---|
| 433 | }
|
---|
| 434 |
|
---|
| 435 | find_path () { (
|
---|
| 436 | save_IFS=$IFS; IFS=:
|
---|
| 437 |
|
---|
| 438 | for dir in $PATH; do
|
---|
| 439 | IFS=$as_save_IFS
|
---|
| 440 | test -z "$dir" && dir=.
|
---|
| 441 | if test -f "$dir/$1"; then
|
---|
| 442 | echo "$dir/$1";
|
---|
| 443 | break;
|
---|
| 444 | fi
|
---|
| 445 | done
|
---|
| 446 | IFS=${save_IFS};
|
---|
| 447 | ); }
|
---|
| 448 |
|
---|
| 449 | find_hostname () {
|
---|
| 450 | tmp=`hostname -f 2>/dev/null`
|
---|
| 451 | if [ $? -ne 0 ]; then
|
---|
| 452 | tmp=`hostname 2>/dev/null`
|
---|
| 453 | fi
|
---|
| 454 | if [ -z "$tmp" ]; then
|
---|
| 455 | tmp="localhost"
|
---|
| 456 | fi
|
---|
[30] | 457 | #
|
---|
| 458 | # first one is hostname, others are aliases
|
---|
| 459 | #
|
---|
| 460 | tmp2=`cat /etc/hosts | egrep "^ *[0123456789].* $tmp" | awk '{ print $2 }'`
|
---|
| 461 | if [ -z "$tmp2" ]; then
|
---|
| 462 | echo "$tmp"
|
---|
| 463 | else
|
---|
| 464 | echo "$tmp2"
|
---|
| 465 | fi
|
---|
[19] | 466 | }
|
---|
| 467 |
|
---|
| 468 | rm -f ./test_log
|
---|
| 469 |
|
---|
| 470 | # first one is hostname, others are aliases
|
---|
| 471 | #
|
---|
| 472 | hostname=`cat /etc/hosts | egrep "^ *127.0.0.1" | awk '{ print $2 }'`
|
---|
| 473 | if [ x"$hostname" = xlocalhost ]; then
|
---|
| 474 | hostname="127.0.0.1"
|
---|
| 475 | fi
|
---|
| 476 |
|
---|
[22] | 477 | # Seems that 'valgrind' causes random hangs :-(
|
---|
| 478 | #
|
---|
| 479 | if [ -z "$usevalgrind" ]; then
|
---|
| 480 | VALGRIND=
|
---|
| 481 | else
|
---|
| 482 | VALGRIND=`find_path valgrind`;
|
---|
| 483 | fi
|
---|
| 484 | [ -z "$VALGRIND" ] || {
|
---|
| 485 | VALGRIND="$VALGRIND --quiet --tool=memcheck --suppressions=.test.supp";
|
---|
| 486 | export VALGRIND;
|
---|
| 487 | [ -z "$verbose" ] || log_msg_ok "using valgrind"
|
---|
| 488 | cat > ".test.supp" <<End-of-data
|
---|
| 489 | #
|
---|
| 490 | # there are unitialized bytes in the struct...
|
---|
| 491 | #
|
---|
| 492 | {
|
---|
| 493 | pushdata_01
|
---|
| 494 | Memcheck:Param
|
---|
| 495 | write(buf)
|
---|
| 496 | obj:/lib/ld-*.so
|
---|
| 497 | fun:sh_hash_pushdata
|
---|
| 498 | fun:sh_files_filecheck
|
---|
| 499 | fun:sh_dirs_chk
|
---|
| 500 | }
|
---|
| 501 | {
|
---|
| 502 | pushdata_02
|
---|
| 503 | Memcheck:Param
|
---|
| 504 | write(buf)
|
---|
| 505 | obj:/lib/ld-*.so
|
---|
| 506 | fun:sh_hash_pushdata
|
---|
| 507 | fun:sh_files_filecheck
|
---|
| 508 | fun:sh_files_checkdir
|
---|
| 509 | }
|
---|
| 510 | {
|
---|
| 511 | pushdata_03
|
---|
| 512 | Memcheck:Param
|
---|
| 513 | write(buf)
|
---|
| 514 | obj:/lib/ld-*.so
|
---|
| 515 | fun:sh_hash_pushdata
|
---|
| 516 | fun:sh_hash_writeout
|
---|
| 517 | fun:main
|
---|
| 518 | }
|
---|
| 519 |
|
---|
| 520 | End-of-data
|
---|
| 521 | }
|
---|
| 522 |
|
---|
[1] | 523 | if test x$1 = x1; then
|
---|
[19] | 524 | . ${SCRIPTDIR}/testcompile.sh
|
---|
| 525 | testcompile
|
---|
| 526 | print_summary
|
---|
| 527 | exit $?
|
---|
[1] | 528 | fi
|
---|
| 529 | if test x$1 = x2; then
|
---|
[19] | 530 | . ${SCRIPTDIR}/testhash.sh
|
---|
| 531 | testhash
|
---|
| 532 | print_summary
|
---|
| 533 | exit $?
|
---|
[1] | 534 | fi
|
---|
| 535 | if test x$1 = x3; then
|
---|
[19] | 536 | . ${SCRIPTDIR}/testrun_1.sh
|
---|
| 537 | testrun1
|
---|
| 538 | print_summary
|
---|
| 539 | exit $?
|
---|
[1] | 540 | fi
|
---|
| 541 | if test x$1 = x4; then
|
---|
[19] | 542 | . ${SCRIPTDIR}/testrun_1.sh
|
---|
| 543 | . ${SCRIPTDIR}/testrun_1a.sh
|
---|
| 544 | testrun1a
|
---|
| 545 | print_summary
|
---|
| 546 | exit $?
|
---|
[1] | 547 | fi
|
---|
| 548 | if test x$1 = x5; then
|
---|
[19] | 549 | . ${SCRIPTDIR}/testext.sh
|
---|
| 550 | testext0
|
---|
| 551 | print_summary
|
---|
| 552 | exit $?
|
---|
[1] | 553 | fi
|
---|
| 554 | if test x$1 = x6; then
|
---|
[19] | 555 | . ${SCRIPTDIR}/testtimesrv.sh
|
---|
| 556 | testtime0
|
---|
| 557 | print_summary
|
---|
| 558 | exit $?
|
---|
[1] | 559 | fi
|
---|
| 560 | if test x$1 = x7; then
|
---|
[19] | 561 | . ${SCRIPTDIR}/testrun_1b.sh
|
---|
| 562 | testrun1b
|
---|
| 563 | print_summary
|
---|
| 564 | exit $?
|
---|
[1] | 565 | fi
|
---|
[22] | 566 | if test x$1 = x8; then
|
---|
| 567 | . ${SCRIPTDIR}/testrun_1.sh
|
---|
| 568 | . ${SCRIPTDIR}/testrun_1c.sh
|
---|
| 569 | testrun1c
|
---|
| 570 | print_summary
|
---|
| 571 | exit $?
|
---|
| 572 | fi
|
---|
[1] | 573 | if test x$1 = x10; then
|
---|
[19] | 574 | . ${SCRIPTDIR}/testrun_2.sh
|
---|
| 575 | testrun2 $hostname
|
---|
| 576 | print_summary
|
---|
| 577 | exit $?
|
---|
[1] | 578 | fi
|
---|
| 579 | if test x$1 = x11; then
|
---|
[19] | 580 | . ${SCRIPTDIR}/testrun_2a.sh
|
---|
| 581 | testrun2a $hostname
|
---|
| 582 | print_summary
|
---|
| 583 | exit $?
|
---|
[1] | 584 | fi
|
---|
| 585 | if test x$1 = x12; then
|
---|
[19] | 586 | . ${SCRIPTDIR}/testrun_2a.sh
|
---|
| 587 | . ${SCRIPTDIR}/testrun_2b.sh
|
---|
| 588 | testrun2b $hostname
|
---|
| 589 | print_summary
|
---|
| 590 | exit $?
|
---|
[1] | 591 | fi
|
---|
| 592 | if test x$1 = x13; then
|
---|
[19] | 593 | . ${SCRIPTDIR}/testrun_2a.sh
|
---|
| 594 | . ${SCRIPTDIR}/testrun_2c.sh
|
---|
| 595 | testrun2c $hostname
|
---|
| 596 | print_summary
|
---|
| 597 | exit $?
|
---|
[1] | 598 | fi
|
---|
| 599 | if test x$1 = x14; then
|
---|
[19] | 600 | . ${SCRIPTDIR}/testrun_2a.sh
|
---|
| 601 | . ${SCRIPTDIR}/testrun_2d.sh
|
---|
| 602 | testrun2d $hostname
|
---|
| 603 | print_summary
|
---|
| 604 | exit $?
|
---|
[1] | 605 | fi
|
---|
| 606 | if test x$1 = xall; then
|
---|
[19] | 607 | TEST_MAX=0
|
---|
| 608 | . ${SCRIPTDIR}/testcompile.sh
|
---|
| 609 | let "TEST_MAX = TEST_MAX + MAXTEST" >/dev/null
|
---|
| 610 | . ${SCRIPTDIR}/testhash.sh
|
---|
| 611 | let "TEST_MAX = TEST_MAX + MAXTEST" >/dev/null
|
---|
| 612 | . ${SCRIPTDIR}/testrun_1.sh
|
---|
| 613 | let "TEST_MAX = TEST_MAX + MAXTEST" >/dev/null
|
---|
| 614 | . ${SCRIPTDIR}/testrun_1a.sh
|
---|
| 615 | let "TEST_MAX = TEST_MAX + MAXTEST" >/dev/null
|
---|
| 616 | . ${SCRIPTDIR}/testext.sh
|
---|
| 617 | let "TEST_MAX = TEST_MAX + MAXTEST" >/dev/null
|
---|
| 618 | . ${SCRIPTDIR}/testtimesrv.sh
|
---|
| 619 | let "TEST_MAX = TEST_MAX + MAXTEST" >/dev/null
|
---|
| 620 | . ${SCRIPTDIR}/testrun_1b.sh
|
---|
| 621 | let "TEST_MAX = TEST_MAX + MAXTEST" >/dev/null
|
---|
[22] | 622 | . ${SCRIPTDIR}/testrun_1c.sh
|
---|
| 623 | let "TEST_MAX = TEST_MAX + MAXTEST" >/dev/null
|
---|
[19] | 624 | . ${SCRIPTDIR}/testrun_2.sh
|
---|
| 625 | let "TEST_MAX = TEST_MAX + MAXTEST" >/dev/null
|
---|
| 626 | . ${SCRIPTDIR}/testrun_2a.sh
|
---|
| 627 | let "TEST_MAX = TEST_MAX + MAXTEST" >/dev/null
|
---|
| 628 | . ${SCRIPTDIR}/testrun_2b.sh
|
---|
| 629 | let "TEST_MAX = TEST_MAX + MAXTEST" >/dev/null
|
---|
| 630 | . ${SCRIPTDIR}/testrun_2c.sh
|
---|
| 631 | let "TEST_MAX = TEST_MAX + MAXTEST" >/dev/null
|
---|
| 632 | . ${SCRIPTDIR}/testrun_2d.sh
|
---|
| 633 | let "TEST_MAX = TEST_MAX + MAXTEST" >/dev/null
|
---|
| 634 | #
|
---|
| 635 | # ${SCRIPTDIR}/testtimesrv.sh
|
---|
| 636 | # ${SCRIPTDIR}/testrun_1b.sh
|
---|
| 637 | # ${SCRIPTDIR}/testrun_2.sh $2
|
---|
| 638 | # ${SCRIPTDIR}/testrun_2a.sh $2
|
---|
| 639 | #
|
---|
| 640 | MAXTEST=${TEST_MAX}; export MAXTEST
|
---|
| 641 | testcompile
|
---|
| 642 | testhash
|
---|
| 643 | #
|
---|
| 644 | . ${SCRIPTDIR}/testrun_1.sh
|
---|
| 645 | MAXTEST=${TEST_MAX}; export MAXTEST
|
---|
| 646 | testrun1
|
---|
| 647 | #
|
---|
| 648 | . ${SCRIPTDIR}/testrun_1a.sh
|
---|
| 649 | MAXTEST=${TEST_MAX}; export MAXTEST
|
---|
| 650 | testrun1a
|
---|
| 651 | #
|
---|
| 652 | testext0
|
---|
| 653 | #
|
---|
| 654 | . ${SCRIPTDIR}/testtimesrv.sh
|
---|
| 655 | MAXTEST=${TEST_MAX}; export MAXTEST
|
---|
| 656 | testtime0
|
---|
| 657 | #
|
---|
| 658 | . ${SCRIPTDIR}/testrun_1b.sh
|
---|
| 659 | MAXTEST=${TEST_MAX}; export MAXTEST
|
---|
| 660 | testrun1b
|
---|
| 661 | #
|
---|
[22] | 662 | . ${SCRIPTDIR}/testrun_1.sh
|
---|
| 663 | . ${SCRIPTDIR}/testrun_1c.sh
|
---|
| 664 | MAXTEST=${TEST_MAX}; export MAXTEST
|
---|
| 665 | testrun1c
|
---|
| 666 | #
|
---|
[19] | 667 | . ${SCRIPTDIR}/testrun_2.sh
|
---|
| 668 | MAXTEST=${TEST_MAX}; export MAXTEST
|
---|
| 669 | testrun2 $hostname
|
---|
| 670 | #
|
---|
| 671 | . ${SCRIPTDIR}/testrun_2a.sh
|
---|
| 672 | MAXTEST=${TEST_MAX}; export MAXTEST
|
---|
| 673 | testrun2a $hostname
|
---|
| 674 | #
|
---|
| 675 | . ${SCRIPTDIR}/testrun_2b.sh
|
---|
| 676 | MAXTEST=${TEST_MAX}; export MAXTEST
|
---|
| 677 | testrun2b $hostname
|
---|
| 678 | #
|
---|
| 679 | . ${SCRIPTDIR}/testrun_2c.sh
|
---|
| 680 | MAXTEST=${TEST_MAX}; export MAXTEST
|
---|
| 681 | testrun2c $hostname
|
---|
| 682 | #
|
---|
| 683 | . ${SCRIPTDIR}/testrun_2d.sh
|
---|
| 684 | MAXTEST=${TEST_MAX}; export MAXTEST
|
---|
| 685 | testrun2d $hostname
|
---|
| 686 | #
|
---|
| 687 | print_summary
|
---|
| 688 | exit 0
|
---|
[1] | 689 | fi
|
---|
| 690 |
|
---|
[19] | 691 | usage;
|
---|
[1] | 692 |
|
---|
[19] | 693 | exit 1;
|
---|
[1] | 694 |
|
---|
[19] | 695 | __ARCHIVE_FOLLOWS__
|
---|
| 696 | -tæCíMoÓ0Ç#@HøÄ
|
---|
| 697 | »Å 4Ñ&m×I9€MõeëËÆ6U(MÝÖ[bwv²®ù|ïÀW$Ä°ç§ÝºŠMHlÈ?µµý÷ËóØqþõ÷ëû1;Ê¥
|
---|
| 698 | Ò©TXjyuÒÖŠíiUM*Ìh©LBMiPéÕËI'JÀ}Aš0ÄÎ?g£ÍÌÊG!ÙŒUªÂek6JV5oÂJŸÑ0¬ü€m>X¢¡*õMÑÊsÇ |
---|
| 699 | ¢î"\§$u¡Ee |
---|
| 700 | úî"{cè0 |
---|
| 701 | âÜî#ÀŠáû |
---|
| 702 | wñ6èaéqä;BÏï"â7P8Ë·Áq%[Õ |
---|
| 703 | QHZTª#»[#î8ªi¿ "ðšj1:€/:é(õ ešJ ê'5Þp]}d32§! õ±f¢×1éÑRµÅ¡LgMLTlì |
---|
| 704 | ÷ù!Ïi1wOiAË |
---|
| 705 | |
---|
| 706 | Ü4ج`îŽi#1LDõÃŒr¶ØCºPC±qLIY,àêÚD,S: |
---|
| 707 | J« ù
|
---|
| 708 | ÀuMä¡År¹p |
---|
| 709 | |
---|
| 710 | xMáúdÑð Ö
|
---|
| 711 | mpÆ-2úÑZE`G·dW%bóðUmÅË{Àæ])óde`íšÞØxüŽÕ
|
---|
| 712 | ìK¹lòùú\¶³j®»:îÌuÞ=7°aäz+k[]gñ|Ü#<ëÄë |
---|
| 713 | ³X±¶ë{ZE:ÞÊe§ æ«æYé]÷+xÄží
|
---|
| 714 | õ= |
---|
| 715 | ßÊKú |
---|
| 716 | žÈÿjêØÿµt* |
---|
| 717 | úFÓ€ÿ_Wãÿï?Ÿ}÷|1Š1ïÜæï»âçåIûÅí\XÞW£åiöO¡þ{ÊáÁÁ·ß÷wŠúöËá÷¯ûáGyý(?ÞŒúüíø|c_ìå/xÍøÀi ßØsÉra×Îhc'Ckt©±# |
---|
| 718 | Œ9ÂMàá%Ô£úd®3l-ÑÂvŒ±¶±. |
---|
| 719 | <7êÍKH$D"H$D"H$D"H$ |
---|
| 720 | ø ?:v( |
---|