forked from Giszmo/Shufflepuff
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtcptest.sh
executable file
·67 lines (49 loc) · 1.21 KB
/
tcptest.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#!/bin/bash
# Argument must be given.
if [ -z "$1" ]
then
echo "No argument supplied"
exit 1
fi
N=$1
if [[ ! $N =~ ^[0-9]{1,2}$ ]]
then
echo "Integer argument >= 2 required"
exit 1
fi
# player index
player=1
# output file name
out="shuffle-output"
# error file name
err="shuffle-error"
# delete all output files that might have been leftover.
while [ $player -le $N ] ;
do
if [ -e $out$player.txt ]
then rm $out$player.txt
fi
if [ -e $err$player.txt ]
then rm $err$player.txt
fi
player=$((player+1))
done
if [ -e shuffler/build/distributions/shuffler ]
then rm -r shuffler/build/distributions/shuffler
fi
# run gradle task to create zip file.
bash gradlew distZip
# Extract contents of generated file.
unzip shuffler/build/distributions/shuffler.zip -d shuffler/build/distributions
# run the protocol.
echo "Running shuffle tcp test for $N players."
minPort=1808
player=1
while [ $player -le $N ] ;
do
echo "running player $player with port $((minPort + player))"
bash ./shuffler/build/distributions/shuffler/bin/shuffler -players $N -identity $player -amount 17 -minport $minPort -threads 4 > $out$player.txt 2> $err$player &
player=$((player+1))
done
wait
echo "Protocol complete."