add .gitignore
[swift-upb.git] / tests / pex_test.sh
1 #!/bin/bash
2
3 EXEC=build/Debug/
4 PEERCOUNT=2
5 STORE=_pextest 
6 TOKILL=
7 rm -rf $STORE
8 mkdir $STORE
9
10 #$EXEC/seeder doc/sofi.jpg 7001
11
12 for i in `seq 1 $PEERCOUNT`; do
13     ( $EXEC/leecher 282a863d5567695161721686a59f0c667250a35d \
14         $STORE/sofi$i.jpg 7001 710$i > $STORE/leecher$i.log ) &
15     TOKILL="$TOKILL $!"
16     sleep 4;
17 done
18
19 sleep 10
20
21 for p in $TOKILL; do
22     kill -9 $p
23 done
24
25 for i in `seq 1 $PEERCOUNT`; do
26     cat $STORE/leecher$i.log | grep sent | awk '{print $5}' | \
27         sort | uniq -c > $STORE/peers$i.txt
28     peers=`wc -l < $STORE/peers$i.txt`
29     if [ $peers -ne $PEERCOUNT ]; then
30         echo Peer $i has $peers peers
31     fi
32 done