From 7638eeee106fe58a1225f642e733629f29418818 Mon Sep 17 00:00:00 2001 From: Benny Prijono Date: Fri, 20 Jan 2006 21:03:36 +0000 Subject: Completed testing for WinCE port git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@126 74dad513-b988-da41-8d7b-12977e46ad98 --- pjlib/src/pjlib-test/ioq_udp.c | 74 ++++++++++++++++++++++-------------------- 1 file changed, 38 insertions(+), 36 deletions(-) (limited to 'pjlib/src/pjlib-test/ioq_udp.c') diff --git a/pjlib/src/pjlib-test/ioq_udp.c b/pjlib/src/pjlib-test/ioq_udp.c index 7db2a8eb..5f933afa 100644 --- a/pjlib/src/pjlib-test/ioq_udp.c +++ b/pjlib/src/pjlib-test/ioq_udp.c @@ -118,7 +118,7 @@ static pj_ioqueue_callback test_cb = static int compliance_test(void) { pj_sock_t ssock=-1, csock=-1; - pj_sockaddr_in addr; + pj_sockaddr_in addr, dst_addr; int addrlen; pj_pool_t *pool = NULL; char *send_buf, *recv_buf; @@ -154,7 +154,7 @@ static int compliance_test(void) // Bind server socket. TRACE_("bind socket..."); - memset(&addr, 0, sizeof(addr)); + pj_memset(&addr, 0, sizeof(addr)); addr.sin_family = PJ_AF_INET; addr.sin_port = pj_htons(PORT); if (pj_sock_bind(ssock, &addr, sizeof(addr))) { @@ -186,19 +186,12 @@ static int compliance_test(void) status=-26; goto on_error; } - // Set destination address to send the packet. - TRACE_("set destination address..."); - temp = pj_str("127.0.0.1"); - if ((rc=pj_sockaddr_in_init(&addr, &temp, PORT)) != 0) { - app_perror("...error: unable to resolve 127.0.0.1", rc); - status=-26; goto on_error; - } - // Randomize send_buf. pj_create_random_string(send_buf, bufsize); // Register reading from ioqueue. TRACE_("start recvfrom..."); + pj_memset(&addr, 0, sizeof(addr)); addrlen = sizeof(addr); bytes = bufsize; rc = pj_ioqueue_recvfrom(skey, &read_op, recv_buf, &bytes, 0, @@ -216,11 +209,19 @@ static int compliance_test(void) status=-29; goto on_error; } + // Set destination address to send the packet. + TRACE_("set destination address..."); + temp = pj_str("127.0.0.1"); + if ((rc=pj_sockaddr_in_init(&dst_addr, &temp, PORT)) != 0) { + app_perror("...error: unable to resolve 127.0.0.1", rc); + status=-290; goto on_error; + } + // Write must return the number of bytes. TRACE_("start sendto..."); bytes = bufsize; - rc = pj_ioqueue_sendto(ckey, &write_op, send_buf, &bytes, 0, &addr, - sizeof(addr)); + rc = pj_ioqueue_sendto(ckey, &write_op, send_buf, &bytes, 0, &dst_addr, + sizeof(dst_addr)); if (rc != PJ_SUCCESS && rc != PJ_EPENDING) { app_perror("...error: pj_ioqueue_sendto", rc); status=-30; goto on_error; @@ -268,8 +269,14 @@ static int compliance_test(void) status=-66; goto on_error; } - if (memcmp(send_buf, recv_buf, bufsize) != 0) { - status=-70; goto on_error; + if (pj_memcmp(send_buf, recv_buf, bufsize) != 0) { + status=-67; goto on_error; + } + if (addrlen != sizeof(pj_sockaddr_in)) { + status=-68; goto on_error; + } + if (addr.sin_family != PJ_AF_INET) { + status=-69; goto on_error; } @@ -295,13 +302,6 @@ static int compliance_test(void) status = 0; on_error: - if (status != 0) { - char errbuf[128]; - PJ_LOG(1, (THIS_FILE, - "...compliance test error: status=%d, os_err=%d (%s)", - status, pj_get_netos_error(), - pj_strerror(pj_get_netos_error(), errbuf, sizeof(errbuf)))); - } if (ssock) pj_sock_close(ssock); if (csock) @@ -431,7 +431,7 @@ static int bench_test(int bufsize, int inactive_sock_count) } // Bind server socket. - memset(&addr, 0, sizeof(addr)); + pj_memset(&addr, 0, sizeof(addr)); addr.sin_family = PJ_AF_INET; addr.sin_port = pj_htons(PORT); if (pj_sock_bind(ssock, &addr, sizeof(addr))) @@ -452,7 +452,7 @@ static int bench_test(int bufsize, int inactive_sock_count) inactive_sock_count*sizeof(pj_sock_t)); inactive_read_op = (pj_ioqueue_op_key_t*)pj_pool_alloc(pool, inactive_sock_count*sizeof(pj_ioqueue_op_key_t)); - memset(&addr, 0, sizeof(addr)); + pj_memset(&addr, 0, sizeof(addr)); addr.sin_family = PJ_AF_INET; for (i=0; i