Statistics
| Branch: | Revision:

grapes / src / Tests / test.sh @ f7074f9e

History | View | Annotate | Download (1.84 KB)

1
#!/bin/bash
2
#launch it e.g. like this:
3
#./test.sh -e "offerstreamer-ml" -n 5 -s "-m 1" -p "-b 40 -o 5 -c 25" -f "chbuf"
4
#./test.sh -e "offerstreamer-ml" -f chbuf
5

    
6
# Kill everything we've stared on exit (with trap).
7
trap "ps -o pid= --ppid $$ | xargs kill -9 2>/dev/null" 0
8

    
9
#defaults
10
SOURCE_PORT=6666
11
PEER_PORT_BASE=5555
12
NUM_PEERS=1
13
FILTER="neigh"
14
CLIENT="./topology_test"
15

    
16
#process options
17
while getopts "s:S:p:P:N:f:e:v:VX:" opt; do
18
  case $opt in
19
    s)
20
      SOURCE_OPTIONS=$OPTARG
21
      ;;
22
    S)
23
      SOURCE_PORT=$OPTARG
24
      ;;
25
    p)
26
      PEER_OPTIONS=$OPTARG
27
      ;;
28
    P)
29
      PEER_PORT_BASE=$OPTARG
30
      ;;
31
    N)
32
      NUM_PEERS=$OPTARG
33
      ;;
34
    f)	#TODO
35
      FILTER=$OPTARG
36
      ;;
37
    e)
38
      CLIENT=$OPTARG
39
      ;;
40
    v)
41
      VIDEO=$OPTARG
42
      ;;
43
    V)	#TODO
44
      VALGRIND="valgrind --error-exitcode=1 --track-origins=yes  --leak-check=full "
45
      VALGRIND="valgrind --error-exitcode=1 --leak-check=full "
46
      ;;
47
    X)
48
      NUM_PEERS_X=$OPTARG
49
      ;;
50
    \?)
51
      echo "Invalid option: -$OPTARG" >&2
52
      exit 1
53
      ;;
54
    :)
55
      echo "Option -$OPTARG requires an argument." >&2
56
      exit 1
57
      ;;
58
  esac
59
done
60

    
61
$VALGRIND $CLIENT $SOURCE_OPTIONS 2> /dev/null &
62

    
63
sleep 2
64
((PEER_PORT_MAX=PEER_PORT_BASE + NUM_PEERS - 1))
65
for PORT in `seq $PEER_PORT_BASE 1 $PEER_PORT_MAX`; do
66
    $VALGRIND $CLIENT $PEER_OPTIONS -P $PORT -i 127.0.0.1 -p $SOURCE_PORT 2>stderr.$PORT > stdout.$PORT &
67
done
68

    
69
((PEER_PORT_BASE = PEER_PORT_MAX + 1))
70
((PEER_PORT_MAX=PEER_PORT_BASE + NUM_PEERS_X - 1))
71
for PORT in `seq $PEER_PORT_BASE 1 $PEER_PORT_MAX`; do
72
#  valgrind --track-origins=yes  --leak-check=full \ TODO!!!
73
    FIFO=fifo.$PORT
74
    rm -f $FIFO
75
    mkfifo $FIFO
76
    xterm -e "$CLIENT $PEER_OPTIONS -P $PORT -i 127.0.0.1 -p $SOURCE_PORT >$FIFO 2>/dev/null | grep '$FILTER' $FIFO" &
77
done
78

    
79
#valgrind --track-origins=yes  --leak-check=full TODO!
80

    
81
wait