sendfile: added server implementation
[p2p-kernel-protocol.git] / sendfile / test.sh
diff --git a/sendfile/test.sh b/sendfile/test.sh
new file mode 100755 (executable)
index 0000000..3cba976
--- /dev/null
@@ -0,0 +1,40 @@
+#!/bin/bash
+
+MODULE_NAME=af_p2pkp
+MODULE_DIR=../module
+CLIENT=client/client
+SERVER=server/server
+FILE=/tmp/testfile1
+IP="127.0.0.1"
+WAIT_TIME=5
+
+LISTENERS_PORTS=(
+       60000
+)
+
+
+#use nc.traditional
+echo 2 | update-alternatives --config nc &> /dev/null
+
+[ -e $FILE ] || exit
+
+#increase tests debugging
+set -x
+
+# 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 $FILE $ARGUMENTS
+
+sleep $WAIT_TIME
+# kill netcat
+for pid in $pids; do
+       kill -9 $pid &> /dev/null
+done