<commit_before>/**
 * @file
 *
 * @brief
 *
 * @copyright BSD License (see LICENSE.md or https://www.libelektra.org)
 */

#include "zeromqrecv.h"

#include <stdio.h>  // printf() & co
#include <time.h>   // time()
#include <unistd.h> // usleep()

#include <kdbio_uv.h>    // elektraIoUvNew()
#include <kdbioplugin.h> // ElektraIoPluginSetBinding

#include <tests.h>
#include <tests_plugin.h>

#include <uv.h>

/** zmq context for tests */
void * context;

/** time (300ms in microseconds) to wait until zmq connections are established and sending & receiving works */
#define TIME_SETTLE_US (300 * 1000)

/** time (100ms in microseconds) before a new socket is created. leaves the system some after binding a socket again */
#define TIME_HOLDOFF (100 * 1000)

/** timeout for tests in seconds */
#define TEST_TIMEOUT 1

Key * test_callbackKey;
uv_loop_t * test_callbackLoop;
int test_incompleteMessageTimeout;

/**
 * @internal
 * Create publisher socket for tests.
 *
 * @return  new socket
 */
static void * createTestSocket (void)
{
	// leave the system some time before binding again
	usleep (TIME_HOLDOFF);

	void * pubSocket = zmq_socket (context, ZMQ_PUB);
	int result = zmq_bind (pubSocket, "tcp://*:6000");
	if (result != 0)
	{
		yield_error ("zmq_bind failed");
		printf ("zmq error was: %s\n", zmq_strerror (zmq_errno ()));
		exit (-1);
	}

	return pubSocket;
}

<commit_msg>zeromqrecv: relax timing for memleak/asan tests<commit_after>/**
 * @file
 *
 * @brief
 *
 * @copyright BSD License (see LICENSE.md or https://www.libelektra.org)
 */

#include "zeromqrecv.h"

#include <stdio.h>  // printf() & co
#include <time.h>   // time()
#include <unistd.h> // usleep()

#include <kdbio_uv.h>    // elektraIoUvNew()
#include <kdbioplugin.h> // ElektraIoPluginSetBinding

#include <tests.h>
#include <tests_plugin.h>

#include <uv.h>

/** zmq context for tests */
void * context;

/** time in microseconds to wait until zmq connections are established and sending & receiving works */
#define TIME_SETTLE_US (1000 * 1000)

/** time (100ms in microseconds) before a new socket is created. leaves the system some after binding a socket again */
#define TIME_HOLDOFF (100 * 1000)

/** timeout for tests in seconds */
#define TEST_TIMEOUT 3

Key * test_callbackKey;
uv_loop_t * test_callbackLoop;
int test_incompleteMessageTimeout;

/**
 * @internal
 * Create publisher socket for tests.
 *
 * @return  new socket
 */
static void * createTestSocket (void)
{
	// leave the system some time before binding again
	usleep (TIME_HOLDOFF);

	void * pubSocket = zmq_socket (context, ZMQ_PUB);
	int result = zmq_bind (pubSocket, "tcp://*:6000");
	if (result != 0)
	{
		yield_error ("zmq_bind failed");
		printf ("zmq error was: %s\n", zmq_strerror (zmq_errno ()));
		exit (-1);
	}

	return pubSocket;
}


{'fraction_non_alphanumeric': 0.13576277241872098, 'fraction_numerical': 0.018578063594140763, 'mean_word_length': 3.9645390070921986, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 19, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2640149', 'n_tokens_mistral': 1028, 'n_tokens_neox': 970, 'n_words': 296}