text stringlengths 14 100k | source stringclasses 1
value | repo stringclasses 810
values | language stringclasses 13
values |
|---|---|---|---|
<|fim_suffix|> RUN_TEST (test_roundtrip);
return UNITY_END ();
}
<|fim_prefix|>/* SPDX-License-Identifier: MPL-2.0 */
#include "testutil.hpp"
#include "testutil_unity.hpp"
SETUP_TEARDOWN_TESTCONTEXT
void test_roundtrip ()
{
void *sb = test_context_socket (ZMQ_REP);
TEST_ASSERT_SUCCESS_ERRNO (zmq_bind (s... | fim | zeromq/libzmq | cpp |
/* SPDX-License-Identifier: MPL-2.0 */
#include "testutil.hpp"
#include "testutil_unity.hpp"
#include <stdlib.h>
SETUP_TEARDOWN_TESTCONTEXT
void test_leak ()
{
char my_endpoint[256];
void *sb = test_context_socket (ZMQ_REP);
bind_loopback_ipc (sb, my_endpoint, sizeof my_endpoint);
void *sc = test_... | 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_single_connect (int ipv6_)
{
size_t len = MAX_SOCKET_STRING;
char my_endpoint[MAX_SOCKET_STRING];
void *sb = test_context_socket (ZMQ_REP);... | 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 ()
{
void *sb = test_context_socket (ZMQ_REP);
TEST_ASSERT_SUCCESS_ERRNO (zmq_bind (sb, "tipc://{5560,0,0}"));
void *sc = test_context_socket (ZMQ_REQ... | 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_reqrep_vmci ()
{
unsigned int cid = VMCISock_GetLocalCID ();
if (cid == VMADDR_CID_ANY)
TEST_... | fim | zeromq/libzmq | cpp |
<|fim_prefix|>/* SPDX-License-Identifier: MPL-2.0 */
#include "testutil.hpp"
#include "testutil_unity.hpp"
#include <string>
#include <sstream>
#include "sys/socket.h"
#include "linux/vm_sockets.h"
#include <sys/ioctl.h>
#include <fcntl.h>
SETUP_TEARDOWN_TESTCONTEXT
void test_reqrep_vsock ()
{
unsigned int cid ... | fim | zeromq/libzmq | cpp |
<|fim_prefix|>/* SPDX-License-Identifier: MPL-2.0 */
#include "testutil.hpp"
#include "testutil_unity.hpp"
SETUP_TEARDOWN_TESTCONTEXT
void test_with_handover ()
{
char my_endpoint[MAX_SOCKET_STRING];
void *router = test_context_socket (ZMQ_ROUTER);
bind_loopback_ipv4 (router, my_endpoint, sizeof my_endpo... | 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
#ifdef ZMQ_BUILD_DRAFT_API
bool send_msg_to_peer_if_ready (void *router_, const char *peer_routing_id_)
{
int rc = TEST_ASSERT_SUCCESS_MESSAGE_ERRNO (
z... | fim | zeromq/libzmq | cpp |
<|fim_suffix|>
void test_router_mandatory_hwm ()
{
if (TRACE_ENABLED)
fprintf (stderr, "Staring router mandatory HWM test ...\n");
char my_endpoint[MAX_SOCKET_STRING];
void *router = test_context_socket (ZMQ_ROUTER);
// Configure router socket to mandatory routing and set HWM and linger
int... | fim | zeromq/libzmq | cpp |
<|fim_suffix|> (void)
{
UNITY_BEGIN ();
RUN_TEST (test_router_mandatory_tipc);
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_router_mandatory_tipc ()
{
if (!is_... | 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_sockopt_router_notify ()
{
void *router = test_context_socket (ZMQ_ROUTER);
int opt_notify;
int opt_notify_read;
size_t opt_notify_read... | fim | zeromq/libzmq | cpp |
<|fim_prefix|>/* SPDX-License-Identif<|fim_suffix|>;
TEST_ASSERT_SUCCESS_ERRNO (
zmq_bind (scatter, "inproc://test-scatter-gather"));
TEST_ASSERT_SUCCESS_ERRNO (
zmq_connect (gather, "inproc://test-scatter-gather"));
TEST_ASSERT_SUCCESS_ERRNO (
zmq_connect (gather2, "inproc://test-scatt... | fim | zeromq/libzmq | cpp |
<|fim_prefix|>/* SPDX-License-Identifier: MPL-2.0 */
// TODO remove this workaround for handling libsodium
// To define SIZE_MAX with older compilers
#define __STDC_LIMIT_MACROS
#if defined ZMQ_CUSTOM_PLATFORM_HPP
#include "platform.hpp"
#else
#include "../src/platform.hpp"
#endif
#ifndef ZMQ_USE_LIBSODIUM
#define... | fim | zeromq/libzmq | cpp |
<|fim_prefix|>/* SPDX-License-Identifier: MPL-2.0 */
#include "testutil.hpp"
#include "testutil_monitoring.hpp"
#include "testutil_unity.hpp"
#include <stdlib.h>
#include <string.h>
// This test requires a KRB5 environment with the following
// service principal (substitute your host.domain and REALM):
//
// zm... | fim | zeromq/libzmq | cpp |
<|fim_prefix|>/* SPDX-License-Identifier: MPL-2.0 */
#include "testutil.hpp"
#include "testutil_unity.hpp"
SETUP_TEARDOWN_TESTCONTEXT
void test_no_zap_handler ()
{
// We first test client/server with a ZAP domain but with no handler
// If there is no handler, libzmq should ignore the ZAP option unless
... | fim | zeromq/libzmq | cpp |
<|fim_suffix|>d;
static void setup_zap_handler ()
{
// Spawn ZAP handler
// We create and bind ZAP socket in main thread to avoid case
// where child thread does not start up fast enough.
void *handler = zmq_socket (get_test_context (), ZMQ_REP);
TEST_ASSERT_SUCCESS_ERRNO (zmq_bind (handler, "in... | 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>
static void zap_handler (void *zap_)
{
// Process ZAP requests forever
while (true) {
char *version = s_recv (zap_);
if (!version)
br... | fim | zeromq/libzmq | cpp |
<|fim_prefix|>/* SPDX-License-Identifier: MPL-2.0 */
#include "testutil_security.hpp"
#include "testutil_unity.hpp"
SETUP_TEARDOWN_TESTCONTEXT
static void zap_handler_wrong_version (void * /*unused_*/)
{
zap_handler_generic (zap_wrong_version);
}
static void zap_handler_wrong_request_id (void * /*unused_*/)
{
... | fim | zeromq/libzmq | cpp |
<|fim_suffix|>
#endif
#else
TEST_IGNORE_MESSAGE ("libzmq without DRAFT support, ignoring "
"setsockopt_priority test");
#endif
}
int main ()
{
setup_test_environment ();
UNITY_BEGIN ();
RUN_TEST (test_setsockopt_tcp_recv_buffer);
RUN_TEST (test_setsockopt_tcp_send_buffer);... | fim | zeromq/libzmq | cpp |
<|fim_prefix|>/* SPDX-License-Identifier: MPL-2.0 */
#i<|fim_suffix|>t tdata = static_cast<const thread_data *> (data_);
void *socket = zmq_socket (get_test_context (), ZMQ_SUB);
TEST_ASSERT_SUCCESS_ERRNO (zmq_connect (socket, tdata->endpoint));
// Start closing the socket while the connecting process ... | fim | zeromq/libzmq | cpp |
<|fim_prefix|>/* SPDX-License-Identifier: MPL-2.0 */
#include "testutil.hpp"
#include "testutil_unity.hpp"
#include <pthread.h>
void setUp ()
{
}
void tearDown ()
{
}
<|fim_suffix|> pthread_create (&threads[i], NULL, worker, get_test_context ()));
}
for (i = 0; i != THREAD_COUNT; i++) {
... | fim | zeromq/libzmq | cpp |
<|fim_suffix|>T_ASSERT_EQUAL_INT (ENOTSOCK, errno); // TODO use EINVAL instead?
}
int main (void)
{
UNITY_BEGIN ();
RUN_TEST (test_zmq_socket_null_context);
RUN_TEST (test_zmq_close_null_socket);
RUN_TEST (test_zmq_setsockopt_null_socket);
RUN_TEST (test_zmq_getsockopt_null_socket);
RUN_TEST (t... | fim | zeromq/libzmq | cpp |
<|fim_suffix|>free (data[num_cases]);
}
free (data);
free (len);
}
int main (int argc, char **argv)
{
setup_test_environment ();
UNITY_BEGIN ();
RUN_TEST (test_socket_options_fuzzer);
return UNITY_END ();
}
#endif
<|fim_prefix|>/* SPDX-License-Identifier: MPL-2.0 */
#ifdef ZMQ_USE_FUZZI... | fim | zeromq/libzmq | cpp |
<|fim_prefix|>/* SPDX-License-Identifier: MPL-2.0 */
#include "testutil.hpp"
#include "testutil_unity.hpp"
SETUP_TEARDOWN_TESTCONTEXT
const int MAX_SENDS = 10000;
void test_change_before_connected ()
{
int rc;
void *bind_socket = test_context_socket (ZMQ_PUSH);
void *connect_socket = test_context_socke... | fim | zeromq/libzmq | cpp |
<|fim_suffix|>);
fprintf (stderr, "test_opt_ok: testing %s\n", msg);
res = zmq_setsockopt (sub, opt, value, len);
TEST_ASSERT_SUCCESS_ERRNO (res);
char buffer[1024];
size_t res_len = (size_t) sizeof buffer;
res = zmq_getsockopt (sub, opt, buffer, &res_len);
TEST_ASSERT_SUCCESS_ERRNO (res);
... | fim | zeromq/libzmq | cpp |
<|fim_suffix|>invalid__failure_short ()
{
test__zmq_curve_public__invalid__failure ("42");
}
void test__zmq_curve_public__invalid__failure_long ()
{
test__zmq_curve_public__invalid__failure (
"0123456789012345678901234567890123456789.");
}
int main ()
{
UNITY_BEGIN ();
RUN_TEST (test__zmq_curve_... | fim | zeromq/libzmq | cpp |
<|fim_suffix|> TEST_ASSERT_FAILURE_ERRNO (EAGAIN, zmq_msg_recv (&msg, a, ZMQ_DONTWAIT));
// After a reconnect of B, the messages should still be gone
TEST_ASSERT_SUCCESS_ERRNO (zmq_connect (b, connect_address));
TEST_ASSERT_FAILURE_ERRNO (EAGAIN, zmq_msg_recv (&msg, a, ZMQ_DONTWAIT));
TEST_ASSERT_F... | 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
char connect_address[MAX_SOCKET_STRING];
// PUSH: SHALL route outgoing messages to connected peers using a
// round-robin strategy.
void test... | fim | zeromq/libzmq | cpp |
<|fim_suffix|>;
s_send_seq (rep, str, SEQ_END);
s_recv_seq (reqs[peer], str, SEQ_END);
free (str);
}
#endif
test_context_socket_close_zero_linger (rep);
for (size_t peer = 0; peer < services; ++peer)
test_context_socket_close_zero_linger (reqs[peer]);
}
void test_envelope (... | fim | zeromq/libzmq | cpp |
<|fim_suffix|>t i = 0; i < services; ++i) {
// There still is a race condition when a stale peer's message
// arrives at the REQ just after a request was sent to that peer.
// To avoid that happening in the test, sleep for a bit.
TEST_ASSERT_EQUAL_INT (1,
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
// SHALL receive incoming messages from its peers using a fair-queuing
// strategy.
void test_fair_queue_in (const char *bind_address_)
{
... | 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
#define MSG_SIZE 20
#ifdef _WIN32
#include <winsock2.h>
#include <ws2tcpip.h>
#else
#include <sys/types.h>
#include <sys/socket.h>
#include <netdb.h>
#endif
voi... | 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
// ZMTP protocol greeting structure
typedef uint8_t byte;
typedef struct
{
byte signature[10]; // 0xFF 8*0x00 0x7F
byte version[2]; // 0x03 0x01 fo... | fim | zeromq/libzmq | cpp |
<|fim_suffix|>L_INT (steps, step);
test_context_socket_close (sockets[CLIENT]);
test_context_socket_close (sockets[SERVER]);
}
int main (int, char **)
{
setup_test_environment ();
UNITY_BEGIN ();
RUN_TEST (test_stream_disconnect);
return UNITY_END ();
}
<|fim_prefix|>/* SPDX-License-Identifier... | fim | zeromq/libzmq | cpp |
<|fim_prefix|>/* SPDX-License-Identifier: MPL-2.0 */
#include "testutil.hpp"
#include "testutil_unity.hpp"
SETUP_TEARDOWN_TESTCONTEXT
void test_stream_empty ()
{
char my_endpoint[MAX_SOCKET_STRING];
void *stream = test_context_socket (ZMQ_STREAM);
void *dealer = test_context_socket (ZMQ_DEALER);
bi... | fim | zeromq/libzmq | cpp |
<|fim_suffix|> TEST_ASSERT_EQUAL_INT (msgsize, send (client_sock, sndbuf, msgsize, 0));
zmq_msg_t msg;
zmq_msg_init (&msg);
int rcvbytes = 0;
while (rcvbytes == 0) // skip connection notification, if any
{
TEST_ASSERT_SUCCESS_ERRNO (zmq_msg_recv (&msg, zsock, 0)); // peerid
TEST_... | fim | zeromq/libzmq | cpp |
<|fim_suffix|>RNO (
zmq_connect (dealer_mon, "inproc://monitor-dealer"));
// connect dealer socket to non-sending stream socket
TEST_ASSERT_SUCCESS_ERRNO (zmq_connect (dealer, my_endpoint));
// we should get ZMQ_EVENT_CONNECTED and then ZMQ_EVENT_DISCONNECTED
int event = get_monitor_event (deale... | fim | zeromq/libzmq | cpp |
<|fim_suffix|>sub, buff, sizeof (buff), 0));
TEST_ASSERT_SUCCESS_ERRNO (zmq_send (xpub, buff, size, 0));
// Receive the message in the subscriber
recv_string_expect_success (sub, "", 0);
// Clean up.
test_context_socket_close (xpub);
test_context_socket_close (xsub);
test_context_socket_... | fim | zeromq/libzmq | cpp |
<|fim_prefix|>/* SPDX-License-Identifier: MPL-2.0 */
#include "testutil.hpp"
#include "testutil_unity.hpp"
SETUP_TEARDOWN_TESTCONTEXT
void test ()
{
// First, create an intermediate device.
void *xpub = test_context_socket (ZMQ_XPUB);
TEST_ASSERT_SUCCESS_ERRNO (zmq_bind (xpub, "tipc://{5560,0,0}"));
... | fim | zeromq/libzmq | cpp |
<|fim_suffix|>stem does not have local\n"
"E: networking. Please fix this before running libzmq checks.\n");
}
test_context_socket_close (dealer);
}
void test_max_sockets ()
{
// Check that we can create 1,000 sockets
fd_t handle[MAX_SOCKETS];
int count;
for (count = 0; count < MAX_... | fim | zeromq/libzmq | cpp |
<|fim_prefix|>/* SPDX-License-Identifier: MPL-2.0 */
#include "testutil.hpp"
#include "testutil_unity.hpp"
#include <cstring>
SETUP_TEARDOWN_TESTCONTEXT
void test_reconnect_ivl_against_pair_socket (const char *my_endpoint_,
void *sb_)
{
void *sc = test_context_socket... | fim | zeromq/libzmq | cpp |
<|fim_suffix|> defined ZMQ_HAVE_VMCI
buf_size = sizeof (my_endpoint);
TEST_ASSERT_SUCCESS_ERRNO (
zmq_getsockopt (req, ZMQ_LAST_ENDPOINT, my_endpoint, &buf_size));
TEST_ASSERT_SUCCESS_ERRNO (zmq_unbind (req, my_endpoint));
#endif
// Clean up
test_context_socket_close (pull);
test_context... | fim | zeromq/libzmq | cpp |
<|fim_suffix|>ntext_socket_close (push);
}
void test_term_endpoint_disconnect_tipc ()
{
if (!is_tipc_available ()) {
TEST_IGNORE_MESSAGE ("TIPC environment unavailable, skipping test\n");
}
// Create infrastructure.
void *push = test_context_socket (ZMQ_PUSH);
TEST_ASSERT_SUCCESS_ERRNO (z... | fim | zeromq/libzmq | cpp |
<|fim_prefix|>/* SPDX-License-Identifier: MPL-2.0 */
#include "testutil.hpp"
#include "testutil_unity.hpp"
SETUP_TEARDOWN_TESTCONTEXT
// Client threads loop on send/recv until told to exit
void client_thread (void *client_)
{
for (int count = 0; count < 15000; count++) {
<|fim_suffix|>etsockopt_thread_safe ()
... | fim | zeromq/libzmq | cpp |
<|fim_suffix|>
<|fim_prefix|>/* SPDX-License-Identifier: MPL-2.0 */
#include "testutil.hpp"
#include "testutil_unity.hpp"
SETUP_TEARDOWN_TESTCONTEXT
void test_timeo ()
{
void *frontend = test_context_socket (ZMQ_DEALER);
TEST_ASSERT_SUCCESS_ERRNO (zmq_bind (frontend, "inproc://timeout_test"));
// Recei... | fim | zeromq/libzmq | cpp |
<|fim_prefix|>/* SPDX-License-Identifier: MPL-2.0 */
#define __STDC_LIMIT_MACROS // to define SIZE_MAX with older compilers
#include "testutil.hpp"
#include "testutil_unity.hpp"
void setUp ()
{
}
void tearDown ()
{
}
void handler (int timer_id_, void *arg_)
{
(void) timer_id_; // Stop 'unused' compiler warning... | fim | zeromq/libzmq | cpp |
<|fim_suffix|>S_ERRNO (zmq_bind (sb, "tcp://[::1]:*"));
char endpoint[256];
size_t endpoint_len = sizeof (endpoint);
memset (endpoint, 0, endpoint_len);
TEST_ASSERT_SUCCESS_ERRNO (
zmq_getsockopt (sb, ZMQ_LAST_ENDPOINT, endpoint, &endpoint_len));
TEST_ASSERT_SUCCESS_ERRNO (zmq_connect (sc, e... | 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>
#include <unistd.h>
SETUP_TEARDOWN_TESTCONTEXT
#if !defined(ZMQ_HAVE_WINDOWS)
void pre_allocate_sock_tcp (void *socket_, char *my_endpoint_)
{
fd_t s = bind_socket_... | fim | zeromq/libzmq | cpp |
/* SPDX-License-Identifier: MPL-2.0 */
#include <string.h>
#include "testutil.hpp"
#include "testutil_unity.hpp"
SETUP_TEARDOWN_TESTCONTEXT
void test_roundtrip ()
{
char bind_address[MAX_SOCKET_STRING];
char connect_address[MAX_SOCKET_STRING];
size_t addr_length = sizeof (connect_address);
void *sb ... | fim | zeromq/libzmq | cpp |
<|fim_suffix|>w2a0jvwp\n"
"uA/bc+4IZ9yvrhC9KkOUnivnCV71U2Wy8zOvrBEJicuGOc+lbWJRKyjbMDi1IybG\n"
"VnemtkQEyXFh6f1h8AdaN+Xj7qXX/YKmNk20Siu4qDNo8nozVpOL2DHjoKLa4N2c\n"
"ULG3kXScxVxWqCuPVNeypV2TZ9uSVFeKK/VJ5iGvFeifDsqVVo6WC4Pdz0WYes8H\n"
"3VqEPSwmNJ1FswLpYpGgCEFnkGRPFFB5dmwr0fuubkgaJPatxrImFac+nukfqZ8N\n"
"x/d4t72... | fim | zeromq/libzmq | cpp |
<|fim_suffix|>;
// Create a subscriber
void *sub = test_context_socket (ZMQ_XSUB);
TEST_ASSERT_SUCCESS_ERRNO (zmq_connect (sub, "inproc://soname"));
TEST_ASSERT_SUCCESS_ERRNO (zmq_setsockopt (sub, ZMQ_ONLY_FIRST_SUBSCRIBE,
&only_first_subscribe,
... | fim | zeromq/libzmq | cpp |
<|fim_prefix|>/* SPDX-License-Identifier: MPL-2.0 */
#include "testutil.hpp"
#include "testutil_unity.hpp"
SETUP_TEARDOWN_TESTCONTEXT
void test_basic ()
{
// Create a publisher
void *pub = test_context_socket (ZMQ_XPUB);
int manual = 1;
TEST_ASSERT_SUCCESS_ERRNO (
zmq_setsockopt (pub, ZMQ_XPUB... | fim | zeromq/libzmq | cpp |
<|fim_suffix|>TY_END ();
}
<|fim_prefix|>/* SPDX-License-Identifier: MPL-2.0 */
#include "testutil.hpp"
#include "testutil_unity.hpp"
SETUP_TEARDOWN_TESTCONTEXT
void test ()
{
// Create a publisher
void *pub = test_context_socket (ZMQ_XPUB);
int hwm = 2000;
TEST_ASSERT_SUCCESS_ERRNO (zmq_setsockopt... | fim | zeromq/libzmq | cpp |
<|fim_prefix|>/* SPDX-License-Identifier: MPL-2.0 */
#include "testutil.hpp"
#include "testutil_unity.hpp"
SETUP_TEARDOWN_TESTCONTEXT
const char bind_address[] = "tcp://127.0.0.1:*";
char connect_address[MAX_SOCKET_STRING];
// 245 chars + 10 chars for subscribe command = 255 chars
const char short_topic[] =
"ABCD... | fim | zeromq/libzmq | cpp |
<|fim_prefix|>/* SPDX-License-Identifier: MPL-2.0 */
#include "testutil.hpp"
#include "testutil_unity.hpp"
SETUP_TEARDOWN_TESTCONTEXT
const uint8_t unsubscribe_a_msg[] = {0, 'A'};
const uint8_t subscribe_a_msg[] = {1, 'A'};
const uint8_t subscribe_b_msg[] = {1, 'B'};
const char test_endpoint[] = "inproc://soname";
... | fim | zeromq/libzmq | cpp |
<|fim_prefix|>/* SPDX-License-Identifier: MPL-2.0 */
#include<|fim_suffix|>essage
recv_string_expect_success (sub, "W", 0);
// Clean up.
test_context_socket_close (pub);
test_context_socket_close (sub);
}
int main ()
{
setup_test_environment ();
UNITY_BEGIN ();
RUN_TEST (test);
retu... | fim | zeromq/libzmq | cpp |
<|fim_prefix|>/* SPDX-License-Identifier: MPL-2.0 */
#include "testutil.hpp"
#include "testutil_unity.hpp"
SETUP_TEARDOWN_TESTCONTEXT
const uint8_t unsubscribe_a_msg[] = {0, 'A'};
const uint8_t subscribe_a_msg[] = {1, 'A'};
const char test_endpoint[] = "inproc://soname";
void test_xsub_verbose_unsubscribe ()
{
... | fim | zeromq/libzmq | cpp |
<|fim_suffix|>e (data);
free (len);
}
int main (int argc, char **argv)
{
setup_test_environment ();
UNITY_BEGIN ();
RUN_TEST (test_z85_decode_fuzzer);
return UNITY_END ();
}
#endif
<|fim_prefix|>/* SPDX-License-Identifier: MPL-<|fim_middle|>2.0 */
#ifdef ZMQ_USE_FUZZING_ENGINE
#include <fuzzer/F... | fim | zeromq/libzmq | cpp |
<|fim_suffix|>truct sockaddr_in saddr = bind_bsd_socket (recv_socket);
void *sb = test_context_socket (ZMQ_REP);
TEST_ASSERT_SUCCESS_ERRNO (zmq_bind (sb, "tcp://127.0.0.1:*"));
zmq_pollitem_t pollitems[] = {
{sb, 0, ZMQ_POLLIN, 0},
{NULL, recv_socket, ZMQ_POLLIN, 0},
};
int send_sock... | fim | zeromq/libzmq | cpp |
<|fim_suffix|>T_NOT_EQUAL (-1, send_socket);
char buf[10];
memset (buf, 1, 10);
TEST_ASSERT_SUCCESS_ERRNO (sendto (
send_socket, buf, 10, 0, (struct sockaddr *) &saddr, sizeof (saddr)));
TEST_ASSERT_EQUAL (1, zmq_ppoll (pollitems, 2, 1, NULL));
TEST_ASSERT_BITS_LOW (ZMQ_POLLIN, pollitems[0]... | fim | zeromq/libzmq | cpp |
<|fim_suffix|>("continued\n");
}
}
if (-1 == pid) {
printf ("waitpid returned -1, with errno %s\n", strerror (errno));
}
} else { // child
setup_test_context ();
// set up signal mask and install handler for SIGTERM
sigset_t sigmask, sigmask_w... | fim | zeromq/libzmq | cpp |
/* SPDX-License-Identifier: MPL-2.0 */
#include "testutil.hpp"
#include "testutil_unity.hpp"
#include <stdarg.h>
#include <string.h>
#if defined _WIN32
#include "../src/windows.hpp"
#if defined ZMQ_HAVE_WINDOWS
#if defined ZMQ_HAVE_IPC
#include <direct.h>
#include <afunix.h>
#endif
#include <crtdbg.h>
#pragma warning... | fim | zeromq/libzmq | cpp |
<|fim_prefix|>/* SPDX-License-Identifier: MPL-2.0 */
#ifdef _AIX
#define MSG_DONTWAIT MSG_NONBLOCK
#endif
#ifndef __TESTUTIL_HPP_INCLUDED__
#define __TESTUTIL_HPP_INCLUDED__
#if defined ZMQ_CUSTOM_PLATFORM_HPP
#include "platform.hpp"
#else
#include "../src/platform.hpp"
#endif
#include "../include/zmq.h"
#include ".... | fim | zeromq/libzmq | cpp |
<|fim_prefix|>/* SPDX-License-Identifier: MPL-2.0 */
#include "testutil_monitoring.hpp"
#include "testutil_unity.hpp"
#include <stdlib.h>
#include <string.h>
static int
receive_monitor_address (void *monitor_, char **address_, bool expect_more_)
{
zmq_msg_t msg;
zmq_msg_init (&msg);
if (zmq_msg_recv (&ms... | fim | zeromq/libzmq | cpp |
<|fim_suffix|>_ = false);
int64_t get_monitor_event_v2 (void *monitor_,
uint64_t **value_,
char **local_address_,
char **remote_address_);
void expect_monitor_event_v2 (void *monitor_,
int64_t expec... | fim | zeromq/libzmq | cpp |
<|fim_prefix|>/* SPDX-License-Identifier: MPL-2.0 */
#include "testutil_security.hpp"
#include <stdlib.h>
#include <string.h>
const char *test_zap_domain = "ZAPTEST";
void socket_config_null_client (void *server_, void *server_secret_)
{
LIBZMQ_UNUSED (server_);
LIBZMQ_UNUSED (server_secret_);
}
void socket... | fim | zeromq/libzmq | cpp |
<|fim_suffix|> \
!= -1) { \
if (event == ZMQ_EVENT_HANDSHAKE_FAILED_NO_DETAIL \
&& (err == EPIPE || err == ECONNRESET \
|| err == E... | fim | zeromq/libzmq | cpp |
<|fim_prefix|>/* SPDX-License-Identifier: MPL-2.0 */
#include "testutil_unity.hpp"
#include <stdlib.h>
#include <string.h>
#ifdef _WIN32
#include <direct.h>
#else
#include <unistd.h>
#endif
int test_assert_success_message_errno_helper (int rc_,
const char *msg_,
... | fim | zeromq/libzmq | cpp |
<|fim_suffix|>ndom_ipc_endpoint instead.
void bind_loopback_ipc (void *socket_, char *my_endpoint_, size_t len_);
// Binds to an ipc endpoint using the tipc wildcard address.
void bind_loopback_tipc (void *socket_, char *my_endpoint_, size_t len_);
#if defined(ZMQ_HAVE_IPC)
// utility function to create a random IPC ... | fim | zeromq/libzmq | cpp |
<|fim_prefix|>/* SPDX-License-Identifier: MPL-2.0 */
#include <stdlib.h>
#include <assert.h>
#include <zmq.h>
int main (void)<|fim_suffix|>s ("distributed (securely!) to peers wishing to connect to it.");
char public_key[41];
char secret_key[41];
if (zmq_curve_keypair (public_key, secret_key)) {
... | fim | zeromq/libzmq | cpp |
<|fim_suffix|>ain ()
{
setup_test_environment ();
zmq::random_open ();
UNITY_BEGIN ();
RUN_TEST (test_roundtrip_empty);
RUN_TEST (test_roundtrip_small);
RUN_TEST (test_roundtrip_large);
RUN_TEST (test_roundtrip_empty_more);
zmq::random_close ();
return UNITY_END ();
}
<|fim_pref... | fim | zeromq/libzmq | cpp |
<|fim_suffix|>::ip_resolver_options_t resolver_opts;
resolver_opts.bindable (true).expect_port (true).ipv6 (ipv6_);
// Should be equivalent to "*:*"
const char *expected = ipv6_ ? "::" : "0.0.0.0";
test_resolve (resolver_opts, "*:0", expected, 0);
}
MAKE_TEST_V4V6 (test_bind_any_port0)
static void t... | fim | zeromq/libzmq | cpp |
<|fim_prefix|>/* SPDX-License-Identifier: MPL-2.0 */
#include "../tests/testutil.hpp"
#if defined(min)
#undef min
#endif
#include <generic_mtrie_impl.hpp>
#include <unity.h>
void setUp ()
{
}
void tearDown ()
{
}
int getlen (const zmq::generic_mtrie_t<int>::prefix_t &data_)
{
return static_cast<int> (strlen (... | fim | zeromq/libzmq | cpp |
<|fim_prefix|>/* SPDX-License-Identifier: MPL-2.0 */
#include "../tests/testutil.hpp"
#include <poller.hpp>
#include <i_poll_events.hpp>
#include <ip.hpp>
#include <unity.h>
#ifndef _WIN32
#include <unistd.h>
#define closesocket close
#endif
void setUp ()
{
}
void tearDown ()
{
}
void test_create ()
{
zmq::th... | fim | zeromq/libzmq | cpp |
<|fim_suffix|>rn true"));
}
void test_size ()
{
zmq::radix_tree_t tree;
// Adapted from the example on wikipedia.
std::vector<std::string> keys;
keys.push_back ("tester");
keys.push_back ("water");
keys.push_back ("slow");
keys.push_back ("slower");
keys.push_back ("test");
keys.pu... | fim | zeromq/libzmq | cpp |
<|fim_prefix|>/* SPDX-License-Identifier: MPL-2.0 */
#ifndef __UNITTEST_RESOLVER_COMMON_INCLUDED__
#define __UNITTEST_RESOLVER_COMMON_INCLUDED__
#include <ip_resolver.hpp>
#include <string.h>
// Attempt a resolution and test the results.
//
// On windows we can receive an IPv4 address even when an IPv6 is requeste... | fim | zeromq/libzmq | cpp |
/* SPDX-License-Identifier: MPL-2.0 */
#include <unity.h>
#include "../tests/testutil.hpp"
#include "../unittests/unittest_resolver_common.hpp"
#include <ip.hpp>
#include <udp_address.hpp>
void setUp ()
{
}
void tearDown ()
{
}
// Test an UDP address resolution. If 'dest_addr_' is NULL assume the
// resolution i... | fim | zeromq/libzmq | cpp |
<|fim_suffix|>
int read_value = -1;
TEST_ASSERT_FALSE (ypipe.read (&read_value));
TEST_ASSERT_EQUAL_INT (-1, read_value);
}
void test_write_complete_and_flush_and_check_read_and_read ()
{
const int value = 42;
zmq::ypipe_t<int, 1> ypipe;
ypipe.write (value, false);
ypipe.flush ();
TEST_... | fim | zeromq/libzmq | cpp |
<|fim_suffix|>ce"]
<|fim_prefix|>from agent.chat.service import ChatService<|fim_middle|>
__all__ = ["ChatServi<|endoftext|> | fim | zhayujie/CowAgent | python |
<|fim_suffix|>)
except Exception:
# If executor cleared messages (context overflow), sync back
if len(executor.messages) == 0:
with agent.messages_lock:
agent.messages.clear()
logger.info("[ChatService] Cleared agent message history... | fim | zhayujie/CowAgent | python |
<|fim_prefix|>"""
SessionService - Manages multi-session lifecycle for both web channel and cloud client.
Provides a unified interface for listing, deleting, renaming, clearing context,
and generating AI titles for conversation sessions. Backed by ConversationStore
(SQLite) and AgentBridge (in-memory agent instances).... | fim | zhayujie/CowAgent | python |
<|fim_prefix|>"""
Self-evolution subsystem for CowAgent.
Runs a lightweight, isolated review pass after a conversation goes idle to
decide whether anything is worth durably learning (memory / skill) or whether
an unfinished task can be pushed forward. Conservative by design: most
conversations should produce no change... | fim | zhayujie/CowAgent | python |
<|fim_suffix|>rent.mkdir(parents=True, exist_ok=True)
shutil.copy2(bak, dst)
logger.info(f"[Evolution] Restored backup {backup_id} ({len(manifest)} file(s))")
return True
except Exception as e:
logger.warning(f"[Evolution] Failed to restore backup {backup_id}: {e}")
r... | fim | zhayujie/CowAgent | python |
"""Configuration for the self-evolution subsystem.
Reads flat ``self_evolution_*`` keys from config.json. All fields have safe
defaults so the feature degrades gracefully when keys are absent.
"""
from __future__ import annotations
from dataclasses import dataclass
from typing import Any
# Defaults — conservative ... | fim | zhayujie/CowAgent | python |
<|fim_suffix|>,
tools=review_tools,
description="Self-evolution review agent",
max_steps=cfg.max_steps,
workspace_dir=str(workspace_dir),
skill_manager=getattr(agent, "skill_manager", None),
memory_manager=getattr(agent, "memory_manager", None),
... | fim | zhayujie/CowAgent | python |
<|fim_prefix|>"""Prompts for the self-evolution review agent.
The system prompt is intentionally English-only: it governs the agent's
internal reasoning and is more stable / cheaper to maintain in one language.
The user-facing summary the agent produces should follow the user's own
language (instructed at the end of t... | fim | zhayujie/CowAgent | python |
<|fim_prefix|>"""Self-evolution record log.
Session-level evolutions are appended to their OWN per-day file under
``memory/evolution/YYYY-MM-DD.md`` (separate from the nightly Deep Dream diary
in ``memory/dreams/``). Each day's file accumulates one short section per
evolution pass — tagged with a timestamp and a backu... | fim | zhayujie/CowAgent | python |
<|fim_prefix|>"""Idle-based evolution trigger.
A single background thread periodically scans live agent sessions and runs an
evolution pass for any session that is idle for >= idle_minutes AND has enough
accumulated signal, where "enough signal" is EITHER:
- >= min_turns user turns since the last evolution, OR
- t... | fim | zhayujie/CowAgent | python |
"""
Knowledge service for handling knowledge base operations.
Provides a unified interface for listing, reading, and graphing knowledge files,
callable from the web console, API, or CLI.
Knowledge file layout (under workspace_root):
knowledge/index.md
knowledge/log.md
knowledge/<category>/<slug>.md
"""
i... | fim | zhayujie/CowAgent | python |
<|fim_prefix|>"""
Memory module for AgentMesh
Provides both long-term memory (vector/keyword search) and short-term
conversa<|fim_suffix|>emory.manager import MemoryManager
from agent.memory.config import MemoryConfig, get_default_memory_config, set_global_memory_config
from agent.memory.embedding import create_embedd... | fim | zhayujie/CowAgent | python |
"""
Text chunking utilities for memory
Splits text into chunks with token limits and overlap
"""
from __future__ import annotations
from typing import List, Tuple
from dataclasses import dataclass
@dataclass
class TextChunk:
"""Represents a text chunk with line numbers"""
text: str
start_line: int
e... | fim | zhayujie/CowAgent | python |
<|fim_prefix|>"""
Memory configuration module
Provides global memory configuration with simplified workspace structure
"""
from __future__ import annotations
import os
from dataclasses import dataclass, field
from typing import Optional, List
from pathlib import Path
def _default_workspace():
"""Get default wor... | fim | zhayujie/CowAgent | python |
<|fim_prefix|>"""
Conversation history persistence using SQLite.
Design:
- sessions table: per-session metadata (channel_type, last_active, msg_count)
- messages table: individual messages stored as JSON, append-only
- Pruning: age-based only (sessions not updated within N days are deleted)
- Thread-safe via a single ... | fim | zhayujie/CowAgent | python |
<|fim_suffix|> RebuildResult,
clear_index,
rebuild_in_process,
)
from agent.memory.embedding.state import (
cleanup_legacy_state_file,
detect_index_dim,
)
__all__ = [
"EMBEDDING_VENDORS",
"DoubaoEmbeddingProvider",
"EmbeddingCache",
"EmbeddingProvider",
"OpenAIEmbeddingProvider",... | fim | zhayujie/CowAgent | python |
<|fim_prefix|>"""
Embedding providers for memory
Supports multiple OpenAI-compatible embedding vendors:
- openai (text-embedding-3-small / large)
- linkai (OpenAI-compatible passthrough)
- dashscope (Aliyun Tongyi text-embedding-v4)
- doubao (ByteDance Doubao Seed1.5 / large-text on Volcengine Ark... | fim | zhayujie/CowAgent | python |
<|fim_suffix|>mbedded", 0))
# sync() degrades to "no embeddings" on batch failure so keyword search
# still works at startup — but in a /rebuild-index request the user
# explicitly asked for vectors. Surface that as a failure.
if chunks > 0 and embedded == 0:
return RebuildResult(
o... | fim | zhayujie/CowAgent | python |
<|fim_suffix|>eanup_legacy_state_file(db_path: PathLike) -> None:
"""Remove old embedding_state.json files from earlier versions.
Safe to call repeatedly; no-op if the file is absent."""
legacy = Path(db_path).parent / "embedding_state.json"
try:
legacy.unlink(missing_ok=True)
except Excepti... | fim | zhayujie/CowAgent | python |
"""
Memory manager for AgentMesh
Provides high-level interface for memory operations
"""
import os
from typing import List, Optional, Dict, Any
from pathlib import Path
import hashlib
from datetime import datetime, timedelta
from agent.memory.config import MemoryConfig, get_default_memory_config
from agent.memory.st... | fim | zhayujie/CowAgent | python |
<|fim_prefix|>"""
Backward-compatib<|fim_suffix|> import sys
sys.exit(main())
<|fim_middle|>le shim for the legacy entry point:
python -m agent.memory.rebuild_index
The implementation now lives in agent.memory.embedding.rebuild.
Prefer using `/memory rebuild-index` in chat going forward.
"""
from agent.memo... | fim | zhayujie/CowAgent | python |
<|fim_prefix|>"""
Memory service for handling memory query operations via cloud protocol.
Provides a unified interface for listing and reading memory files,
callable from the cloud client (LinkAI) or a future web console.
Memory file layout (under workspace_root):
MEMORY.md -> type: global
memor... | fim | zhayujie/CowAgent | python |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.