summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgthaker <gthaker@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2003-01-20 18:34:42 +0000
committergthaker <gthaker@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2003-01-20 18:34:42 +0000
commitb56fe9cf40eeda9c0cbe9e7300d9effffb0c224b (patch)
treef5f48d0d28842aafb45a26cf90e30082bb7733f2
parent340500477aabede94014fbbd79c38b909a357d4f (diff)
downloadATCD-b56fe9cf40eeda9c0cbe9e7300d9effffb0c224b.tar.gz
Test for ACE_Multihomed_INET_Addr
-rw-r--r--tests/Multihomed_INET_Addr_Test.cpp328
1 files changed, 164 insertions, 164 deletions
diff --git a/tests/Multihomed_INET_Addr_Test.cpp b/tests/Multihomed_INET_Addr_Test.cpp
index 3a8403ce0c6..c65dbbf0e7f 100644
--- a/tests/Multihomed_INET_Addr_Test.cpp
+++ b/tests/Multihomed_INET_Addr_Test.cpp
@@ -44,13 +44,13 @@ int ACE_TMAIN (int argc, ACE_TCHAR *argv[])
// The secondary addresses will always be these...
const char *secondary_dotted_decimals[] = {
- "64.219.54.121",
+ "64.219.54.121",
"127.0.0.1",
"21.242.14.51",
"53.141.124.24",
"42.12.44.9"
};
-
+
// ... and as you can see, there are 5 of them
const size_t num_secondaries = 5;
@@ -58,7 +58,7 @@ int ACE_TMAIN (int argc, ACE_TCHAR *argv[])
// in ACE_UINT32 format in host byte order
ACE_UINT32 primary_addr32;
ACE_UINT32 secondary_addr32[5];
-
+
{
struct in_addr addrv4;
ACE_OS::inet_pton (AF_INET, primary_dotted_decimal, &addrv4);
@@ -79,61 +79,61 @@ int ACE_TMAIN (int argc, ACE_TCHAR *argv[])
// Array of ones (used to clear the secondary addresses of the test
// subject)
ACE_UINT32 array_of_threes[5] = { ACE_UINT32 (3),
- ACE_UINT32 (3),
- ACE_UINT32 (3),
- ACE_UINT32 (3),
- ACE_UINT32 (3) };
-
+ ACE_UINT32 (3),
+ ACE_UINT32 (3),
+ ACE_UINT32 (3),
+ ACE_UINT32 (3) };
+
// Array of INET_Addrs that will repeatedly be passed into the
// get_secondary_addresses accessor of Multihomed_INET_Addr
- ACE_INET_Addr in_out[5];
+ ACE_INET_Addr in_out[5];
// Array of INET_Addrs against which the above array will be tested.
ACE_INET_Addr stay_out[5];
-
+
// Array of sockaddrs that will repeatedly be passed into the
// get_addresses accessor of Multihomed_INET_Addr
const size_t num_sockaddrs = 6;
sockaddr in_out_sockaddr[num_sockaddrs];
- // Run the test with a varying number of secondary addresses
+ // Run the test with a varying number of secondary addresses
for (i = 0; i <= num_secondaries; ++i) {
/****** Clear the in_out array and test subject ******/
-
+
// Clear the in_out array by setting every port to 0 and every
// address to 1
for (j = 0; j < num_secondaries; ++j) {
in_out[j].set(0, ACE_UINT32 (1), 1);
}
-
+
// Clear the in_out_sockaddr array by setting every port to 0 and
// every address to 1
ACE_OS::memset(in_out_sockaddr, 0, num_sockaddrs * sizeof(sockaddr));
-
+
// Clear the test subject by setting the port to 2 and every
// address (both the primary and the secondaries) to 3
addr.set (2, ACE_UINT32 (3), 1, array_of_threes, num_secondaries);
-
+
// Check that the port is 2
if (addr.get_port_number() != 2) {
ACE_ERROR ((LM_ERROR,
- ACE_TEXT ("Failed get_port_number check\n")
- ACE_TEXT ("%d != %d\n"),
- addr.get_port_number(),
- 2));
+ ACE_TEXT ("Failed get_port_number check\n")
+ ACE_TEXT ("%d != %d\n"),
+ addr.get_port_number(),
+ 2));
status = 1;
}
-
+
// Check that the primary address is 3
if (addr.get_ip_address() != ACE_UINT32 (3)) {
ACE_ERROR ((LM_ERROR,
- ACE_TEXT ("Failed get_ip_address check\n")
- ACE_TEXT ("0x%x != 0x%x\n"),
- addr.get_ip_address(),
- ACE_UINT32 (3)));
+ ACE_TEXT ("Failed get_ip_address check\n")
+ ACE_TEXT ("0x%x != 0x%x\n"),
+ addr.get_ip_address(),
+ ACE_UINT32 (3)));
status = 1;
}
@@ -153,50 +153,50 @@ int ACE_TMAIN (int argc, ACE_TCHAR *argv[])
// Check that the in_out array matches stay_out element
for (j = 0; j < num_secondaries; ++j) {
- if (in_out[j] != stay_out[0]) {
-
- ACE_TCHAR in_out_string[100];
- ACE_TCHAR stay_out_string[100];
-
- in_out[j].addr_to_string(in_out_string, 100);
- stay_out[0].addr_to_string(stay_out_string, 100);
-
- ACE_ERROR ((LM_ERROR,
- ACE_TEXT ("Failed get_secondary_addresses check\n")
- ACE_TEXT ("%s != %s\n"),
- in_out_string,
- stay_out_string));
-
- status = 1;
- }
+ if (in_out[j] != stay_out[0]) {
+
+ ACE_TCHAR in_out_string[100];
+ ACE_TCHAR stay_out_string[100];
+
+ in_out[j].addr_to_string(in_out_string, 100);
+ stay_out[0].addr_to_string(stay_out_string, 100);
+
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("Failed get_secondary_addresses check\n")
+ ACE_TEXT ("%s != %s\n"),
+ in_out_string,
+ stay_out_string));
+
+ status = 1;
+ }
}
// Pass the in_out_sockaddr array to the accessor
addr.get_addresses(in_out_sockaddr, num_secondaries + 1);
-
+
// Check that the in_out_sockaddr array matches stay_out element
for (j = 0, pointer = in_out_sockaddr;
j < num_secondaries + 1;
++j, ++pointer) {
- if (memcmp(pointer, stay_out[0].get_addr(), sizeof(sockaddr))) {
+ if (memcmp(pointer, stay_out[0].get_addr(), sizeof(sockaddr))) {
+
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("Failed get_addresses check\n")));
- ACE_ERROR ((LM_ERROR,
- ACE_TEXT ("Failed get_addresses check\n")));
-
- status = 1;
- }
+ status = 1;
+ }
}
} else {
-
- ACE_ERROR ((LM_ERROR,
- ACE_TEXT ("Failed get_num_secondary_addresses check\n")
- ACE_TEXT ("%d != %d\n"),
- returned_num_secondaries,
- num_secondaries));
- status = 1;
-
+
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("Failed get_num_secondary_addresses check\n")
+ ACE_TEXT ("%d != %d\n"),
+ returned_num_secondaries,
+ num_secondaries));
+ status = 1;
+
}
@@ -204,19 +204,19 @@ int ACE_TMAIN (int argc, ACE_TCHAR *argv[])
addr.set(port,
- primary_dotted_decimal,
- 1,
- AF_INET,
- secondary_dotted_decimals,
- i);
+ primary_dotted_decimal,
+ 1,
+ AF_INET,
+ secondary_dotted_decimals,
+ i);
// Check the port number
if (addr.get_port_number() != port) {
ACE_ERROR ((LM_ERROR,
- ACE_TEXT ("Failed second get_port_number check\n")
- ACE_TEXT ("%d != %d\n"),
- addr.get_port_number(),
- port));
+ ACE_TEXT ("Failed second get_port_number check\n")
+ ACE_TEXT ("%d != %d\n"),
+ addr.get_port_number(),
+ port));
status = 1;
}
@@ -239,7 +239,7 @@ int ACE_TMAIN (int argc, ACE_TCHAR *argv[])
// Initialize the stay_out array with the secondary addresses
for (j = 0; j < i; ++j) {
- stay_out[j].set(port, secondary_dotted_decimals[j]);
+ stay_out[j].set(port, secondary_dotted_decimals[j]);
}
// Pass the in_out array to the accessor
@@ -248,96 +248,96 @@ int ACE_TMAIN (int argc, ACE_TCHAR *argv[])
// Check that the in_out array matches stay_out array
for (j = 0; j < i; ++j) {
- if (in_out[j] != stay_out[j]) {
-
- ACE_TCHAR in_out_string[100];
- ACE_TCHAR stay_out_string[100];
-
- in_out[j].addr_to_string(in_out_string, 100);
- stay_out[j].addr_to_string(stay_out_string, 100);
-
- ACE_ERROR ((LM_ERROR,
- ACE_TEXT ("Failed second get_secondary_addresses check\n")
- ACE_TEXT ("%s != %s\n"),
- in_out_string,
- stay_out_string));
-
- status = 1;
- }
+ if (in_out[j] != stay_out[j]) {
+
+ ACE_TCHAR in_out_string[100];
+ ACE_TCHAR stay_out_string[100];
+
+ in_out[j].addr_to_string(in_out_string, 100);
+ stay_out[j].addr_to_string(stay_out_string, 100);
+
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("Failed second get_secondary_addresses check\n")
+ ACE_TEXT ("%s != %s\n"),
+ in_out_string,
+ stay_out_string));
+
+ status = 1;
+ }
}
// Pass the in_out_sockaddr array to the accessor
addr.get_addresses(in_out_sockaddr, i + 1);
-
+
// Check that the primary address in the in_out_sockaddr array
// matches the primary address reported by the superclass
if (memcmp(in_out_sockaddr, addr.get_addr(), sizeof(sockaddr))) {
- ACE_ERROR ((LM_ERROR,
- ACE_TEXT ("Failed second get_addresses check ")
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("Failed second get_addresses check ")
ACE_TEXT ("(for primary address)\n")));
-
- status = 1;
+
+ status = 1;
}
-
+
// Check that the secondary addresses in the in_out_sockaddr
// array match the stay_out array
for (j = 1, pointer = &in_out_sockaddr[1];
j < i + 1;
++j, ++pointer) {
- if (memcmp(pointer, stay_out[j-1].get_addr(), sizeof(sockaddr))) {
+ if (memcmp(pointer, stay_out[j-1].get_addr(), sizeof(sockaddr))) {
- ACE_ERROR ((LM_ERROR,
- ACE_TEXT ("Failed second get_addresses check ")
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("Failed second get_addresses check ")
ACE_TEXT ("(for secondary addresses)\n")));
-
- status = 1;
- }
+
+ status = 1;
+ }
}
} else {
-
+
ACE_ERROR ((LM_ERROR,
- ACE_TEXT ("Failed second get_num_secondary_addresses check\n")
- ACE_TEXT ("%d != %d\n"),
- returned_num_secondaries,
- i));
+ ACE_TEXT ("Failed second get_num_secondary_addresses check\n")
+ ACE_TEXT ("%d != %d\n"),
+ returned_num_secondaries,
+ i));
status = 1;
}
/****** Clear the in_out array and test subject AGAIN ******/
-
+
// Clear the in_out array by setting every port to 0 and every
// address to 1
for (j = 0; j < num_secondaries; ++j) {
in_out[j].set(0, ACE_UINT32 (1), 1);
}
-
+
// Clear the test subject by setting the port to 2 and every
// address (both the primary and the secondaries) to 3
addr.set (2, ACE_UINT32 (3), 1, array_of_threes, num_secondaries);
-
+
// Check that the port is 2
if (addr.get_port_number() != 2) {
ACE_ERROR ((LM_ERROR,
- ACE_TEXT ("Failed third get_port_number check\n")
- ACE_TEXT ("%d != %d\n"),
- addr.get_port_number(),
- 2));
+ ACE_TEXT ("Failed third get_port_number check\n")
+ ACE_TEXT ("%d != %d\n"),
+ addr.get_port_number(),
+ 2));
status = 1;
}
-
+
// Check that the primary address is 3
if (addr.get_ip_address() != ACE_UINT32 (3)) {
ACE_ERROR ((LM_ERROR,
- ACE_TEXT ("Failed third get_ip_address check\n")
- ACE_TEXT ("0x%x != 0x%x\n"),
- addr.get_ip_address(),
- ACE_UINT32 (3)));
+ ACE_TEXT ("Failed third get_ip_address check\n")
+ ACE_TEXT ("0x%x != 0x%x\n"),
+ addr.get_ip_address(),
+ ACE_UINT32 (3)));
status = 1;
}
@@ -357,51 +357,51 @@ int ACE_TMAIN (int argc, ACE_TCHAR *argv[])
// Check that the in_out array matches stay_out array
for (j = 0; j < num_secondaries; ++j) {
- if (in_out[j] != stay_out[0]) {
-
- ACE_TCHAR in_out_string[100];
- ACE_TCHAR stay_out_string[100];
-
- in_out[j].addr_to_string(in_out_string, 100);
- stay_out[0].addr_to_string(stay_out_string, 100);
-
- ACE_ERROR ((LM_ERROR,
- ACE_TEXT ("Failed third get_secondary_addresses check\n")
- ACE_TEXT ("%s != %s\n"),
- in_out_string,
- stay_out_string));
-
- status = 1;
- }
+ if (in_out[j] != stay_out[0]) {
+
+ ACE_TCHAR in_out_string[100];
+ ACE_TCHAR stay_out_string[100];
+
+ in_out[j].addr_to_string(in_out_string, 100);
+ stay_out[0].addr_to_string(stay_out_string, 100);
+
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("Failed third get_secondary_addresses check\n")
+ ACE_TEXT ("%s != %s\n"),
+ in_out_string,
+ stay_out_string));
+
+ status = 1;
+ }
}
} else {
-
- ACE_ERROR ((LM_ERROR,
- ACE_TEXT ("Failed third get_num_secondary_addresses check\n")
- ACE_TEXT ("%d != %d\n"),
- returned_num_secondaries,
- num_secondaries));
- status = 1;
-
+
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("Failed third get_num_secondary_addresses check\n")
+ ACE_TEXT ("%d != %d\n"),
+ returned_num_secondaries,
+ num_secondaries));
+ status = 1;
+
}
/**** Test set (u_short, ACE_UINT32, int, const ACE_UINT32 *, size_t) ****/
addr.set(port,
- primary_addr32,
- 1,
- secondary_addr32,
- i);
+ primary_addr32,
+ 1,
+ secondary_addr32,
+ i);
// Check the port number
if (addr.get_port_number() != port) {
ACE_ERROR ((LM_ERROR,
- ACE_TEXT ("Failed forth get_port_number check\n")
- ACE_TEXT ("%d != %d\n"),
- addr.get_port_number(),
- port));
+ ACE_TEXT ("Failed forth get_port_number check\n")
+ ACE_TEXT ("%d != %d\n"),
+ addr.get_port_number(),
+ port));
status = 1;
}
@@ -424,7 +424,7 @@ int ACE_TMAIN (int argc, ACE_TCHAR *argv[])
// Initialize the stay_out array with the secondary addresses
for (j = 0; j < i; ++j) {
- stay_out[j].set(port, secondary_addr32[j]);
+ stay_out[j].set(port, secondary_addr32[j]);
}
// Pass the in_out array to the accessor
@@ -433,31 +433,31 @@ int ACE_TMAIN (int argc, ACE_TCHAR *argv[])
// Check that the in_out array matches stay_out array
for (j = 0; j < i; ++j) {
- if (in_out[j] != stay_out[j]) {
-
- ACE_TCHAR in_out_string[100];
- ACE_TCHAR stay_out_string[100];
-
- in_out[j].addr_to_string(in_out_string, 100);
- stay_out[j].addr_to_string(stay_out_string, 100);
-
- ACE_ERROR ((LM_ERROR,
- ACE_TEXT ("Failed forth get_secondary_addresses check\n")
- ACE_TEXT ("%s != %s\n"),
- in_out_string,
- stay_out_string));
-
- status = 1;
- }
+ if (in_out[j] != stay_out[j]) {
+
+ ACE_TCHAR in_out_string[100];
+ ACE_TCHAR stay_out_string[100];
+
+ in_out[j].addr_to_string(in_out_string, 100);
+ stay_out[j].addr_to_string(stay_out_string, 100);
+
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("Failed forth get_secondary_addresses check\n")
+ ACE_TEXT ("%s != %s\n"),
+ in_out_string,
+ stay_out_string));
+
+ status = 1;
+ }
}
} else {
-
+
ACE_ERROR ((LM_ERROR,
- ACE_TEXT ("Failed forth get_num_secondary_addresses check\n")
- ACE_TEXT ("%d != %d\n"),
- returned_num_secondaries,
- i));
+ ACE_TEXT ("Failed forth get_num_secondary_addresses check\n")
+ ACE_TEXT ("%d != %d\n"),
+ returned_num_secondaries,
+ i));
status = 1;
}