void test_poller_exists_with_socket_on_zmq_ctx_term (const int socket_type_) { #ifdef ZMQ_HAVE_POLLER struct poller_test_data_t poller_test_data; poller_test_data.socket_type = socket_type_; // Set up our context and sockets poller_test_data.ctx = zmq_ctx_new (); TEST_ASSERT_NOT_NULL (poller_test_data.ctx); poller_test_data.counter = zmq_atomic_counter_new (); TEST_ASSERT_NOT_NULL (poller_test_data.counter); void *thread = zmq_threadstart (run_poller, &poller_test_data); TEST_ASSERT_NOT_NULL (thread); while (zmq_atomic_counter_value (poller_test_data.counter) == 0) { msleep (10); } // Destroy the context TEST_ASSERT_SUCCESS_ERRNO (zmq_ctx_destroy (poller_test_data.ctx)); zmq_threadclose (thread); zmq_atomic_counter_destroy (&poller_test_data.counter); #else TEST_IGNORE_MESSAGE ("libzmq without zmq_poller_* support, ignoring test"); #endif }
void check_proxy_stats (void *control_proxy) { zmq_proxy_stats_t total_stats; int rc; rc = zmq_send (control_proxy, "STATISTICS", 10, 0); assert (rc == 10); // first frame of the reply contains FRONTEND stats: total_stats.frontend.msg_in = recv_stat (control_proxy, false); total_stats.frontend.bytes_in = recv_stat (control_proxy, false); total_stats.frontend.msg_out = recv_stat (control_proxy, false); total_stats.frontend.bytes_out = recv_stat (control_proxy, false); // second frame of the reply contains BACKEND stats: total_stats.backend.msg_in = recv_stat (control_proxy, false); total_stats.backend.bytes_in = recv_stat (control_proxy, false); total_stats.backend.msg_out = recv_stat (control_proxy, false); total_stats.backend.bytes_out = recv_stat (control_proxy, true); // check stats if (is_verbose) { printf ( "frontend: pkts_in=%lu bytes_in=%lu pkts_out=%lu bytes_out=%lu\n", (unsigned long int) total_stats.frontend.msg_in, (unsigned long int) total_stats.frontend.bytes_in, (unsigned long int) total_stats.frontend.msg_out, (unsigned long int) total_stats.frontend.bytes_out); printf ( "backend: pkts_in=%lu bytes_in=%lu pkts_out=%lu bytes_out=%lu\n", (unsigned long int) total_stats.backend.msg_in, (unsigned long int) total_stats.backend.bytes_in, (unsigned long int) total_stats.backend.msg_out, (unsigned long int) total_stats.backend.bytes_out); printf ("clients sent out %d requests\n", zmq_atomic_counter_value (g_clients_pkts_out)); printf ("workers sent out %d replies\n", zmq_atomic_counter_value (g_workers_pkts_out)); } assert (total_stats.frontend.msg_in == (unsigned) zmq_atomic_counter_value (g_clients_pkts_out)); assert (total_stats.frontend.msg_out == (unsigned) zmq_atomic_counter_value (g_workers_pkts_out)); assert (total_stats.backend.msg_in == (unsigned) zmq_atomic_counter_value (g_workers_pkts_out)); assert (total_stats.backend.msg_out == (unsigned) zmq_atomic_counter_value (g_clients_pkts_out)); }
void test_zap_unsuccessful (void *ctx_, char *my_endpoint_, void *server_, void *server_mon_, int expected_server_event_, int expected_server_value_, socket_config_fn socket_config_, void *socket_config_data_, void **client_mon_ = NULL, int expected_client_event_ = 0, int expected_client_value_ = 0) { int server_events_received = expect_new_client_bounce_fail_and_count_monitor_events ( ctx_, my_endpoint_, server_, socket_config_, socket_config_data_, client_mon_, server_mon_, expected_server_event_, expected_server_value_, expected_client_event_, expected_client_value_); // there may be more than one ZAP request due to repeated attempts by the // client (actually only in case if ZAP status code 300) assert (server_events_received == 0 || 1 <= zmq_atomic_counter_value (zap_requests_handled)); }