X-Git-Url: http://rtime.felk.cvut.cz/gitweb/can-benchmark.git/blobdiff_plain/c602425056bbe84fd1baeb2e75172108760c9b9a..41c72639e9e7f2ed299d5101ace714a72e20543c:/gw-tests/lib.sh diff --git a/gw-tests/lib.sh b/gw-tests/lib.sh index cc5f1b6..f82ea28 100644 --- a/gw-tests/lib.sh +++ b/gw-tests/lib.sh @@ -1,5 +1,13 @@ set -e +while [ $# -gt 0 ]; do + case "$1" in + -P) OPT_PLOT_DISABLE=1; shift;; + -p) OPT_PLOT_ONLY=1; shift;; + -X|--no-x11-plot) OPT_NO_X11=1; shift;; + esac +done + PATH=$PWD/../_compiled/bin/:$PATH COUNT=10000 @@ -21,7 +29,7 @@ sshgw() { ssh -x -a -S $socket root@192.168.2.3 "$@" } -_cleanupgw() { +cleanupgw() { # Set can interfaces up sshgw 'for i in 0 1; do ip link show dev can$i|grep -q UP || ip link set can$i up type can bitrate 1000000; done' # Delete all GW rules @@ -60,25 +68,41 @@ create_dirs_and_links() { } _run() { - _cleanupgw - kvers=$(sshgw uname -r) - dir=$(create_dirs_and_links $(basename $0 .sh) $kvers) - cd $dir - main - _plot + if [[ ! "$OPT_PLOT_ONLY" ]]; then + kernel_versions=$(sshgw uname -r) + else + kernel_versions=$(ls results/by-kern) + fi + for kvers in $kernel_versions; do + dir=$(create_dirs_and_links $(basename $0 .sh) $kvers) + script=$PWD/$0 + cd $dir + if [[ ! "$OPT_PLOT_ONLY" ]]; then + cleanupgw + main + cp $script . + fi + _plot + done } test_end() { test_end_called=t - trap '' DEBUG + exit_ok= _run + exit_ok=t } -exit() { +_myexit() { + code=$? + cmd=$BASH_COMMAND if [[ ! "$test_end_called" ]]; then test_end_called=t error "bug in the test script: No test_end called" fi + if ! test -n "$exit_ok"; then + error "FATAL: Command '$cmd' exited with code $code" + fi } -trap 'exit' EXIT +trap '_myexit' EXIT