diff --git a/tests/test_security_zap.cpp b/tests/test_security_zap.cpp index ffdd0999..213d3939 100644 --- a/tests/test_security_zap.cpp +++ b/tests/test_security_zap.cpp @@ -266,6 +266,20 @@ void test_zap_errors (socket_config_fn server_socket_config_, client_socket_config_data_); shutdown_context_and_server_side (ctx, zap_thread, server, server_mon, handler); + // no ZAP handler + fprintf (stderr, "test_zap_unsuccessful no ZAP handler started\n"); + setup_context_and_server_side ( + &ctx, &handler, &zap_thread, &server, &server_mon, my_endpoint, + NULL, server_socket_config_); + test_zap_unsuccessful (ctx, my_endpoint, server, server_mon, +#ifdef ZMQ_BUILD_DRAFT_API + ZMQ_EVENT_HANDSHAKE_FAILED_NO_DETAIL, EFAULT, +#else + 0, 0, +#endif + client_socket_config_, client_socket_config_data_); + shutdown_context_and_server_side (ctx, zap_thread, server, server_mon, + handler); } int main (void) diff --git a/tests/testutil_security.hpp b/tests/testutil_security.hpp index ea27d724..288783db 100644 --- a/tests/testutil_security.hpp +++ b/tests/testutil_security.hpp @@ -336,12 +336,15 @@ void setup_context_and_server_side ( int rc = zmq_bind (*handler, "inproc://handler-control"); assert (rc == 0); - *zap_thread = zmq_threadstart (zap_handler_, *ctx); + if (zap_handler_) { + *zap_thread = zmq_threadstart (zap_handler_, *ctx); - char *buf = s_recv (*handler); - assert (buf); - assert (streq (buf, "GO")); - free (buf); + char *buf = s_recv (*handler); + assert (buf); + assert (streq (buf, "GO")); + free (buf); + } else + *zap_thread = NULL; // Server socket will accept connections *server = zmq_socket (*ctx, ZMQ_DEALER); @@ -386,7 +389,8 @@ void shutdown_context_and_server_side (void *ctx, close_zero_linger (server); // Wait until ZAP handler terminates - zmq_threadclose (zap_thread); + if (zap_thread) + zmq_threadclose (zap_thread); rc = zmq_ctx_term (ctx); assert (rc == 0);