Skip to content

Commit

Permalink
tests: add real test checking pings.
Browse files Browse the repository at this point in the history
  • Loading branch information
outscale-fne committed Feb 19, 2020
1 parent da5727f commit 7794494
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 1 deletion.
5 changes: 4 additions & 1 deletion tests/61_bench_nic_1BT/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

2 changes: 2 additions & 0 deletions tests/62_bench_nic_2BT/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,6 @@ network_disconnect 0 1
server_stop 0
server_stop 1

check_ping 32000 45000

return_result
25 changes: 25 additions & 0 deletions tests/functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 7794494

Please sign in to comment.