X-Git-Url: http://p2p-next.cs.pub.ro/gitweb/?a=blobdiff_plain;f=test%2Ftest.sh;fp=test%2Ftest.sh;h=d36d0fef333d2fe4bf629472edaa6c4c9152e1ee;hb=bea87028d855a62771324f4458696165c566b997;hp=0000000000000000000000000000000000000000;hpb=4f43366e09852a0d49c2983897290814ce43a80f;p=p2p-kernel-protocol.git diff --git a/test/test.sh b/test/test.sh new file mode 100755 index 0000000..d36d0fe --- /dev/null +++ b/test/test.sh @@ -0,0 +1,43 @@ +#!/bin/bash + +MODULE_NAME=af_p2pkp +MODULE_DIR=../module +CLIENT=client/client +SERVER=server/server +IP="127.0.0.1" + +LISTENERS_PORTS=( + 60000 + 60001 +) + + +#use nc.traditional +echo 2 | update-alternatives --config nc &> /dev/null + +#increase tests debugging +set -x + +# insert module, causing the message to be sent +insmod $MODULE_DIR/$MODULE_NAME.ko + +# listen for UDP packets on localhost, port 60000 (run in background) +for port in "${LISTENERS_PORTS[@]}"; do + $SERVER $IP $port testfile.$port & + pids="$pids $!" + ARGUMENTS="$IP $port $ARGUMENTS" +done + +# wait for netcat to start listening +sleep 1 + +$CLIENT $ARGUMENTS + +# kill netcat +for pid in $pids; do + wait $pid &> /dev/null +done + +# remove module +rmmod $MODULE_NAME +