/[resiprocate]/main/resip/stack/test/insert-packet.sh
ViewVC logotype

Contents of /main/resip/stack/test/insert-packet.sh

Parent Directory Parent Directory | Revision Log Revision Log


Revision 7268 - (show annotations) (download)
Wed Sep 26 18:55:20 2007 UTC (12 years, 1 month ago) by bcampen
File MIME type: text/plain
File size: 1094 byte(s)
Replacing ParseBuffer::Exception with ParseException. Required moving
ParseException.hxx to rutil, and creating a ParseException.cxx there
too. Left a typedef in ParseBuffer.hxx that makes ParseBuffer::Exception
an alias for ParseException (for backwards compatibility with app code)

1 #!/bin/sh
2 #
3 # Insert a test packet into a unit test.
4 # ./insert-packet.sh <plaintext packet file> <C++ source>
5 #
6 # searches for the initNetwork() line and inserts just below that
7 #
8
9 function die() {
10 echo "$1" >&2;
11 exit 1;
12 }
13
14 test ! -z "$1" -a ! -z "$2" || die "usage: $0 input output";
15
16 quoted=`sed -e 's/\"/\\\"/g' \
17 -e 's/^/ \"/' \
18 -e $'s/\r$//g' -e 's/$/\\\\r\\\\n\"/g' <$1`;
19
20 # Figure out where we want to insert this.
21 line=`egrep -n 'initNetwork\(\)\;$' <$2 | sed -e 's/:/ /' | awk '{print $1}'`;
22
23 total=`wc -l $2 | awk '{print $1}'`;
24
25 head -n ${line} $2 >.tmp;
26
27 cat >>.tmp <<EOF
28
29 {
30 Data txt(
31 ${quoted}
32 );
33
34 std::auto_ptr<SipMessage> message(TestSupport::makeMessage(txt));
35
36 try
37 {
38 (void)message->header(h_From);
39 }
40 catch (ParseException&)
41 {
42 std::cerr << "uh, failed to parse message: "
43 << __FILE__ << ':' << __LINE__
44 << std::endl;
45 assert(false);
46 }
47 }
48 EOF
49
50 tail -n `expr ${total} - ${line}` $2 >>.tmp;
51
52 mv .tmp $2;
53
54 echo "inserted at line `expr ${line} + 1`";

Properties

Name Value
svn:eol-style native
svn:executable *
svn:mime-type text/plain

webmaster AT resiprocate DOT org
ViewVC Help
Powered by ViewVC 1.1.27