From e5cb601f3d32162eda473033e84f1f8bfb28ce07 Mon Sep 17 00:00:00 2001 From: Steve Huston Date: Wed, 29 Mar 2017 19:01:09 -0400 Subject: Add new test case for selecting protocol by name --- ACE/tests/INET_Addr_Test_IPV6.cpp | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/ACE/tests/INET_Addr_Test_IPV6.cpp b/ACE/tests/INET_Addr_Test_IPV6.cpp index d9409bed5e8..a3c37ce6412 100644 --- a/ACE/tests/INET_Addr_Test_IPV6.cpp +++ b/ACE/tests/INET_Addr_Test_IPV6.cpp @@ -22,7 +22,7 @@ // Make sure that ACE_Addr::addr_type_ is the same // as the family of the inet_addr_. -int check_type_consistency (const ACE_INET_Addr &addr) +static int check_type_consistency (const ACE_INET_Addr &addr) { int family = -1; @@ -51,6 +51,35 @@ int check_type_consistency (const ACE_INET_Addr &addr) return 0; } +// A test to ensure ACE_INET_Addr can select the protocol family. +static bool check_both_families() +{ + bool good = true; + ACE_INET_Addr a; + if (-1 == a.set(ACE_TEXT (""), ACE_TEXT ("facebook.com"), ACE_TEXT ("tcp"))) + { + ACE_ERROR ((LM_ERROR, + ACE_TEXT ("%p\n"), + ACE_TEXT ("both test, facebook.com"))); + good = false; + } + else + { + ACE_TCHAR str[1000]; + a.addr_to_string (str, 1000, 1); + ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("got type %d, addr %s\n"), a.get_type(), str)); + // Should have selected IPv4. + if (a.get_type() != AF_INET) + { + ACE_ERROR ((LM_ERROR, + ACE_TEXT ("Wrong address family, expecting IPv4\n"))); + good = false; + } + } + + return good; +} + int run_main (int, ACE_TCHAR *[]) { @@ -154,6 +183,9 @@ int run_main (int, ACE_TCHAR *[]) #endif /* ACE_LINUX */ } + if (!check_both_families()) + status = 1; + #endif /* ACE_HAS_IPV6 */ ACE_END_TEST; -- cgit v1.2.1