projects
/
p2p-kernel-protocol.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
doc: final revise of the document
[p2p-kernel-protocol.git]
/
sendfile
/
test.sh
diff --git
a/sendfile/test.sh
b/sendfile/test.sh
index
3cba976
..
cb06891
100755
(executable)
--- a/
sendfile/test.sh
+++ b/
sendfile/test.sh
@@
-4,34
+4,49
@@
MODULE_NAME=af_p2pkp
MODULE_DIR=../module
CLIENT=client/client
SERVER=server/server
MODULE_DIR=../module
CLIENT=client/client
SERVER=server/server
-FILE=/tmp/testfile1
+FILE=/tmp/testfile32
+OUTPUT_DIR=/tmp
IP="127.0.0.1"
IP="127.0.0.1"
-WAIT_TIME=
5
+WAIT_TIME=
3
LISTENERS_PORTS=(
LISTENERS_PORTS=(
- 60000
+ 50000
+ 50001
+ 50002
+ 50003
+ 50004
+ 50005
+ 50006
+ 50007
)
)
-
#use nc.traditional
echo 2 | update-alternatives --config nc &> /dev/null
#use nc.traditional
echo 2 | update-alternatives --config nc &> /dev/null
-[ -
e $FILE ] || exit
+[ -
d $OUTPUT_DIR ] || mkdir -p $OUTPUT_DIR
#increase tests debugging
#increase tests debugging
-set -x
+
#
set -x
-# listen for UDP packets on localhost, port
6
0000 (run in background)
+# listen for UDP packets on localhost, port
5
0000 (run in background)
for port in "${LISTENERS_PORTS[@]}"; do
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
pids="$pids $!"
ARGUMENTS="$IP $port $ARGUMENTS"
done
# wait for netcat to start listening
-sleep
1
+sleep
$WAIT_TIME
-$CLIENT $FILE $ARGUMENTS
+if [ $# -eq 0 ]; then
+ [ -e $FILE ] || exit
+ $CLIENT $FILE $ARGUMENTS
+else
+ for file in $@; do
+ [ -e $file ] || continue
+ $CLIENT $file $ARGUMENTS
+ done
+fi
sleep $WAIT_TIME
# kill netcat
sleep $WAIT_TIME
# kill netcat