text stringlengths 14 100k | source stringclasses 1
value | repo stringclasses 810
values | language stringclasses 13
values |
|---|---|---|---|
<|fim_suffix|>std::string ("wss://") << host () << std::string (":")
<< _address.port () << path ();
addr_ = os.str ();
return 0;
}
<|fim_prefix|>/* SPDX-License-Identifier: MPL-2.0 */
#include "precompiled.hpp"
#include <string>
#include <sstream>
#include "wss_address.hpp"
zmq::wss_address_t::wss_a... | fim | zeromq/libzmq | cpp |
<|fim_suffix|>dif
<|fim_prefix|>/* SPDX-License-Identifier: MPL-2.0 */
#ifndef __ZMQ_WSS_ADDRESS_HPP_INCLUDED__
#define __ZMQ_WSS_ADDRESS_HPP_INCLUDED__
#include "ws_address.hpp"
namespace zmq
{
class wss_address_t : public ws_address_t
{
public:
wss_address_t ();
wss_address_t (const sockaddr *sa_, sockle... | fim | zeromq/libzmq | cpp |
<|fim_prefix|>/* SPDX-License-Identifier: MPL-2.0 */
#include "precompiled.hpp"
#include "wss_engine.hpp"
static int verify_certificate_callback (gnutls_session_t session)
{
unsigned int status;
const char *hostname;
// read hostname
hostname = (const char *) gnutls_session_get_ptr (session);
in... | fim | zeromq/libzmq | cpp |
/* SPDX-License-Identifier: MPL-2.0 */
#ifndef __ZMQ_WSS_ENGINE_HPP_INCLUDED__
#define __ZMQ_WSS_ENGINE_HPP_INCLUDED__
#include <gnutls/gnutls.h>
#include "ws_engine.hpp"
#define WSS_BUFFER_SIZE 8192
namespace zmq
{
class wss_engine_t : public ws_engine_t
{
public:
wss_engine_t (fd_t fd_,
co... | fim | zeromq/libzmq | cpp |
<|fim_prefix|>/* SPDX-License-Identifier: MPL-2.0 */
#include "precompiled.hpp"
#include <string.h>
#include "xpub.hpp"
#include "pipe.hpp"
#include "err.hpp"
#include "msg.hpp"
#include "macros.hpp"
#include "generic_mtrie_impl.hpp"
zmq::xpub_t::xpub_t (class ctx_t *parent_, uint32_t tid_, int sid_) :
socket_ba... | fim | zeromq/libzmq | cpp |
/* SPDX-License-Identifier: MPL-2.0 */
#ifndef __ZMQ_XPUB_HPP_INCLUDED__
#define __ZMQ_XPUB_HPP_INCLUDED__
#include <deque>
#include "socket_base.hpp"
#include "session_base.hpp"
#include "mtrie.hpp"
#include "dist.hpp"
namespace zmq
{
class ctx_t;
class msg_t;
class pipe_t;
class io_thread_t;
class xpub_t : publi... | fim | zeromq/libzmq | cpp |
<|fim_prefix|>/* SPDX-License-Identifier: MPL-2.0 */
#include "precompiled.hpp"
#include <string.h>
#include "macros.hpp"
#include "xsub.hpp"
#include "err.hpp"
zmq::xsub_t::xsub_t (class ctx_t *parent_, uint32_t tid_, int sid_) :
socket_base_t (parent_, tid_, sid_),
_verbose_unsubs (false),
_has_message... | fim | zeromq/libzmq | cpp |
<|fim_prefix|>/* SPDX-License-Identifier: MPL-2.0 */
#ifndef __ZMQ_XSUB_HPP_INCLUDED__
#define __ZMQ_XSUB_HPP_INCLUDED__
#include "socket_base.hpp"
#include "session_base.hpp"
#include "dist.hpp"
#include "fq.hpp"
#ifdef ZMQ_USE_RADIX_TREE
#include "radix_tree.hpp"
#else
#include "trie.hpp"
#endif
namespace zmq
{
cl... | fim | zeromq/libzmq | cpp |
<|fim_prefix|>/* SPDX-License-Identifier: MPL-2.0 */
#ifndef __ZMQ_YPIPE_HPP_INCLUDED__
#define __ZMQ_YPIPE_HPP_INCLUDED__
#include "atomic_ptr.hpp"
#include "yqueue.hpp"
#include "ypipe_base.hpp"
namespace zmq
{
// Lock-free queue implementation.
// Only a single thread can read from the pipe at any specific mome... | fim | zeromq/libzmq | cpp |
<|fim_suffix|>
virtual bool unwrite (T *value_) = 0;
virtual bool flush () = 0;
virtual bool check_read () = 0;
virtual bool read (T *value_) = 0;
virtual bool probe (bool (*fn_) (const T &)) = 0;
};
}
#endif
<|fim_prefix|>
/* SPDX-License-Identifier: MPL-2.<|fim_middle|>0 */
#ifndef __ZMQ_YPIPE_B... | fim | zeromq/libzmq | cpp |
/* SPDX-License-Identifier: MPL-2.0 */
#ifndef __ZMQ_YPIPE_CONFLATE_HPP_INCLUDED__
#define __ZMQ_YPIPE_CONFLATE_HPP_INCLUDED__
#include "platform.hpp"
#include "dbuffer.hpp"
#include "ypipe_base.hpp"
namespace zmq
{
// Adapter for dbuffer, to plug it in instead of a queue for the sake
// of implementing the confla... | fim | zeromq/libzmq | cpp |
<|fim_suffix|>gin_chunk = allocate_chunk ();
alloc_assert (_begin_chunk);
_begin_pos = 0;
_back_chunk = NULL;
_back_pos = 0;
_end_chunk = _begin_chunk;
_end_pos = 0;
}
// Destroy the queue.
inline ~yqueue_t ()
{
while (true) {
if (_be... | fim | zeromq/libzmq | cpp |
<|fim_suffix|>ptions.routing_id_size);
errno_assert (rc == 0);
memcpy (msg.data (), options.routing_id, options.routing_id_size);
msg.set_flags (msg_t::more);
rc = session->write_zap_msg (&msg);
errno_assert (rc == 0);
// Mechanism frame
rc = msg.init_size (mechanism_length_);
errno_as... | fim | zeromq/libzmq | cpp |
<|fim_suffix|> methods from mechanism_t
status_t status () const ZMQ_FINAL;
int zap_msg_available () ZMQ_FINAL;
// zap_client_t methods
int receive_and_process_zap_reply () ZMQ_FINAL;
void handle_zap_status_code () ZMQ_FINAL;
// Current FSM state
state_t state;
private:
const sta... | fim | zeromq/libzmq | cpp |
<|fim_prefix|>/* SPDX-License-Identifier: MPL-2.0 */
// "Tell them I was a writer.
// A maker of software.
// A humanist. A father.
// And many things.
// But above all, a writer.
// Thank You. :)"
// - Pieter Hintjens
#include "precompiled.hpp"
#define ZMQ_TYPE_UNSAFE
#include "macros.hpp"
#include "poller.hp... | fim | zeromq/libzmq | cpp |
<|fim_prefix|>/* SPDX-License-Identifier: MPL-2.0 */
#ifndef __ZMQ_DRAFT_H_INCLUDED__
#define __ZMQ_DRAFT_H_INCLUDED__
/******************************************************************************/
/* These functions are DRAFT and disabled in stable releases, and subject to */
/* change at ANY time until declared... | fim | zeromq/libzmq | c |
<|fim_suffix|>n base 256 (binary)
value = value * 256 + data_[byte_nbr++];
if (byte_nbr % 4 == 0) {
// Output value in base 85
unsigned int divisor = 85 * 85 * 85 * 85;
while (divisor) {
dest_[char_nbr++] = encoder[value / divisor % 85];
... | fim | zeromq/libzmq | cpp |
<|fim_suffix|> + msg_t::ping_cmd_name_size,
static_cast<uint8_t *> (msg_->data ()) + ping_ttl_len,
context_len);
_next_msg = static_cast<int (stream_engine_base_t::*) (msg_t *)> (
&zmtp_engine_t::produce_pong_message);
out_event ();
... | fim | zeromq/libzmq | cpp |
<|fim_prefix|>/* SPDX-License-Identifier: MPL-2.0 */
#ifndef __ZMQ_ZMTP_ENGINE_HPP_INCLUDED__
#define __ZMQ_ZMTP_ENGINE_HPP_INCLUDED__
#include <stddef.h>
#include "fd.hpp"
#include "i_engine.hpp"
#include "io_object.hpp"
#include "i_encoder.hpp"
#include "i_decoder.hpp"
#include "options.hpp"
#include "socket_base.... | fim | zeromq/libzmq | cpp |
<|fim_suffix|>SS_ERRNO (zmq_connect (sc, test_endpoint));
bounce (sb, sc);
test_context_socket_close (sc);
test_context_socket_close (sb);
}
void test_empty_abstract_name ()
{
void *sb = test_context_socket (ZMQ_DEALER);
TEST_ASSERT_FAILURE_ERRNO (EINVAL, zmq_bind (sb, test_endpoint_empty));
... | fim | zeromq/libzmq | cpp |
<|fim_suffix|>URE_ERRNO (EINVAL, zmq_bind (sb, "tipc://<1.2.3:123123>"));
// Test connecting to random identity, should fail
TEST_ASSERT_FAILURE_ERRNO (EINVAL, zmq_connect (sb, "tipc://<*>"));
// Clean up
test_context_socket_close (sb);
}
int main ()
{
setup_test_environment ();
if (!is_tip... | fim | zeromq/libzmq | cpp |
<|fim_suffix|>to this file,
* that they are short-lived so they do not trigger timeouts in the
* CI build environments.
*/
#include "testutil.hpp"
#include "testutil_unity.hpp"
void setUp ()
{
}
void tearDown ()
{
}
void test_version ()
{
int major, minor, patch;
zmq_version (&major, &minor, &patch);
... | fim | zeromq/libzmq | cpp |
/* SPDX-License-Identifier: MPL-2.0 */
#include "testutil.hpp"
#include "testutil_unity.hpp"
#include <unity.h>
#include <string.h>
void setUp ()
{
}
void tearDown ()
{
}
void test_app_meta_reqrep ()
{
void *ctx;
zmq_msg_t msg;
void *rep_sock, *req_sock;
char connect_address[MAX_SOCKET_STRING];
... | fim | zeromq/libzmq | cpp |
<|fim_prefix|>/* SPDX-License-Identifier: MPL-2.0 *<|fim_suffix|>ST_ASSERT_EQUAL_INT (2, zmq_atomic_counter_inc (counter));
TEST_ASSERT_EQUAL_INT (3, zmq_atomic_counter_value (counter));
TEST_ASSERT_EQUAL_INT (1, zmq_atomic_counter_dec (counter));
TEST_ASSERT_EQUAL_INT (1, zmq_atomic_counter_dec (counter));... | fim | zeromq/libzmq | cpp |
<|fim_suffix|>));
TEST_ASSERT_EQUAL_INT (EINVAL, zmq_errno ());
}
// call zmq_z85_encode, then zmq_z85_decode, and compare the results with the original
template <size_t SIZE>
void test__zmq_z85_encode__zmq_z85_decode__roundtrip (
const uint8_t (&test_data_)[SIZE])
{
char test_data_z85[SIZE * 5 / 4 + 1];
... | fim | zeromq/libzmq | cpp |
<|fim_suffix|>ct_success (sb, "buzz", 0);
test_context_socket_close (sc);
test_context_socket_close (sb);
}
int main (void)
{
setup_test_environment ();
UNITY_BEGIN ();
RUN_TEST (test_x);
return UNITY_END ();
}
<|fim_prefix|>/* SPDX-License-Identifier: MPL-2.0 */
#include "testutil.hpp"
#inc... | fim | zeromq/libzmq | cpp |
<|fim_prefix|>/* SPDX-License-Identifier: MPL-2.0 */
#ifdef ZMQ_USE_FUZZING_ENGINE
#include <fuzzer/FuzzedDataProvider.h>
#endif
#include <string.h>
#include "testutil.hpp"
#include "testutil_security.hpp"
// Test that the ZMTP engine handles invalid handshake when binding
// https://rfc.zeromq.org/spec/37/
extern ... | fim | zeromq/libzmq | cpp |
<|fim_prefix|>/* SPDX-License-Identifier: MPL-2.0 */
#ifdef ZMQ_USE_FUZZING_ENGINE
#include <fuzzer/FuzzedDataProvider.h>
#endif
#include <string>
#include "testutil.hpp"
#include "testutil_unity.hpp"
#ifndef PATH_MAX
#define PATH_MAX 1024
#endif
// Test that zmq_bind can handle malformed strings
extern "C" int LL... | fim | zeromq/libzmq | cpp |
<|fim_prefix|>/* SPDX-License-Identifier: MPL-2.0 */
#ifdef ZMQ_USE_FUZZING_ENGINE
#include <fuzzer/FuzzedDataProvider.h>
#endif
#include "testutil.hpp"
#include "testutil_unity.hpp"
// Test that the ZMTP engine handles invalid handshake when binding
// https://rfc.zeromq.org/spec/37/
extern "C" int LLVMFuzzerTestOn... | fim | zeromq/libzmq | cpp |
/* SPDX-License-Identifier: MPL-2.0 */
#include "testutil.hpp"
#include "testutil_unity.hpp"
SETUP_TEARDOWN_TESTCONTEXT
void test_x ()
{
void *sock = test_context_socket (ZMQ_PUB);
TEST_ASSERT_SUCCESS_ERRNO (
zmq_connect (sock, "tcp://127.0.0.1:0;localhost:1234"));
TEST_ASSERT_SUCCESS_ERRNO (
... | fim | zeromq/libzmq | cpp |
<|fim_prefix|>/* SPDX-License-Identifier: MPL-2.0 */
#ifdef ZMQ_USE_FUZZING_ENGINE
#include <fuzzer/FuzzedDataProvider.h>
#endif
#include "testutil.hpp"
#include "testutil_unity.hpp"
/<|fim_suffix|>t (77);
while (num_cases-- > 0) {
TEST_ASSERT_SUCCESS_ERRNO (
LLVMFuzzerTestOneInput (data[num_c... | fim | zeromq/libzmq | cpp |
<|fim_prefix|>/* SPDX-License-Identifier: MPL-2.0 */
#ifdef ZMQ_USE_FUZZING_ENGINE
#include <fuzzer/FuzzedDataProvider.h>
#endif
#include "testutil.hpp"
#include "testutil_unity.hpp"
// Test that the ZMTP WebSocket engine handles invalid handshake when connecting
// https://rfc.zeromq.org/spec/45/
extern "C" int LLV... | fim | zeromq/libzmq | cpp |
<|fim_suffix|>ND ();
}
<|fim_prefix|>/* SPDX-License-Identifier: MPL-2.0 */
#include "testutil.hpp"
#include "tes<|fim_middle|>tutil_unity.hpp"
SETUP_TEARDOWN_TESTCONTEXT
void test_busy_poll ()
{
// Create a socket
void *socket = test_context_socket (ZMQ_DEALER);
// set socket ZMQ_BUSY_POLL options
... | fim | zeromq/libzmq | cpp |
<|fim_suffix|>_TRUE (zmq_has ("gssapi"));
#else
TEST_ASSERT_TRUE (!zmq_has ("gssapi"));
#endif
#if defined(ZMQ_HAVE_VMCI)
TEST_ASSERT_TRUE (zmq_has ("vmci"));
#else
TEST_ASSERT_TRUE (!zmq_has ("vmci"));
#endif
#if defined(ZMQ_BUILD_DRAFT_API)
TEST_ASSERT_TRUE (zmq_has ("draft"));
#else
TEST_ASSERT... | fim | zeromq/libzmq | cpp |
<|fim_prefix|>/* SPDX-License-Identifier: MPL-2.0 */
#include "testutil.hpp"
#include "testutil_unity.hpp"
#include <unity.h>
void *sb;
void *sc;
void setUp ()
{
setup_test_context ();
sb = test_context_socket (ZMQ_CHANNEL);
TEST_ASSERT_SUCCESS_ERRNO (zmq_bind (sb, "inproc://a"));
sc = test_contex... | fim | zeromq/libzmq | cpp |
<|fim_prefix|>/* SPDX-License-Identifier: MPL-2.0 */
#include "testutil.hpp"
#include "testutil_unity.hpp"
SETUP_TEARDOWN_TESTCONTEXT
void create_inproc_client_server_pair (void **server_, void **client_)
{
*server_ = test_context_socket (ZMQ_SERVER);
*client_ = test_context_socket (ZMQ_CLIENT);
TEST_AS... | fim | zeromq/libzmq | cpp |
<|fim_prefix|>/* SPDX-License-Identifier: MPL-2.0 */
#include "testutil.hpp"
#include "testutil_unity.hpp"
SETUP_TEARDOWN_TESTCONTEXT
void test_conflate ()
{
char my_endpoint[MAX_SOCKET_STRING];
int rc;
void *s_in = test_context_socket (ZMQ_PULL);
int conflate = 1;
TEST_ASSERT_SUCCESS_ERRNO (
... | fim | zeromq/libzmq | cpp |
<|fim_suffix|> while (-1 != zmq_msg_recv (&msg, client, ZMQ_DONTWAIT)) {
zmq_msg_close (&msg);
zmq_msg_init (&msg);
}
close (server_accept);
close (server);
test_context_socket_close_zero_linger (client);
test_context_socket_close_zero_linger (client_mon);
teardown_test_conte... | fim | zeromq/libzmq | cpp |
<|fim_suffix|>the I/O thread
do {
rc = zmq_send (frontend, "Hello", 5, ZMQ_DONTWAIT);
TEST_ASSERT_TRUE (rc == 5 || (rc == -1 && zmq_errno () == EAGAIN));
} while (rc == 5);
// Recreate backend socket
backend = test_context_socket (ZMQ_DEALER);
TEST_ASSERT_SUCCESS_ERRNO (
zmq_... | fim | zeromq/libzmq | cpp |
/* SPDX-License-Identifier: MPL-2.0 */
#ifdef ZMQ_USE_FUZZING_ENGINE
#include <fuzzer/FuzzedDataProvider.h>
#endif
#include <string>
#include "testutil.hpp"
#include "testutil_unity.hpp"
// Test that zmq_connect can handle malformed strings
extern "C" int LLVMFuzzerTestOneInput (const uint8_t *data, size_t size)
{
... | fim | zeromq/libzmq | cpp |
<|fim_suffix|>ata[num_cases]);
}
free (data);
free (len);
}
int main (int argc, char **argv)
{
LIBZMQ_UNUSED (argc);
LIBZMQ_UNUSED (argv);
setup_test_environment ();
UNITY_BEGIN ();
RUN_TEST (test_connect_null_fuzzer);
return UNITY_END ();
}
#endif
<|fim_prefix|>/* SPDX-License-... | fim | zeromq/libzmq | cpp |
<|fim_suffix|>ST (test_invalid_proto_fails);
return UNITY_END ();
}
<|fim_prefix|>/* SPDX-License-Identifier: MPL-2.0 */
#include "testutil.hpp"
#include "testutil_unity.hpp"
#include <unity.h>
void *sock;
void setUp ()
{
setup_test_context ();
sock = test_context_socket (ZMQ_PUB);
}
void tearDown ()
... | fim | zeromq/libzmq | cpp |
<|fim_prefix|>/* SPDX-License-Identifier: MPL-2.0 */
#include "testutil.hpp"
#include "testutil_unity.hpp"
#include <string.h>
SETUP_TEARDOWN_TESTCONTEXT
const char *rconn1routing_id = "conn1";
const char *x_routing_id = "X";
const char *y_routing_id = "Y";
const char *z_routing_id = "Z";
void test_stream_2_stream... | fim | zeromq/libzmq | cpp |
<|fim_prefix|>/* SPDX-License-Identifier: MPL-2.0 */
#ifdef ZMQ_USE_FUZZING_ENGINE
#include <fuzzer/FuzzedDataProvider.h>
#endif
#include "testutil.hpp"
#include "testutil_unity.hpp"
// Test that the ZMTP engine handles invalid handshake when connecting
// https://rfc.zeromq.org/spec/37/
extern "C" int LLVMFuzzerTes... | fim | zeromq/libzmq | cpp |
/* SPDX-License-Identifier: MPL-2.0 */
#ifdef ZMQ_USE_FUZZING_ENGINE
#include <fuzzer/FuzzedDataProvider.h>
#endif
#include "testutil.hpp"
#include "testutil_unity.hpp"
// Test that the ZMTP WebSocket engine handles invalid handshake when connecting
// https://rfc.zeromq.org/spec/45/
extern "C" int LLVMFuzzerTestOne... | fim | zeromq/libzmq | cpp |
<|fim_suffix|>counter_destroy (&poller_test_data.counter);
#else
TEST_IGNORE_MESSAGE ("libzmq without zmq_poller_* support, ignoring test");
#endif
}
void test_poller_exists_with_socket_on_zmq_ctx_term_thread_safe_socket ()
{
#ifdef ZMQ_BUILD_DRAFT_API
test_poller_exists_with_socket_on_zmq_ctx_term (ZMQ_CLIENT... | fim | zeromq/libzmq | cpp |
<|fim_prefix|>/* SPDX-License-Identifier: MPL-2.0 */
#include <limits>
#include "testutil.hpp"
#include "testutil_unity.hpp"
SETUP_TEARDOWN_TESTCONTEXT
#define WAIT_FOR_BACKGROUND_THREAD_INSPECTION (0)
#ifdef ZMQ_HAVE_LINUX
#include <sys/time.h>
#include <sys/resource.h>
#include <unistd.h> // for sleep()
#include ... | fim | zeromq/libzmq | cpp |
/* SPDX-License-Identifier: MPL-2.0 */
#include "testutil.hpp"
#include "testutil_unity.hpp"
#include <stdlib.h>
#include <string.h>
SETUP_TEARDOWN_TESTCONTEXT
void str_send_to (void *s_, const char *content_, const char *address_)
{
send_string_expect_success (s_, address_, ZMQ_SNDMORE);
send_string_expect... | fim | zeromq/libzmq | cpp |
<|fim_suffix|>OCKET_STRING];
void *sb = test_context_socket (ZMQ_PAIR);
TEST_ASSERT_SUCCESS_ERRNO (zmq_setsockopt (sb, ZMQ_TOS, &tos, tos_size));
bind_loopback_ipv4 (sb, my_endpoint, sizeof (my_endpoint));
TEST_ASSERT_SUCCESS_ERRNO (zmq_getsockopt (sb, ZMQ_TOS, &o_tos, &tos_size));
TEST_ASSERT_EQU... | fim | zeromq/libzmq | cpp |
<|fim_prefix|>/* SPDX-License-Identifier: MPL-2.0 */
#include "testutil.hpp"
#include "testutil_unity.hpp"
#include <string.h>
SETUP_TEARDOWN_TESTCONTEXT
/// Initialize a zeromq message with a given null-terminated string
#define ZMQ_PREPARE_STRING(msg, data, size) \
TEST_ASSE... | fim | zeromq/libzmq | cpp |
<|fim_suffix|>ss (server, "D", 0);
// Clean up.
test_context_socket_close (server);
}
void test_tcp ()
{
test ("tcp://127.0.0.1:5569");
}
void test_inproc ()
{
test ("inproc://disconnect-msg");
}
void test_inproc_disconnect ()
{
const char *address = "inproc://disconnect-msg";
// Create ... | fim | zeromq/libzmq | cpp |
/* SPDX-License-Identifier: MPL-2.0 */
#include "testutil.hpp"
#include "testutil_unity.hpp"
#include <unistd.h>
#include <grp.h>
SETUP_TEARDOWN_TESTCONTEXT
static void bounce_fail (void *server_, void *client_)
{
const char *content = "12345678ABCDEFGH12345678abcdefgh";
char buffer[32];
// Send messa... | fim | zeromq/libzmq | cpp |
<|fim_suffix|>;
}
test_context_socket_close (pull);
}
#endif
}
int main (void)
{
setup_test_environment ();
UNITY_BEGIN ();
RUN_TEST (test_fork);
return UNITY_END ();
}
<|fim_prefix|>/* SPDX-License-Identifier: MPL-2.0 */
#include "testutil.hpp"
#include "testutil_unity.hpp"
#inc... | fim | zeromq/libzmq | cpp |
<|fim_prefix|>/* SPDX-License-Identifier: MPL-2.0 */
#include "testutil.hpp"
#include "testutil_unity.hpp"
#include <string.h>
SETUP_TEARDOWN_TESTCONTEXT
void test_getsockopt_memset ()
{
int64_t more;
size_t more_size = sizeof (more);
void *sb = test_co<|fim_suffix|>e (sc);
test_context_socket_clos... | fim | zeromq/libzmq | cpp |
<|fim_suffix|>ond_define); \
} \
void test_heartbeat_notimeout_##first##_##second##_with_curve () \
{ \
test_heartbeat_notimeout (1,... | fim | zeromq/libzmq | cpp |
<|fim_prefix|>/* SPDX-License-Identifier: MPL-2.0 */
#include "testutil.hpp"
#include "testutil_unity.hpp"
SETUP_TEARDOWN_TESTCONTEXT
void test (const char *address)
{
// Create a router
void *router = test_context_socket (ZMQ_ROUTER);
char my_endpoint[MAX_SOCKET_STRING];
// set router socket opti... | fim | zeromq/libzmq | cpp |
<|fim_suffix|>sockopt (client, ZMQ_HELLO_MSG, "HELLO", 5));
TEST_ASSERT_SUCCESS_ERRNO (
zmq_setsockopt (client, ZMQ_HICCUP_MSG, "HICCUP", 6));
TEST_ASSERT_SUCCESS_ERRNO (zmq_connect (client, address));
// Receive the hello message from client
recv_string_expect_success (server, "HELLO", 0);
... | fim | zeromq/libzmq | cpp |
<|fim_suffix|> until we block
int send_count = 0;
while (send_count < MAX_SENDS
&& zmq_send (bind_socket, NULL, 0, ZMQ_DONTWAIT) == 0)
++send_count;
// Close bind
test_context_socket_close (bind_socket);
/* TODO Can't currently do connect without then wiring up a bind as things ... | fim | zeromq/libzmq | cpp |
<|fim_suffix|>nation message
while (is_termination == 0)
recv_count += receive (sub_socket, &is_termination);
// remove termination message from the count:
recv_count--;
TEST_ASSERT_EQUAL_INT (send_count, recv_count);
// Clean up
test_context_socket_close (sub_socket);
test_contex... | fim | zeromq/libzmq | cpp |
<|fim_prefix|>/* SPDX-License-Identifier: MPL-2.0 */
#include "testutil.hpp"
#include "testutil_unity.hpp"
SETUP_TEARDOWN_TESTCONTEXT
void test_immediate_1 ()
{
int val;
int rc;<|fim_suffix|> seen++;
}
// TODO: this fails ~1% of the runs on OBS but it does not seem to be reproducible anywhere els... | fim | zeromq/libzmq | cpp |
<|fim_suffix|> zmq_threadclose (threads[i]);
}
test_context_socket_close (bind_socket);
}
void test_simultaneous_connect_bind_threads ()
{
const unsigned int no_of_times = 50;
void *threads[no_of_times * 2];
void *thr_args[no_of_times];
char endpts[no_of_times][20];
// Set up thread a... | fim | zeromq/libzmq | cpp |
<|fim_suffix|> send_string_expect_success (router_socket, "b", 0);
// Check whether we've got the valid reply.
recv_string_expect_success (req_socket, "b", 0);
// Tear down the wiring.
test_context_socket_close (router_socket);
test_context_socket_close (req_socket);
}
int main ()
{
setup_t... | fim | zeromq/libzmq | cpp |
<|fim_prefix|>/* SPDX-License-Identifier: MPL-2.0 */
#include "testutil.hpp"
#include "testutil_unity.hpp"
#include <stdlib.h>
#include <string.h>
SETUP_TEARDOWN_TESTCONTEXT
// XSI vector I/O
#if defined ZMQ_HAVE_UIO
#include <sys/uio.h>
#else
struct iovec
{
void *iov_base;
size_t iov_len;
};
#endif
static... | fim | zeromq/libzmq | cpp |
/* SPDX-License-Identifier: MPL-2.0 */
#include "testutil.hpp"
#include "testutil_unity.hpp"
SETUP_TEARDOWN_TESTCONTEXT
void test_ipc_wildcard ()
{
void *sb = test_context_socket (ZMQ_PAIR);
char endpoint[200];
bind_loopback_ipc (sb, endpoint, sizeof endpoint);
void *sc = test_context_socket (ZMQ_PA... | fim | zeromq/libzmq | cpp |
<|fim_prefix|>/* SPDX-License-Identifier: MPL-2.0 */
#include "testutil.hpp"
#include "testutil_unity.hpp"
SETUP_TEARDOWN_TESTCONTEXT
// Issue 566 describes a problem in libzmq v4.0.0 where a dealer to router
// connection would fail randomly. The test works when the two sockets are
// on the same context, and fa... | fim | zeromq/libzmq | cpp |
<|fim_suffix|>nment ();
UNITY_BEGIN ();
RUN_TEST (test_last_endpoint);
return UNITY_END ();
}
<|fim_prefix|>/* SPDX-License-Identifier: MPL-2.0 */
#include "testutil.hpp"
#include "testutil_unity.hpp"
SETUP_TEARDOWN_TESTCONTEXT
static void do_bind_and_verify (void *s_, const char *endpoint_)
{
TEST_... | fim | zeromq/libzmq | cpp |
<|fim_suffix|>
}
// We may stop sooner if system has fewer available sockets
TEST_ASSERT_LESS_OR_EQUAL (ZMQ_MAX_SOCKETS_DFLT, sockets.size ());
// Further calls to zmq_socket should return NULL
for (unsigned int i = 0; i < 10; ++i) {
TEST_ASSERT_NULL (zmq_socket (get_test_context (), ZMQ_... | fim | zeromq/libzmq | cpp |
<|fim_suffix|>.zap.01"));
void *zap_thread = zmq_threadstart (&zap_handler, handler);
void *server = test_context_socket (ZMQ_DEALER);
void *client = test_context_socket (ZMQ_DEALER);
TEST_ASSERT_SUCCESS_ERRNO (
zmq_setsockopt (server, ZMQ_ZAP_DOMAIN, "DOMAIN", 6));
bind_loopback_ipv4 (server... | fim | zeromq/libzmq | cpp |
<|fim_prefix|>/* SPDX-License-Identifier: MPL-2.0 */
#include "testutil.hpp"
#include "testutil_unity.hpp"
#include <stdlib.h>
#include <string.h>
SETUP_TEARDOWN_TESTCONTEXT
// Read one event off the monitor socket; return value and address
// by reference, if not null, and event number by value. Returns -1
// i... | fim | zeromq/libzmq | cpp |
<|fim_suffix|>ERT_NOT_NULL (queue_stat);
TEST_ASSERT_EQUAL_INT (i == 0 ? 0 : send_hwm, queue_stat[0]);
TEST_ASSERT_EQUAL_INT (0, queue_stat[1]);
free (push_local_address);
free (push_remote_address);
free (queue_stat);
}
// Close client and server
test_context_socke... | fim | zeromq/libzmq | cpp |
<|fim_suffix|>re.
test_context_socket_close (router);
test_context_socket_close (dealer);
}
int main (void)
{
setup_test_environment ();
UNITY_BEGIN ();
RUN_TEST (test_msg_init_ffn);
return UNITY_END ();
}
<|fim_prefix|>/* SPDX-License-Identifier: MPL-2.0 */
#include "testutil.hpp"
#include "... | fim | zeromq/libzmq | cpp |
<|fim_prefix|>/* SPDX-License-Identifier: MPL-2.0 */
#include "testutil.hpp"
#include "testutil_unity.hpp"
SETUP_TEARDOWN_TESTCONTEXT
void test_more ()
{
// Create the infrastructure
void *sb = test_context_socket (ZMQ_ROUTER);
TEST_ASSERT_SUCCESS_ERRNO (zmq_bind (sb, "inproc://a"));
void *sc = tes... | fim | zeromq/libzmq | cpp |
<|fim_suffix|>ITY_END ();
}
<|fim_prefix|>/* SPDX-License-Identifier: MPL-2.0 */
#include "testutil.hpp"
#include "testutil_unity.hpp"
#include <string.h>
SETUP_TEARDOWN_TESTCONTEXT
void test_msg_init ()
{
zmq_msg_t msg;
TEST_ASSERT_SUCCESS_ERRNO (zmq_msg_init (&msg));
TEST_ASSERT_EQUAL_INT (0, zmq_msg_... | fim | zeromq/libzmq | cpp |
<|fim_suffix|> to do with pair or inproc, and belongs somewhere else
void test_zmq_send_const ()
{
TEST_ASSERT_EQUAL_INT (3, TEST_ASSERT_SUCCESS_ERRNO (
zmq_send_const (sb, "foo", 3, ZMQ_SNDMORE)));
TEST_ASSERT_EQUAL_INT (
6, TEST_ASSERT_SUCCESS_ERRNO (zmq_send_const (sb, "... | fim | zeromq/libzmq | cpp |
<|fim_prefix|>/* SPDX-License-Identifier: MPL-2.0 */
#include "testutil.hpp"
#include "testutil_unity.hpp"
#inclu<|fim_suffix|> void *sb = test_context_socket (ZMQ_PAIR);
// TODO ENAMETOOLONG is not listed in the errors returned by zmq_bind,
// should this be EINVAL?
TEST_ASSERT_FAILURE_ERRNO (ENAMETOO... | fim | zeromq/libzmq | cpp |
<|fim_prefix|>/* SPDX-License-Identifier: MPL-2.0 */
#include "testutil.hpp"
#include "testutil_unity.hpp"
#include <string.h>
#if defined _WIN32
#include "../src/windows.hpp"
#endif
SETUP_TEARDOWN_TESTCONTEXT
typedef void (*extra_func_t) (void *socket_);
#ifdef ZMQ_BUILD_DRAFT
void set_sockopt_fastpath (void *so... | fim | zeromq/libzmq | cpp |
<|fim_suffix|>oint;
int rc = zmq_bind (sb, "tcp://127.0.0.1:*");
if (rc < 0 && errno == EOPNOTSUPP)
TEST_IGNORE_MESSAGE ("SO_BINDTODEVICE not supported");
TEST_ASSERT_SUCCESS_ERRNO (rc);
TEST_ASSERT_SUCCESS_ERRNO (
zmq_getsockopt (sb, ZMQ_LAST_ENDPOINT, my_endpoint, &my_endpoint_length));
... | fim | zeromq/libzmq | cpp |
<|fim_suffix|>n");
return 77;
}
UNITY_BEGIN ();
RUN_TEST (test_roundtrip);
return UNITY_END ();
}
<|fim_prefix|>/* SPDX-License-Identifier: MPL-2.0 */
#include <stdio.h>
#include "testutil.hpp"
#include "testutil_unity.hpp"
SETUP_TEARDOWN_TESTCONTEXT
void test_roundtrip ()
{
void *sb = t... | fim | zeromq/libzmq | cpp |
<|fim_prefix|>/* SPDX-License-Identifier: MPL-2.0 */
#include <string>
#include <sstream>
#include <vmci_sockets.h>
#include "testutil.hpp"
#include "testutil_unity.hpp"
SETUP_TEARDOWN_TESTCONTEXT
void test_pair_vmci ()
{
unsigned int cid = VMCISock_GetLocalCID ();
if (cid == VMADDR_CID_ANY)
TEST_IG... | fim | zeromq/libzmq | cpp |
<|fim_prefix|>/* SPDX-License-Identifier: MPL-2.0 */
#include "t<|fim_suffix|>q_bind (sb, endpoint.c_str ());
if (rc < 0 && (errno == EAFNOSUPPORT || errno == EPROTONOSUPPORT))
TEST_IGNORE_MESSAGE ("VSOCK not supported");
TEST_ASSERT_SUCCESS_ERRNO (rc);
void *sc = test_context_socket (ZMQ_PAIR);
... | fim | zeromq/libzmq | cpp |
<|fim_suffix|>CESS_ERRNO (
zmq_msg_set_routing_id (&msg, peer2_routing_id));
int rc = zmq_msg_send (&msg, peer1, 0);
TEST_ASSERT_EQUAL_INT (1, rc);
}
{
zmq_msg_t msg;
TEST_ASSERT_SUCCESS_ERRNO (zmq_msg_init (&msg));
int rc = zmq_msg_recv (&msg, peer2, 0);
... | fim | zeromq/libzmq | cpp |
<|fim_prefix|>/* SPDX-License-Identifier: MPL-2.0 */
#include "testutil.hpp"
#include "testutil_unity.hpp"
#include <string.h>
SETUP_TEAR<|fim_suffix|>))[0] = 'X';
TEST_ASSERT_SUCCESS_ERRNO (
zmq_msg_set_routing_id (&msg, peer1_routing_id));
int rc = zmq_msg_send (&msg, peer2, 0);
T... | fim | zeromq/libzmq | cpp |
/* SPDX-License-Identifier: MPL-2.0 */
#include "testutil.hpp"
#include "testutil_unity.hpp"
#include <limits.h>
#ifndef _WIN32
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <unistd.h>
#endif
SETUP_TEARDOWN_TESTCONTEXT
fd_t get_fd (void *socket_)
{
fd_t fd;
size_t fd_size ... | fim | zeromq/libzmq | cpp |
<|fim_suffix|> send_string_expect_success (server, "Hello", 0);
recv_string_expect_success (client, "Hello", 0);
test_context_socket_close (server);
test_context_socket_close (client);
}
int main ()
{
setup_test_environment ();
UNITY_BEGIN ();
RUN_TEST (test_probe_router_router);
RUN_... | fim | zeromq/libzmq | cpp |
<|fim_suffix|>{
TEST_ASSERT_SUCCESS_ERRNO (zmq_close (endpoint_receivers[i]));
}
}
// Each worker task works on one request at a time and sends a random number
// of replies back, with random delays between replies:
// The comments in the first column, if suppressed, makes it a poller version
static void ... | fim | zeromq/libzmq | cpp |
<|fim_prefix|>/* SPDX-License-Identifier: MPL-2.0 */
#include "testutil.hpp"
#include "testutil_unity.hpp"
#include <string.h>
#include <unity.h>
#include <assert.h>
#include <unistd.h>
//
// Asynchronous proxy test using ZMQ_XPUB_NODROP and HWM:
//
// Topology:
//
// XPUB SUB
// | ... | fim | zeromq/libzmq | cpp |
<|fim_prefix|>/* SPDX-License-Identifier: MPL-2.0 */
#include "testutil.hpp"
#include "testutil_unity.hpp"
#include <stdlib.h>
void setUp ()
{
setup_test_context ();
}
// This is our server task.
// It runs a proxy with a single REP socket as both frontend and backend.
void server_task (void * /*unused_*/)
{
... | fim | zeromq/libzmq | cpp |
<|fim_suffix|>le
// one request at a time but one client can talk to multiple workers at
// once.
static void server_worker (void * /*unused_*/);
void server_task (void * /*unused_*/)
{
// Frontend socket talks to clients over TCP
char my_endpoint[MAX_SOCKET_STRING];
void *frontend = zmq_socket (get_test_... | fim | zeromq/libzmq | cpp |
<|fim_suffix|>k, NULL);
// Control socket receives terminate command from main over inproc
void *control = test_context_socket (ZMQ_REP);
TEST_ASSERT_NOT_NULL (control);
TEST_ASSERT_SUCCESS_ERRNO (zmq_bind (control, "inproc://control"));
char *my_endpoint = s_recv (control);
TEST_ASSERT_NOT_NUL... | fim | zeromq/libzmq | cpp |
<|fim_prefix|>/* SPDX-License-Identifier: MPL-2.0 */
#include "testutil.hpp"
#include "testutil_unity.hpp"
#include <string.h>
SETUP_TEARDOWN_TESTCONTEXT
void test ()
{
// Create a publisher
void *pub = test_context_socket (ZMQ_PUB);
TEST_ASSERT_SUCCESS_ERRNO (zmq_bind (pub, "inproc://soname"));
/... | fim | zeromq/libzmq | cpp |
<|fim_suffix|>ate a subscriber
void *subscriber = test_context_socket (ZMQ_SUB);
TEST_ASSERT_SUCCESS_ERRNO (zmq_connect (subscriber, my_endpoint));
// Subscribe to all messages.
TEST_ASSERT_SUCCESS_ERRNO (
zmq_setsockopt (subscriber, ZMQ_SUBSCRIBE, "", 0));
// Wait a bit till the subscript... | fim | zeromq/libzmq | cpp |
<|fim_suffix|> RUN_TEST (test_nested_topic_prefixes);
return UNITY_END ();
}
<|fim_prefix|>/* SPDX-License-Identifier: MPL-2.0 */
#include "testutil.hpp"
#include "testutil_unity.hpp"
#include <string.h>
SETUP_TEARDOWN_TESTCONTEXT
void settle_subscriptions (void *skt)
{
// To kick the application thread,... | fim | zeromq/libzmq | cpp |
<|fim_prefix|>/* SPDX-License-Identifier: MPL-2.0 */
#include "testutil.hpp"
#include "testutil_unity.hpp"
#include <string.h>
#ifndef _WIN32
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <unistd.h>
#endif
// Helper macro to define the v4/v6 function pairs
#define MAKE_TEST_V4V6(_t... | fim | zeromq/libzmq | cpp |
<|fim_suffix|>string_expect_success (sb0, "42", 0);
recv_string_expect_success (sc, "42", 0);
test_context_socket_close (sb0);
TEST_ASSERT_SUCCESS_ERRNO (zmq_bind (sb1, my_endpoint));
send_string_expect_success (sb1, "42", 0);
recv_string_expect_success (sc, "42", 0);
test_context_socket_clo... | fim | zeromq/libzmq | cpp |
/* SPDX-License-Identifier: MPL-2.0 */
#include "testutil.hpp"
#include "testutil_unity.hpp"
SETUP_TEARDOWN_TESTCONTEXT
void test_reconnect_ivl_against_pair_socket (const char *my_endpoint_,
void *sb_)
{
void *sc = test_context_socket (ZMQ_PAIR);
int interval = -1... | fim | zeromq/libzmq | cpp |
<|fim_prefix|>/* SPDX-License-Identifier: MPL-2.0 */
#include <assert.h>
#include "testutil.hpp"
#include "testutil_unity.hpp"
#include "testutil_monitoring.hpp"
#include <unity.h>
// test behavior with (mostly) default values
void reconnect_default ()
{
// setup pub socket
void *pub = test_context_socket (Z... | fim | zeromq/libzmq | cpp |
/* SPDX-License-Identifier: MPL-2.0 */
#include "testutil.hpp"
#include "testutil_unity.hpp"
SETUP_TEARDOWN_TESTCONTEXT
void test_req_correlate ()
{
void *req = test_context_socket (ZMQ_REQ);
void *router = test_context_socket (ZMQ_ROUTER);
int enabled = 1;
TEST_ASSERT_SUCCESS_ERRNO (
zmq_sets... | fim | zeromq/libzmq | cpp |
<|fim_suffix|>);
// Send a reply to the first request - that should be discarded by the REQ
s_send_seq (rep[0], "WRONG", SEQ_END);
// Send the expected reply
s_send_seq (rep[1], "OK", SEQ_END);
s_recv_seq (req, "OK", SEQ_END);
// Another standard req-rep cycle, just to check
s_send_seq... | fim | zeromq/libzmq | cpp |
<|fim_prefix|>/* SPDX-License-Identifier: MPL-2.0 */
#include "testutil.hpp"
#include "testutil_unity.hpp"
SETUP_TEARDOWN_TESTCONTEXT
void test_roundtrip ()
{
char endpoint1[MAX_SOCKET_STRING];
char endpoint2[MAX_SOCKET_STRING];
// Create a req/rep device.
void *dealer = test_context_socket (ZMQ_DE... | fim | zeromq/libzmq | cpp |
<|fim_suffix|>
zmq_getsockopt (req, ZMQ_RCVMORE, &rcvmore, &sz));
TEST_ASSERT_FALSE (rcvmore);
// Clean up.
test_context_socket_close (req);
test_context_socket_close (rep);
test_context_socket_close (router);
test_context_socket_close (dealer);
}
int main ()
{
if (!is_tipc_availabl... | fim | zeromq/libzmq | cpp |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.