X-Git-Url: http://p2p-next.cs.pub.ro/gitweb/?a=blobdiff_plain;f=test%2Ftest.sh;h=f924cb27d4e08c0f2292d987106a68d75e851154;hb=9a8004aad7630028ccafa207626a0100b06f2736;hp=5808baf0d03102af117c0b646283c6a3b83c6693;hpb=89f719363f1abe0becd2e98e596f823e412c344d;p=p2p-kernel-protocol.git diff --git a/test/test.sh b/test/test.sh index 5808baf..f924cb2 100755 --- a/test/test.sh +++ b/test/test.sh @@ -4,37 +4,53 @@ MODULE_NAME=af_p2pkp MODULE_DIR=../module CLIENT=client/client SERVER=server/server -FILE=/root/Dropbox/school/p2pkp/test/client/test_file +FILE=/tmp/testfile32 +OUTPUT_DIR=/tmp IP="127.0.0.1" -WAIT_TIME=2 +WAIT_TIME=3 LISTENERS_PORTS=( 60000 + 60001 + 60002 + 60003 + 60004 + 60005 ) #use nc.traditional echo 2 | update-alternatives --config nc &> /dev/null -[ -e $FILE ] || exit +[ -d $OUTPUT_DIR ] || mkdir -p $OUTPUT_DIR #increase tests debugging -set -x +#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 & + $SERVER $IP $port $OUTPUT_DIR/testfile.$port & pids="$pids $!" ARGUMENTS="$IP $port $ARGUMENTS" done # wait for netcat to start listening -sleep 1 +sleep $WAIT_TIME + + +if [ $# -eq 0 ]; then + [ -e $FILE ] || exit + $CLIENT $FILE $ARGUMENTS +else + for file in $@; do + [ -e $file ] || continue + $CLIENT $file $ARGUMENTS + done +fi -$CLIENT $FILE $ARGUMENTS sleep $WAIT_TIME # kill netcat