~ubuntu-branches/debian/experimental/ion/experimental

« back to all changes in this revision

Viewing changes to tests/issue-132-udplso-tx-rate-limit/dotest

  • Committer: Package Import Robot
  • Author(s): Leo Iannacone
  • Date: 2012-02-01 09:46:31 UTC
  • Revision ID: package-import@ubuntu.com-20120201094631-qpfwehc1b7ftkjgx
Tags: upstream-2.5.3~dfsg1
ImportĀ upstreamĀ versionĀ 2.5.3~dfsg1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/bin/bash
 
2
#
 
3
# 132-udplso-tx-rate-limit.sh
 
4
# Greg Menke
 
5
# July 6, 2010
 
6
# copied from 1000.loopback test
 
7
 
 
8
# script used in "make test" to ensure ion is functioning properly.
 
9
# script is expected to be run by automake, meaning:
 
10
# 1: Environment variable "srcdir" exists and points to the root directory of
 
11
# the ion source code.
 
12
# 2: The current working directory contains the built programs of ion.
 
13
CONFIGFILES=" \
 
14
./config/ionconfig.nodeconf \
 
15
./config/132-udplso-tx-rate-limit.bprc \
 
16
./config/132-udplso-tx-rate-limit.ipnrc \
 
17
./config/132-udplso-tx-rate-limit.ionsecrc \
 
18
./config/132-udplso-tx-rate-limit.ionrc \
 
19
./config/132-udplso-tx-rate-limit.ltprc \
 
20
"
 
21
echo "########################################"
 
22
echo
 
23
pwd | sed "s/\/.*\///" | xargs echo "NAME: "
 
24
echo
 
25
echo "PURPOSE: Testing the functionality of issue 132: a transmission rate
 
26
        limit on udp link service adapter to ltp.  Beyond the configuration
 
27
        options, this is a simple loopback test."
 
28
echo
 
29
echo "CONFIG: Custom loopback: "
 
30
echo
 
31
for N in $CONFIGFILES
 
32
do
 
33
        echo "$N:"
 
34
        cat $N
 
35
        echo "# EOF"
 
36
        echo
 
37
done
 
38
echo "OUTPUT: Terminal messages will relay results."
 
39
echo
 
40
echo "########################################"
 
41
 
 
42
# file sent over ion
 
43
IONSENDFILE=./ionsendfile.dat
 
44
IONRECEIVEFILE=./testfile1
 
45
 
 
46
 
 
47
echo "Starting ION..."
 
48
CONFIGDIR="./config"
 
49
ionstart                           \
 
50
    -i ${CONFIGDIR}/132-udplso-tx-rate-limit.ionrc \
 
51
    -l ${CONFIGDIR}/132-udplso-tx-rate-limit.ltprc \
 
52
    -b ${CONFIGDIR}/132-udplso-tx-rate-limit.bprc  \
 
53
    -s ${CONFIGDIR}/132-udplso-tx-rate-limit.ionsecrc \
 
54
    -p ${CONFIGDIR}/132-udplso-tx-rate-limit.ipnrc
 
55
 
 
56
 
 
57
# receive the message and store it in a file via test bundle sink
 
58
echo "Starting File receiver..."
 
59
bprecvfile ipn:1.2 &
 
60
BPRECVFILEPID=$!
 
61
 
 
62
# give app some time to start up
 
63
sleep 5
 
64
#
 
65
# create a 1 megabyte file of random data
 
66
#
 
67
echo "Creating 1 megabyte test file..."
 
68
dd if=/dev/urandom of=$IONSENDFILE bs=1024 count=1024
 
69
# send the file to the receiver
 
70
echo "Sending file (includes 45 sec pause for the limited tx)..."
 
71
bpsendfile ipn:1.1 ipn:1.2 $IONSENDFILE &
 
72
BPSENDFILEPID=$!
 
73
 
 
74
# wait long enough for file to transfer
 
75
sleep 45
 
76
 
 
77
# kill everything in case it didn't finish properly
 
78
echo "Stopping bpsendfile & bprecvfile..."
 
79
kill -2 $BPRECVFILEPID $BPSENDFILEPID >/dev/null 2>&1
 
80
sleep 1
 
81
kill -15 $BPRECVFILEPID $BPSENDFILEPID >/dev/null 2>&1
 
82
sleep 1
 
83
kill -9 $BPRECVFILEPID $BPSENDFILEPID >/dev/null 2>&1
 
84
 
 
85
# shut down ion processes
 
86
echo "Stopping ion..."
 
87
ionstop
 
88
 
 
89
echo "Checking files..."
 
90
 
 
91
# compare the sent message to the received one
 
92
 
 
93
if ! `cmp -s $IONSENDFILE $IONRECEIVEFILE`; then
 
94
 
 
95
    echo "Oh noes, data corruption!"
 
96
    echo
 
97
    echo "Send file $IONSENDFILE differs from $IONRECEIVEFILE or $IONRECEIVEFILE was not created"
 
98
    echo
 
99
    RETVAL=1
 
100
 
 
101
else
 
102
    #sendfilets=`stat --format='%Z' $IONSENDFILE`
 
103
    #recvfilets=`stat --format='%Z' $IONRECEIVEFILE`
 
104
 
 
105
    sendfilets=`perl -le 'print scalar  ((lstat shift)[9])' $IONSENDFILE`
 
106
    recvfilets=`perl -le 'print scalar  ((lstat shift)[9])' $IONRECEIVEFILE`
 
107
 
 
108
    tsdiff=$((recvfilets - sendfilets))
 
109
 
 
110
    if [ $tsdiff -ge 10 ]; then
 
111
    
 
112
        echo "bundle transfer successful!"
 
113
        RETVAL=0
 
114
    else
 
115
 
 
116
        echo "Oh noes, data OK but recv file timestamp not 10secs older than send file!"
 
117
        RETVAL=2
 
118
    fi
 
119
 
 
120
fi
 
121
 
 
122
 
 
123
# clean up
 
124
#rm -f $IONSENDFILE $IONRECEIVEFILE
 
125
 
 
126
 
 
127
exit $RETVAL
 
128