From e970ec227103d6bbd267239af7471d28579590c7 Mon Sep 17 00:00:00 2001 From: Francois NOUAILLE Date: Wed, 19 Feb 2020 09:00:33 +0000 Subject: [PATCH] tests: add real test checking pings. --- scripts/tests_all.sh | 2 +- tests/61_bench_nic_1BT/test.sh | 5 ++++- tests/62_bench_nic_2BT/test.sh | 2 ++ tests/functions.sh | 23 ++++++++++++++++++++++- 4 files changed, 29 insertions(+), 3 deletions(-) diff --git a/scripts/tests_all.sh b/scripts/tests_all.sh index e4459de45..c822d4101 100755 --- a/scripts/tests_all.sh +++ b/scripts/tests_all.sh @@ -37,7 +37,7 @@ fi sleep 1 # Crypto test -$BUTTERFLY_ROOT/scripts/tests_crypto.sh $BUTTERFLY_BUILD_ROOT/build +$BUTTERFLY_ROOT/scripts/tests_crypto.sh $BUTTERFLY_BUILD_ROOT if [ $? != 0 ]; then tput setaf 1 echo "crypto test failed" diff --git a/tests/61_bench_nic_1BT/test.sh b/tests/61_bench_nic_1BT/test.sh index 874cb9103..db8829939 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_bench_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..93d381267 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_bench_ping 32000 45000 + return_result diff --git a/tests/functions.sh b/tests/functions.sh index 3ef990b4e..3b4897897 100755 --- a/tests/functions.sh +++ b/tests/functions.sh @@ -21,7 +21,7 @@ RETURN_CODE=0 function return_result { clean_all if [ $RETURN_CODE == 0 ]; then - echo $CUR_TEST 'SUCESS !!!' + echo $CUR_TEST 'SUCCESS !!!' else echo $CUR_TEST 'FAIL !!!' fi @@ -1502,6 +1502,27 @@ function fail { exit 1 } +#Use: check_bench_ping [maximum average delay all bursts] [maximum average delay one burst] +function check_bench_ping { + tmp_ping_file="/tmp/butterfly_bench_ping" + sed -n -e '/^ping/p' $BUTTERFLY_BUILD_ROOT/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