Skip to content
Snippets Groups Projects
Commit c2bf5c03 authored by Jonas Höppner's avatar Jonas Höppner
Browse files

bluetooth: Allow to specify package cnt and delay for bt_test

GRNFS-27
parent 6d9a31bc
No related branches found
No related tags found
1 merge request!239bluetooth: Allow to specify package cnt and delay for bt_test
#!/bin/sh -x
#!/bin/sh
L2PINGD_LOG="/tmp/bt_test.log"
PING_COUNT="5"
PING_GOOD_COUNT="3"
DELAY="100"
# parse parameters
while [ $# -gt 0 ];
do
case "$1" in
'-v' )
set -x
;;
'-h' )
echo " trigger l2pingd to do X pings of which Y needs to be successful"
echo " -h: print help"
echo " -n: number of pings to send in total, default: $PING_COUNT"
echo " -g: numbers of pings that need to be successful to return success, default: $PING_GOOD_COUNT"
echo " -d: delay in ms between the pings, default: $DELAY"
echo " -v: More verbose messages"
exit 0
;;
'-n' )
PING_COUNT="$2"
shift
;;
'-g' )
PING_GOOD_COUNT="$2"
shift
;;
esac
shift
done
DELAY="$(( DELAY * 1000 ))"
echo "" > "$L2PINGD_LOG"
kill -USR2 $(pgrep l2pingd)
status="pass"
for i in 0 1 2 3 4; do
kill -USR1 $(pgrep l2pingd)
sleep 0.3
PID_L2PINGD="$(pgrep l2pingd)"
if [ -z "$PID_L2PINGD" ];then
echo "l2pings is not running"
echo "RESULT: fail"
exit 1
fi
# Reset the packet id to map the log
kill -USR2 $PID_L2PINGD
status="fail"
cnt=0
good=0
if ! grep -q "id $i time" "$L2PINGD_LOG"; then
status="fail"
while [ $cnt -lt $PING_COUNT ];
do
kill -USR1 $PID_L2PINGD
usleep $DELAY
if grep -q "id $cnt time" "$L2PINGD_LOG"; then
good=$(( good + 1 ))
fi
cnt=$(( cnt + 1 ))
done
if [ $good -ge $PING_GOOD_COUNT ];
then
status="pass"
fi
echo "Received $good out of $cnt pings"
echo "RESULT: $status"
if [ "$status" = "pass" ]; then
exit 0
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment