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 24, 2020
1 parent ad7656b commit e970ec2
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 3 deletions.
2 changes: 1 addition & 1 deletion scripts/tests_all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
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_bench_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_bench_ping 32000 45000

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

0 comments on commit e970ec2

Please sign in to comment.