summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorSteve Huston <shuston@riverace.com>1997-09-22 15:59:42 +0000
committerSteve Huston <shuston@riverace.com>1997-09-22 15:59:42 +0000
commit662c559154b8eb6ba0c77d78ff3c835de22f3bda (patch)
tree9c354c6862e2114367e04884422749c86c844f82 /tests
parenta24f4b1a9a7ee93304e497e5b6b6c9c936b8d810 (diff)
downloadATCD-662c559154b8eb6ba0c77d78ff3c835de22f3bda.tar.gz
A test for exercising ACE_SOCK_Connector functionality.
Diffstat (limited to 'tests')
-rw-r--r--tests/SOCK_Connector_Test.cpp84
1 files changed, 84 insertions, 0 deletions
diff --git a/tests/SOCK_Connector_Test.cpp b/tests/SOCK_Connector_Test.cpp
new file mode 100644
index 00000000000..5b698642acc
--- /dev/null
+++ b/tests/SOCK_Connector_Test.cpp
@@ -0,0 +1,84 @@
+// $Id$
+
+// ============================================================================
+//
+// = LIBRARY
+// tests
+//
+// = FILENAME
+// SOCK_Connector_Test.cpp
+//
+// = DESCRIPTION
+// This is a test of ACE_SOCK_Connector, focusing on failure cases more
+// than on success cases.
+//
+// = AUTHOR
+// Steve Huston
+//
+// ============================================================================
+
+#include "ace/OS.h"
+#include "ace/INET_Addr.h"
+#include "ace/SOCK_Connector.h"
+#include "ace/SOCK_Stream.h"
+#include "test_config.h"
+
+
+static int
+fail_no_listener_nonblocking(void)
+{
+
+int status;
+ACE_INET_Addr nobody_home((u_short)4242, "mambo"); // "localhost"
+ACE_SOCK_Connector con;
+ACE_SOCK_Stream sock;
+ACE_Time_Value nonblock(0, 0);
+
+ status = con.connect(sock, nobody_home, &nonblock);
+ ACE_ASSERT(status == -1); // Need a port that will fail
+
+ if (errno == EWOULDBLOCK) {
+ status = con.complete(sock);
+ if (status != -1) {
+ ACE_DEBUG((LM_DEBUG, "Connect which should fail didn't\n"));
+ status = -1;
+ }
+ else if (errno != ECONNREFUSED) {
+ ACE_DEBUG((LM_DEBUG, "%p', expected ECONNREFUSED\n",
+ "Failed with '"));
+ status = -1;
+ }
+ else {
+ ACE_DEBUG((LM_DEBUG, "%p\n", "Proper fail"));
+ status = 0;
+ }
+ }
+ else {
+ ACE_DEBUG((LM_DEBUG,
+ "Test not executed fully; expected EWOULDBLOCK, %p\n",
+ "not"));
+ status = -1;
+ }
+
+ sock.close(); // Just in case
+
+ return status;
+
+}
+
+
+int
+main (int, char *[])
+{
+
+int status = 0;
+
+ ACE_START_TEST ("SOCK_Connector_Test");
+
+ if (fail_no_listener_nonblocking() == -1)
+ status = 1;
+
+ ACE_END_TEST;
+ return status;
+}
+