"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "test/testsock.c" between
apr-1.6.5.tar.bz2 and apr-1.7.0.tar.bz2

About: APR (Apache Portable Runtime) project offers software libraries that provide a predictable and consistent interface to underlying platform-specific implementations (APR core library).

testsock.c  (apr-1.6.5.tar.bz2):testsock.c  (apr-1.7.0.tar.bz2)
skipping to change at line 580 skipping to change at line 580
ABTS_INT_EQUAL(tc, 1, on); ABTS_INT_EQUAL(tc, 1, on);
rv = apr_socket_bind(sock, sa); rv = apr_socket_bind(sock, sa);
APR_ASSERT_SUCCESS(tc, "Problem binding to port with FREEBIND", rv); APR_ASSERT_SUCCESS(tc, "Problem binding to port with FREEBIND", rv);
rv = apr_socket_close(sock); rv = apr_socket_close(sock);
APR_ASSERT_SUCCESS(tc, "Problem closing socket", rv); APR_ASSERT_SUCCESS(tc, "Problem closing socket", rv);
#endif #endif
} }
#define TEST_ZONE_ADDR "fe80::1"
#ifdef __linux__
/* Reasonable bet that "lo" will exist. */
#define TEST_ZONE_NAME "lo"
/* ... fill in other platforms here */
#endif
#ifdef TEST_ZONE_NAME
#define TEST_ZONE_FULLADDR TEST_ZONE_ADDR "%" TEST_ZONE_NAME
#endif
static void test_zone(abts_case *tc, void *data)
{
#if APR_HAVE_IPV6
apr_sockaddr_t *sa;
apr_status_t rv;
const char *name = NULL;
apr_uint32_t id = 0;
rv = apr_sockaddr_info_get(&sa, "127.0.0.1", APR_INET, 8080, 0, p);
APR_ASSERT_SUCCESS(tc, "Problem generating sockaddr", rv);
/* Fail for an IPv4 address! */
ABTS_INT_EQUAL(tc, APR_EBADIP,
apr_sockaddr_zone_set(sa, "1"));
ABTS_INT_EQUAL(tc, APR_EBADIP,
apr_sockaddr_zone_get(sa, &name, &id, p));
rv = apr_sockaddr_info_get(&sa, "::1", APR_INET6, 8080, 0, p);
APR_ASSERT_SUCCESS(tc, "Problem generating sockaddr", rv);
/* Fail for an address which isn't link-local */
ABTS_INT_EQUAL(tc, APR_EBADIP, apr_sockaddr_zone_set(sa, "1"));
rv = apr_sockaddr_info_get(&sa, TEST_ZONE_ADDR, APR_INET6, 8080, 0, p);
APR_ASSERT_SUCCESS(tc, "Problem generating sockaddr", rv);
ABTS_INT_EQUAL(tc, APR_EBADIP, apr_sockaddr_zone_get(sa, &name, &id, p));
#ifdef TEST_ZONE_NAME
{
apr_sockaddr_t *sa2;
char buf[50];
APR_ASSERT_SUCCESS(tc, "Set zone to " TEST_ZONE_NAME,
apr_sockaddr_zone_set(sa, TEST_ZONE_NAME));
APR_ASSERT_SUCCESS(tc, "Get zone",
apr_sockaddr_zone_get(sa, NULL, NULL, p));
APR_ASSERT_SUCCESS(tc, "Get zone",
apr_sockaddr_zone_get(sa, &name, &id, p));
ABTS_STR_EQUAL(tc, TEST_ZONE_NAME, name);
ABTS_INT_NEQUAL(tc, 0, id); /* Only guarantee is that it should be non-z
ero */
/* Check string translation. */
APR_ASSERT_SUCCESS(tc, "get IP address",
apr_sockaddr_ip_getbuf(buf, 50, sa));
ABTS_STR_EQUAL(tc, TEST_ZONE_FULLADDR, buf);
memset(buf, 'A', sizeof buf);
ABTS_INT_EQUAL(tc, APR_ENOSPC, apr_sockaddr_ip_getbuf(buf, strlen(TEST_Z
ONE_ADDR), sa));
ABTS_INT_EQUAL(tc, APR_ENOSPC, apr_sockaddr_ip_getbuf(buf, strlen(TEST_Z
ONE_FULLADDR), sa));
APR_ASSERT_SUCCESS(tc, "get IP address",
apr_sockaddr_ip_getbuf(buf, strlen(TEST_ZONE_FULLADDR
) + 1, sa));
/* Check for overflow. */
ABTS_INT_EQUAL(tc, 'A', buf[strlen(buf) + 1]);
rv = apr_sockaddr_info_copy(&sa2, sa, p);
APR_ASSERT_SUCCESS(tc, "Problem copying sockaddr", rv);
/* Copy copied zone matches */
APR_ASSERT_SUCCESS(tc, "Get zone",
apr_sockaddr_zone_get(sa2, &name, &id, p));
ABTS_STR_EQUAL(tc, TEST_ZONE_NAME, name);
ABTS_INT_NEQUAL(tc, 0, id); /* Only guarantee is that it should be non-z
ero */
/* Should match self and copy */
ABTS_INT_NEQUAL(tc, 0, apr_sockaddr_equal(sa, sa));
ABTS_INT_NEQUAL(tc, 0, apr_sockaddr_equal(sa2, sa2));
ABTS_INT_NEQUAL(tc, 0, apr_sockaddr_equal(sa2, sa));
/* Should not match against copy without zone set. */
rv = apr_sockaddr_info_get(&sa2, TEST_ZONE_ADDR, APR_INET6, 8080, 0, p);
APR_ASSERT_SUCCESS(tc, "Problem generating sockaddr", rv);
ABTS_INT_EQUAL(tc, 0, apr_sockaddr_equal(sa2, sa));
}
#endif /* TEST_ZONE_NAME */
#endif /* APR_HAVE_IPV6 */
}
abts_suite *testsock(abts_suite *suite) abts_suite *testsock(abts_suite *suite)
{ {
suite = ADD_SUITE(suite) suite = ADD_SUITE(suite)
socket_name = IPV4_SOCKET_NAME; socket_name = IPV4_SOCKET_NAME;
abts_run_test(suite, test_addr_info, NULL); abts_run_test(suite, test_addr_info, NULL);
abts_run_test(suite, test_addr_copy, NULL); abts_run_test(suite, test_addr_copy, NULL);
abts_run_test(suite, test_serv_by_name, NULL); abts_run_test(suite, test_serv_by_name, NULL);
abts_run_test(suite, test_create_bind_listen, NULL); abts_run_test(suite, test_create_bind_listen, NULL);
abts_run_test(suite, test_send, NULL); abts_run_test(suite, test_send, NULL);
abts_run_test(suite, test_recv, NULL); abts_run_test(suite, test_recv, NULL);
abts_run_test(suite, test_atreadeof, NULL); abts_run_test(suite, test_atreadeof, NULL);
abts_run_test(suite, test_timeout, NULL); abts_run_test(suite, test_timeout, NULL);
abts_run_test(suite, test_print_addr, NULL); abts_run_test(suite, test_print_addr, NULL);
abts_run_test(suite, test_get_addr, NULL); abts_run_test(suite, test_get_addr, NULL);
abts_run_test(suite, test_nonblock_inheritance, NULL); abts_run_test(suite, test_nonblock_inheritance, NULL);
abts_run_test(suite, test_freebind, NULL); abts_run_test(suite, test_freebind, NULL);
abts_run_test(suite, test_zone, NULL);
#if APR_HAVE_SOCKADDR_UN #if APR_HAVE_SOCKADDR_UN
socket_name = UNIX_SOCKET_NAME; socket_name = UNIX_SOCKET_NAME;
socket_type = APR_UNIX; socket_type = APR_UNIX;
abts_run_test(suite, test_create_bind_listen, NULL); abts_run_test(suite, test_create_bind_listen, NULL);
abts_run_test(suite, test_send, NULL); abts_run_test(suite, test_send, NULL);
abts_run_test(suite, test_recv, NULL); abts_run_test(suite, test_recv, NULL);
abts_run_test(suite, test_timeout, NULL); abts_run_test(suite, test_timeout, NULL);
#endif #endif
return suite; return suite;
 End of changes. 2 change blocks. 
0 lines changed or deleted 100 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)