diff --git a/tests/61_bench_nic_1BT/test.sh b/tests/61_bench_nic_1BT/test.sh index 874cb9103..ffb057019 100755 --- a/tests/61_bench_nic_1BT/test.sh +++ b/tests/61_bench_nic_1BT/test.sh @@ -9,6 +9,7 @@ BUTTERFLY_BUILD_ROOT=$1 BUTTERFLY_SRC_ROOT=$(cd "$(dirname $0)/../.." && pwd) + source $BUTTERFLY_SRC_ROOT/tests/functions.sh network_connect 0 1 @@ -21,8 +22,10 @@ bench_lat_snd_add 0 1 2 42 sg-1 sleep 0.5 +server_stop 0 network_disconnect 0 1 -server_stop 0 +check_ping 3 5 return_result + diff --git a/tests/62_bench_nic_2BT/test.sh b/tests/62_bench_nic_2BT/test.sh index 05d452bd5..ab3271192 100755 --- a/tests/62_bench_nic_2BT/test.sh +++ b/tests/62_bench_nic_2BT/test.sh @@ -25,4 +25,6 @@ network_disconnect 0 1 server_stop 0 server_stop 1 +check_ping 32000 45000 + return_result diff --git a/tests/functions.sh b/tests/functions.sh index 3ef990b4e..a7b339611 100755 --- a/tests/functions.sh +++ b/tests/functions.sh @@ -1502,6 +1502,31 @@ function fail { exit 1 } +function check_ping { + tmp_ping_file="/tmp/butterfly_bench_ping" + sed -n -e '/^ping/p' build/butterflyd_0_output > $tmp_ping_file + + max_average_ping_time="$(awk '{ ($9 > max) ? max = $9 : max = max }END {printf max}' ${tmp_ping_file})" + + average_ping_time="$(awk '{ total += $9; i+=1 }END {printf total/i}' ${tmp_ping_file})" + rm ${tmp_ping_file} + if [ -z $average_ping_time ] + then + echo "[Error]: bench: no successfull ping." + RETURN_CODE=1 + elif (( $(echo "$max_average_ping_time > $2" | bc -l) )) + then + echo "[Error]: bench: at least one burst have an average ping time to big." + RETURN_CODE=1 + elif (( $(echo "$average_ping_time > $1" | bc -l) )) + then + echo "[Error]: bench: average ping time to big." + RETURN_CODE=1 + else + echo "[Info]: bench: ping test ok." + fi +} + if [ "$BUTTERFLY_BUILD_ROOT" = "-h" ] || [ "$BUTTERFLY_BUILD_ROOT" = "--help" ] || [ "$BUTTERFLY_SRC_ROOT" = "-h" ] || [ "$BUTTERFLY_SRC_ROOT" = "--help" ] ; then usage