summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorbojan <bojan@13f79535-47bb-0310-9956-ffa450edef68>2008-06-03 00:20:24 +0000
committerbojan <bojan@13f79535-47bb-0310-9956-ffa450edef68>2008-06-03 00:20:24 +0000
commita00f6ee48531245dcb342ec18ea0abc15b50893c (patch)
tree5a739f696738b6f7597f4971830aa434962c2fa1 /test
parentf7d7d9e5b1f0fe08ba7a3668e1369ccd174ecaca (diff)
downloadlibapr-a00f6ee48531245dcb342ec18ea0abc15b50893c.tar.gz
Backport rr661178 and 662326 from the trunk.
Fix PR44367. Caveats: - no idea if IBM's proprietary OSes actually have thread-safe version of getservbyname() function, just assumed that by looking at other similar functions being marked safe in APR detection code - works on Linux (Fedora 9, i.e. glibc2) Use thread safe versions of getservbyname(). Add test for apr_getservbyname(). git-svn-id: http://svn.apache.org/repos/asf/apr/apr/branches/1.3.x@662607 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'test')
-rw-r--r--test/testsock.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/test/testsock.c b/test/testsock.c
index 0d1bd578b..84121449b 100644
--- a/test/testsock.c
+++ b/test/testsock.c
@@ -73,6 +73,26 @@ static void test_addr_info(abts_case *tc, void *data)
ABTS_STR_EQUAL(tc, "127.0.0.1", sa->hostname);
}
+static void test_serv_by_name(abts_case *tc, void *data)
+{
+ apr_status_t rv;
+ apr_sockaddr_t *sa;
+
+ rv = apr_sockaddr_info_get(&sa, NULL, APR_UNSPEC, 0, 0, p);
+ APR_ASSERT_SUCCESS(tc, "Problem generating sockaddr", rv);
+
+ rv = apr_getservbyname(sa, "ftp");
+ APR_ASSERT_SUCCESS(tc, "Problem getting ftp service", rv);
+ ABTS_INT_EQUAL(tc, 21, sa->port);
+
+ rv = apr_getservbyname(sa, "complete_and_utter_rubbish");
+ APR_ASSERT_SUCCESS(tc, "Problem getting non-existent service", !rv);
+
+ rv = apr_getservbyname(sa, "http");
+ APR_ASSERT_SUCCESS(tc, "Problem getting http service", rv);
+ ABTS_INT_EQUAL(tc, 80, sa->port);
+}
+
static apr_socket_t *setup_socket(abts_case *tc)
{
apr_status_t rv;
@@ -318,6 +338,7 @@ abts_suite *testsock(abts_suite *suite)
suite = ADD_SUITE(suite)
abts_run_test(suite, test_addr_info, NULL);
+ abts_run_test(suite, test_serv_by_name, NULL);
abts_run_test(suite, test_create_bind_listen, NULL);
abts_run_test(suite, test_send, NULL);
abts_run_test(suite, test_recv, NULL);