summaryrefslogtreecommitdiff
path: root/ACE/tests/INET_Addr_Test.cpp
diff options
context:
space:
mode:
authorSteve Huston <shuston@riverace.com>2015-03-12 20:12:43 -0400
committerSteve Huston <shuston@riverace.com>2015-03-12 20:12:43 -0400
commitbfce463fcd2e0e30c4eab6434594efa938ee2d80 (patch)
treece928f844b47553ef12f0188e7068952d9c62a67 /ACE/tests/INET_Addr_Test.cpp
parent16e65aee37999efc6cdf01577bffe7ba707eebd3 (diff)
downloadATCD-bfce463fcd2e0e30c4eab6434594efa938ee2d80.tar.gz
Add the requisite test program addition for new feature
Diffstat (limited to 'ACE/tests/INET_Addr_Test.cpp')
-rw-r--r--ACE/tests/INET_Addr_Test.cpp51
1 files changed, 50 insertions, 1 deletions
diff --git a/ACE/tests/INET_Addr_Test.cpp b/ACE/tests/INET_Addr_Test.cpp
index 4743b2894f3..9e2cfc7a4a9 100644
--- a/ACE/tests/INET_Addr_Test.cpp
+++ b/ACE/tests/INET_Addr_Test.cpp
@@ -20,7 +20,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;
@@ -49,6 +49,52 @@ int check_type_consistency (const ACE_INET_Addr &addr)
return 0;
}
+static bool test_multiple (void)
+{
+
+ bool success = true;
+
+ // Check the behavior when there are multiple addresses assigned to a name.
+ // The NTP pool should always return multiples, though always different.
+ ACE_INET_Addr ntp;
+ if (ntp.set (123, ACE_TEXT ("pool.ntp.org")) == -1)
+ {
+ ACE_ERROR ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("pool.ntp.org")));
+ return false;
+ }
+ size_t count = 0;
+ ACE_TCHAR addr_string[256];
+ do
+ {
+ ++count; // If lookup succeeded, there's at least one
+ ntp.addr_to_string (addr_string, sizeof (addr_string));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("IPv4 %B: %s\n"), count, addr_string));
+ }
+ while (ntp.next ());
+ success = count > 1;
+
+#if defined (ACE_HAS_IPV6)
+ ACE_INET_Addr ntp6;
+ if (ntp6.set (123, ACE_TEXT ("2.pool.ntp.org"), 1, AF_INET6) == -1)
+ {
+ ACE_ERROR ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("2.pool.ntp.org")));
+ return false;
+ }
+ count = 0;
+ do
+ {
+ ++count; // If lookup succeeded, there's at least one
+ ntp6.addr_to_string (addr_string, sizeof (addr_string));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("IPv6 %B: %s\n"), count, addr_string));
+ }
+ while (ntp6.next ());
+ if (count <= 1)
+ success = false;
+#endif /* ACE_HAS_IPV6 */
+
+ return success;
+}
+
struct Address {
const char* name;
bool loopback;
@@ -273,6 +319,9 @@ int run_main (int, ACE_TCHAR *[])
status = 1;
}
+ if (!test_multiple ())
+ status = 1;
+
ACE_END_TEST;
return status;