[asterisk-scf-commits] asterisk-scf/release/pjproject.git branch "veesix" updated.
Commits to the Asterisk SCF project code repositories
asterisk-scf-commits at lists.digium.com
Wed Dec 29 17:50:42 UTC 2010
branch "veesix" has been updated
via 191569a04e0110776711ae56bafeb07d32ccc893 (commit)
from a505e6e6056509f62a1a91c6834811115035a759 (commit)
Summary of changes:
pjsip/build/Makefile | 2 +-
pjsip/src/test/test.c | 1 +
pjsip/src/test/test.h | 1 +
...ransport_udp_test.c => transport_udp_test_v6.c} | 16 ++++++++--------
4 files changed, 11 insertions(+), 9 deletions(-)
copy pjsip/src/test/{transport_udp_test.c => transport_udp_test_v6.c} (88%)
- Log -----------------------------------------------------------------
commit 191569a04e0110776711ae56bafeb07d32ccc893
Author: Mark Michelson <mmichelson at digium.com>
Date: Wed Dec 29 11:56:55 2010 -0600
Create separate IPv4 and IPv6 tests for UDP transport.
diff --git a/pjsip/build/Makefile b/pjsip/build/Makefile
index 231ec54..1922a09 100644
--- a/pjsip/build/Makefile
+++ b/pjsip/build/Makefile
@@ -88,7 +88,7 @@ export TEST_SRCDIR = ../src/test
export TEST_OBJS += dlg_core_test.o dns_test.o msg_err_test.o \
msg_logger.o msg_test.o multipart_test.o regc_test.o \
test.o transport_loop_test.o transport_tcp_test.o transport_tcp_test_v6.o \
- transport_test.o transport_udp_test.o \
+ transport_test.o transport_udp_test.o transport_udp_test_v6.o\
tsx_basic_test.o tsx_bench.o tsx_uac_test.o \
tsx_uas_test.o txdata_test.o uri_test.o \
inv_offer_answer_test.o
diff --git a/pjsip/src/test/test.c b/pjsip/src/test/test.c
index 40bb8f1..a32c1b2 100644
--- a/pjsip/src/test/test.c
+++ b/pjsip/src/test/test.c
@@ -315,6 +315,7 @@ int test_main(void)
#if INCLUDE_UDP_TEST
DO_TEST(transport_udp_test());
+ DO_TEST(transport_udp_test_v6());
#endif
#if INCLUDE_LOOP_TEST
diff --git a/pjsip/src/test/test.h b/pjsip/src/test/test.h
index c1b02fa..894db99 100644
--- a/pjsip/src/test/test.h
+++ b/pjsip/src/test/test.h
@@ -76,6 +76,7 @@ int multipart_test(void);
int txdata_test(void);
int tsx_bench(void);
int transport_udp_test(void);
+int transport_udp_test_v6(void);
int transport_loop_test(void);
int transport_tcp_test(void);
int transport_tcp_test_v6(void);
diff --git a/pjsip/src/test/transport_udp_test_v6.c b/pjsip/src/test/transport_udp_test_v6.c
new file mode 100644
index 0000000..6483599
--- /dev/null
+++ b/pjsip/src/test/transport_udp_test_v6.c
@@ -0,0 +1,128 @@
+/* $Id: transport_udp_test.c 2638 2009-04-22 14:27:55Z nanang $ */
+/*
+ * Copyright (C) 2008-2009 Teluu Inc. (http://www.teluu.com)
+ * Copyright (C) 2003-2008 Benny Prijono <benny at prijono.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include "test.h"
+#include <pjsip.h>
+#include <pjlib.h>
+
+#define THIS_FILE "transport_udp_test.c"
+
+
+/*
+ * UDP transport test.
+ */
+int transport_udp_test_v6(void)
+{
+ enum { SEND_RECV_LOOP = 8 };
+ pjsip_transport *udp_tp, *tp;
+ pj_sockaddr_in6 addr, rem_addr;
+ pj_str_t s;
+ pj_status_t status;
+ int rtt[SEND_RECV_LOOP], min_rtt;
+ int i, pkt_lost;
+
+ pj_sockaddr_init(pj_AF_INET6(), (pj_sockaddr *)&addr, NULL, TEST_UDP_PORT);
+
+ /* Start UDP transport. */
+ status = pjsip_udp_transport_start6( endpt, &addr, NULL, 1, &udp_tp);
+ if (status != PJ_SUCCESS) {
+ app_perror(" Error: unable to start UDP transport", status);
+ return -10;
+ }
+
+ /* UDP transport must have initial reference counter set to 1. */
+ if (pj_atomic_get(udp_tp->ref_cnt) != 1)
+ return -20;
+
+ /* Test basic transport attributes */
+ status = generic_transport_test(udp_tp);
+ if (status != PJ_SUCCESS)
+ return status;
+
+ /* Test that transport manager is returning the correct
+ * transport.
+ */
+ pj_sockaddr_init(pj_AF_INET6(), (pj_sockaddr *)&rem_addr, pj_cstr(&s, "::1"), 80);
+ status = pjsip_endpt_acquire_transport(endpt, PJSIP_TRANSPORT_UDP6,
+ &rem_addr, sizeof(rem_addr),
+ NULL, &tp);
+ if (status != PJ_SUCCESS)
+ return -50;
+ if (tp != udp_tp)
+ return -60;
+
+ /* pjsip_endpt_acquire_transport() adds reference, so we need
+ * to decrement it.
+ */
+ pjsip_transport_dec_ref(tp);
+
+ /* Check again that reference counter is 1. */
+ if (pj_atomic_get(udp_tp->ref_cnt) != 1)
+ return -70;
+
+ /* Basic transport's send/receive loopback test. */
+ pj_sockaddr_init(pj_AF_INET6(), (pj_sockaddr *)&rem_addr, pj_cstr(&s, "::1"), TEST_UDP_PORT);
+ for (i=0; i<SEND_RECV_LOOP; ++i) {
+ status = transport_send_recv_test(PJSIP_TRANSPORT_UDP, tp,
+ "sip:alice@[::1]:"TEST_UDP_PORT_STR,
+ &rtt[i]);
+ if (status != 0)
+ return status;
+ }
+
+ min_rtt = 0xFFFFFFF;
+ for (i=0; i<SEND_RECV_LOOP; ++i)
+ if (rtt[i] < min_rtt) min_rtt = rtt[i];
+
+ report_ival("udp-rtt-usec", min_rtt, "usec",
+ "Best UDP transport round trip time, in microseconds "
+ "(time from sending request until response is received. "
+ "Tests were performed on local machine only)");
+
+
+ /* Multi-threaded round-trip test. */
+ status = transport_rt_test(PJSIP_TRANSPORT_UDP, tp,
+ "sip:alice at 127.0.0.1:"TEST_UDP_PORT_STR,
+ &pkt_lost);
+ if (status != 0)
+ return status;
+
+ if (pkt_lost != 0)
+ PJ_LOG(3,(THIS_FILE, " note: %d packet(s) was lost", pkt_lost));
+
+ /* Check again that reference counter is 1. */
+ if (pj_atomic_get(udp_tp->ref_cnt) != 1)
+ return -80;
+
+ /* Destroy this transport. */
+ pjsip_transport_dec_ref(udp_tp);
+
+ /* Force destroy this transport. */
+ status = pjsip_transport_destroy(udp_tp);
+ if (status != PJ_SUCCESS)
+ return -90;
+
+ /* Flush events. */
+ PJ_LOG(3,(THIS_FILE, " Flushing events, 1 second..."));
+ flush_events(1000);
+
+ /* Done */
+ return 0;
+}
-----------------------------------------------------------------------
--
asterisk-scf/release/pjproject.git
More information about the asterisk-scf-commits
mailing list