You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by as...@apache.org on 2019/04/12 21:44:10 UTC

[qpid-proton] branch 0.27.x updated: PROTON-2018: Don't use a fixed port for the ssl proactor test

This is an automated email from the ASF dual-hosted git repository.

astitcher pushed a commit to branch 0.27.x
in repository https://gitbox.apache.org/repos/asf/qpid-proton.git


The following commit(s) were added to refs/heads/0.27.x by this push:
     new 560ba28  PROTON-2018: Don't use a fixed port for the ssl proactor test
560ba28 is described below

commit 560ba28223a6e815f9673e89baeaa4630b8b22fe
Author: Andrew Stitcher <as...@apache.org>
AuthorDate: Fri Apr 12 16:56:57 2019 -0400

    PROTON-2018: Don't use a fixed port for the ssl proactor test
    
    (cherry picked with changes from commit be0b0c277d5cdeeb2e7430b40d1b370b4d1425c9)
---
 c/tests/ssl_proactor_test.cpp | 36 ++++++++++++++++++++++++++++++++----
 1 file changed, 32 insertions(+), 4 deletions(-)

diff --git a/c/tests/ssl_proactor_test.cpp b/c/tests/ssl_proactor_test.cpp
index c9eafc7..7ae89d8 100644
--- a/c/tests/ssl_proactor_test.cpp
+++ b/c/tests/ssl_proactor_test.cpp
@@ -164,6 +164,36 @@ void run(pn_proactor_t *p, app_data_t *app, handler_t *shandler, handler_t *chan
   } while(true);
 }
 
+static void run_until_listener_open(pn_proactor_t* p) {
+  do {
+    pn_event_batch_t *events = pn_proactor_wait(p);
+    pn_event_t *e;
+    for (e = pn_event_batch_next(events); e; e = pn_event_batch_next(events)) {
+      if (pn_event_type(e)==PN_LISTENER_OPEN) {
+        pn_proactor_done(p, events);
+        return;
+      }
+    }
+    pn_proactor_done(p, events);
+  } while (true);
+}
+
+static void setup_connection(pn_proactor_t* proactor, pn_transport_t* t) {
+  pn_listener_t* l = pn_listener();
+  pn_proactor_listen(proactor, l, ":0", 16);
+  // Don't know port until the listener is open
+  run_until_listener_open(proactor);
+
+  // Construct connect address (from listener port)
+  const pn_netaddr_t* a = pn_listener_addr(l);
+  char port[32];
+  port[0] = ':';
+  pn_netaddr_host_port(a, NULL, 0, port+1, 31);
+
+  INFO("Connecting to " << port);
+  pn_proactor_connect2(proactor, NULL, t, port);
+}
+
 TEST_CASE("ssl") {
   struct app_data_t app = {0};
 
@@ -187,8 +217,7 @@ TEST_CASE("ssl") {
     REQUIRE(pn_ssl_domain_set_peer_authentication(cd, PN_SSL_VERIFY_PEER_NAME, NULL) == 0);
     REQUIRE(pn_ssl_init(pn_ssl(t), cd, NULL) == 0);
 
-    pn_proactor_listen(proactor, pn_listener(), "", 16);
-    pn_proactor_connect2(proactor, NULL, t, "");
+    setup_connection(proactor, t);
 
     run(proactor, &app, server_handler, client_handler);
     CHECK(app.connection_succeeded==false);
@@ -200,8 +229,7 @@ TEST_CASE("ssl") {
     REQUIRE(pn_ssl_domain_set_peer_authentication(cd, PN_SSL_ANONYMOUS_PEER, NULL) == 0);
     REQUIRE(pn_ssl_init(pn_ssl(t), cd, NULL) == 0);
 
-    pn_proactor_listen(proactor, pn_listener(), "", 16);
-    pn_proactor_connect2(proactor, NULL, t, "");
+    setup_connection(proactor, t);
 
     run(proactor, &app, server_handler, client_handler);
     CHECK(app.connection_succeeded==true);


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org