| .. | .. |
|---|
| 4 | 4 | # IPv4 and IPv6 onlink tests |
|---|
| 5 | 5 | |
|---|
| 6 | 6 | PAUSE_ON_FAIL=${PAUSE_ON_FAIL:=no} |
|---|
| 7 | +VERBOSE=0 |
|---|
| 7 | 8 | |
|---|
| 8 | 9 | # Network interfaces |
|---|
| 9 | 10 | # - odd in current namespace; even in peer ns |
|---|
| .. | .. |
|---|
| 91 | 92 | |
|---|
| 92 | 93 | if [ ${rc} -eq ${expected} ]; then |
|---|
| 93 | 94 | nsuccess=$((nsuccess+1)) |
|---|
| 94 | | - printf "\n TEST: %-50s [ OK ]\n" "${msg}" |
|---|
| 95 | + printf " TEST: %-50s [ OK ]\n" "${msg}" |
|---|
| 95 | 96 | else |
|---|
| 96 | 97 | nfail=$((nfail+1)) |
|---|
| 97 | | - printf "\n TEST: %-50s [FAIL]\n" "${msg}" |
|---|
| 98 | + printf " TEST: %-50s [FAIL]\n" "${msg}" |
|---|
| 98 | 99 | if [ "${PAUSE_ON_FAIL}" = "yes" ]; then |
|---|
| 99 | 100 | echo |
|---|
| 100 | 101 | echo "hit enter to continue, 'q' to quit" |
|---|
| .. | .. |
|---|
| 121 | 122 | |
|---|
| 122 | 123 | run_cmd() |
|---|
| 123 | 124 | { |
|---|
| 124 | | - echo |
|---|
| 125 | | - echo "COMMAND: $*" |
|---|
| 126 | | - eval $* |
|---|
| 125 | + local cmd="$*" |
|---|
| 126 | + local out |
|---|
| 127 | + local rc |
|---|
| 128 | + |
|---|
| 129 | + if [ "$VERBOSE" = "1" ]; then |
|---|
| 130 | + printf " COMMAND: $cmd\n" |
|---|
| 131 | + fi |
|---|
| 132 | + |
|---|
| 133 | + out=$(eval $cmd 2>&1) |
|---|
| 134 | + rc=$? |
|---|
| 135 | + if [ "$VERBOSE" = "1" -a -n "$out" ]; then |
|---|
| 136 | + echo " $out" |
|---|
| 137 | + fi |
|---|
| 138 | + |
|---|
| 139 | + [ "$VERBOSE" = "1" ] && echo |
|---|
| 140 | + |
|---|
| 141 | + return $rc |
|---|
| 127 | 142 | } |
|---|
| 128 | 143 | |
|---|
| 129 | 144 | get_linklocal() |
|---|
| .. | .. |
|---|
| 451 | 466 | } |
|---|
| 452 | 467 | |
|---|
| 453 | 468 | ################################################################################ |
|---|
| 469 | +# usage |
|---|
| 470 | + |
|---|
| 471 | +usage() |
|---|
| 472 | +{ |
|---|
| 473 | + cat <<EOF |
|---|
| 474 | +usage: ${0##*/} OPTS |
|---|
| 475 | + |
|---|
| 476 | + -p Pause on fail |
|---|
| 477 | + -v verbose mode (show commands and output) |
|---|
| 478 | +EOF |
|---|
| 479 | +} |
|---|
| 480 | + |
|---|
| 481 | +################################################################################ |
|---|
| 454 | 482 | # main |
|---|
| 455 | 483 | |
|---|
| 456 | 484 | nsuccess=0 |
|---|
| 457 | 485 | nfail=0 |
|---|
| 458 | 486 | |
|---|
| 487 | +while getopts :t:pPhv o |
|---|
| 488 | +do |
|---|
| 489 | + case $o in |
|---|
| 490 | + p) PAUSE_ON_FAIL=yes;; |
|---|
| 491 | + v) VERBOSE=$(($VERBOSE + 1));; |
|---|
| 492 | + h) usage; exit 0;; |
|---|
| 493 | + *) usage; exit 1;; |
|---|
| 494 | + esac |
|---|
| 495 | +done |
|---|
| 496 | + |
|---|
| 459 | 497 | cleanup |
|---|
| 460 | 498 | setup |
|---|
| 461 | 499 | run_onlink_tests |
|---|