-
Notifications
You must be signed in to change notification settings - Fork 16
/
functions
executable file
·185 lines (161 loc) · 3.81 KB
/
functions
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
#!/bin/sh
OS=`uname`
if [ "${OS}" = "FreeBSD" ]
then
CC=${CC:-"cc"}
MAKE_CMD=gmake
else
CC=${CC:-"gcc"}
MAKE_CMD=make
fi
MYUID=`id -u`
if [ ! ${MYUID} -eq 0 ]
then
SUDO="sudo"
else
SUDO=""
fi
PP_CMD="gpp -C -x"
PYTHON_CMD="`which ${PYTHON_CMD:-"python"}`"
MM_TYPE="${MM_TYPE:-b2bua}"
MM_BRANCH="${MM_BRANCH:-master}"
MM_REV="${MM_REV:-${MM_BRANCH}}"
MM_AUTH="${MM_AUTH:-"simple"}"
MM_VER_FULL=`echo ${MM_BRANCH} | sed 's|[.]||g'`
MM_VER=`echo ${MM_BRANCH} | sed 's|[.]|| ; s|[.].*|| ; s/^\(.\{2\}\).*$/\1/'`
RTPPC_TYPE="${RTPPC_TYPE:-udp}"
BASEDIR="${BASEDIR:-$(dirname -- $0)}"
BASEDIR="$(readlink -f -- $BASEDIR)"
BUILDDIR="${BUILDDIR:-${BASEDIR}}"
RTPPROXY_DIST="${RTPPROXY_DIST:-"${BUILDDIR}/dist/rtpproxy"}"
LOCALBASE="/usr/local"
RTPPROXY="${LOCALBASE}/bin/rtpproxy_debug --dso ${LOCALBASE}/lib/rtpproxy/rtpp_acct_csv_debug.so"
RTPP_SOCK_BARE="${BASEDIR}/rtpproxy.sock"
RTPP_SOCK_UDP="udp:127.0.0.1:22222"
RTPP_SOCK_UNIX="unix:${RTPP_SOCK_BARE}"
RTPP_SOCK_CUNIX="cunix:${BASEDIR}/rtpproxy.csock"
RTPP_SOCK_UDP6="udp6:::1:22222"
RTPP_SOCK_TCP="tcp:127.0.0.1:22222"
RTPP_SOCK_TCP6="tcp6:::1:22222"
fail_rc() {
RC=${1}
shift
echo >&2 "FAILED: (rc=$RC)" "$@"
if [ -n "$CONTINUE" ] ; then
return
fi
if [ -n "$INTERACTIVE" ] ; then
read -p "Continue? (y/n)" YN
if [ "$YN" != 'y' ] ; then
exit $RC
fi
else
exit $RC
fi
}
case "${RTPPC_TYPE}" in
"udp") RTPP_SOCK_TEST="${RTPP_SOCK_UDP}";;
"udp6") RTPP_SOCK_TEST="${RTPP_SOCK_UDP6}";;
"unix") RTPP_SOCK_TEST="${RTPP_SOCK_UNIX}";;
"cunix") RTPP_SOCK_TEST="${RTPP_SOCK_CUNIX}";;
"tcp") RTPP_SOCK_TEST="${RTPP_SOCK_TCP}";;
"tcp6") RTPP_SOCK_TEST="${RTPP_SOCK_TCP6}";;
"rtp.io") RTPP_SOCK_TEST="${RTPP_SOCK_TCP}";;
*) fail_rc 1 "Unknown socket type RTPPC_TYPE=${RTPPC_TYPE}";;
esac
MM_INIT_DELAY=1
RTPP_STAT_TIMEOUT=$((36 + ${MM_INIT_DELAY}))
ALICE_TIMEOUT=45
BOB_TIMEOUT=45
TEST_SET="1,2,3,4,5,6,7,8,9,10,early_cancel"
TEST_SET="${TEST_SET},reinvite,reinv_fail,reinv_onhold,reinv_frombob"
if [ "${MM_TYPE}" = "b2bua" -o "${MM_TYPE}" = "go-b2bua" ]
then
MM_SOCK="unix:${BASEDIR}/b2bua.sock"
# Python b2bua needs slightly more time to init everything
MM_INIT_DELAY=5
# RTP sessions might take up to 60 seconds to disconnect on no media
RTPP_STAT_TIMEOUT=$((70 + ${MM_INIT_DELAY}))
RTPP_PRE_STAT_TIMEOUT=$((55 + ${MM_INIT_DELAY}))
ALICE_TIMEOUT=90
BOB_TIMEOUT=90
TEST_SET="${TEST_SET},11,12,13,14,reinv_brkn1,reinv_brkn2,reinv_bad_ack"
fi
MM_ROOT="${MM_ROOT:-"${BUILDDIR}/dist/${MM_TYPE}"}"
if [ "${MM_TYPE}" = "b2bua" ]
then
TEST_SET="${TEST_SET},inv_brkn1"
fi
#if [ "${MM_TYPE}" != "opensips" -o "${MM_BRANCH}" = "1.11" ]
#then
TEST_SET="${TEST_SET},early_cancel_lost100"
#fi
#if [ "${MM_TYPE}" = "kamailio" ]
#then
# TEST_SET="${TEST_SET}"
#fi
if [ "${MM_TYPE}" = "opensips" -a \( "${MM_BRANCH}" = "2.3" \
-o "${MM_BRANCH}" = "master" \) ]
then
# TEST_SET=`echo ${TEST_SET} | sed 's|,early_cancel_lost100|| ; s|,early_cancel||'`
MM_ARGS="-d"
fi
forcefail() {
RC=${1}
if [ ${RC} -eq 0 ]
then
echo >&2 "ALERT, forcefail() called with the bogus 0 RC!"
${RC}=1
fi
shift
fail_rc "${RC}" "${@}"
}
fail() {
RC=$?
fail_rc "${RC}" "${@}"
}
ok() {
echo >&2 "OK:" "$@"
}
report_rc_log() {
RC=${1}
FAIL_LOGFILES="${2}"
shift 2
if [ ${RC} -eq 0 ]
then
ok "${@}"
else
if [ x"${VT_NO_LOG_DUMP}" = x"" ]
then
for logf in ${FAIL_LOGFILES}
do
cat -n "${logf}" | grep -a -v 'DBUG:main:GLOBAL:' | grep -a -v 'DBUG:rtpp_proc_async_run:GLOBAL:' >&2
done
fi
fail_rc "${RC}" "${@}"
fi
}
report_rc() {
RC=${1}
shift
if [ ${RC} -eq 0 ]
then
ok "${@}"
else
fail_rc "${RC}" "${@}"
fi
}
report() {
RC=${?}
report_rc ${RC} "${@}"
}
reportifnotfail() {
RC=$?
if [ "$RC" = 0 ]
then
fail_rc 1 "$@"
else
true
ok "$@"
fi
}