aboutsummaryrefslogtreecommitdiffstats
path: root/extras/libmemif/test
diff options
context:
space:
mode:
Diffstat (limited to 'extras/libmemif/test')
-rw-r--r--extras/libmemif/test/main_test.c215
-rw-r--r--extras/libmemif/test/socket_test.c53
-rw-r--r--extras/libmemif/test/unit_test.h1
3 files changed, 87 insertions, 182 deletions
diff --git a/extras/libmemif/test/main_test.c b/extras/libmemif/test/main_test.c
index b7705c4be1a..a5e0e3dc860 100644
--- a/extras/libmemif/test/main_test.c
+++ b/extras/libmemif/test/main_test.c
@@ -65,7 +65,8 @@ START_TEST (test_init)
int err;
if ((err =
- memif_init (control_fd_update, TEST_APP_NAME)) != MEMIF_ERR_SUCCESS)
+ memif_init (control_fd_update, TEST_APP_NAME, NULL,
+ NULL)) != MEMIF_ERR_SUCCESS)
ck_abort_msg ("err code: %u, err msg: %s", err, memif_strerror (err));
libmemif_main_t *lm = &libmemif_main;
@@ -84,7 +85,8 @@ START_TEST (test_init_epoll)
{
int err;
- if ((err = memif_init (NULL, TEST_APP_NAME)) != MEMIF_ERR_SUCCESS)
+ if ((err =
+ memif_init (NULL, TEST_APP_NAME, NULL, NULL)) != MEMIF_ERR_SUCCESS)
ck_abort_msg ("err code: %u, err msg: %s", err, memif_strerror (err));
libmemif_main_t *lm = &libmemif_main;
@@ -110,12 +112,11 @@ START_TEST (test_create)
libmemif_main_t *lm = &libmemif_main;
if ((err =
- memif_init (control_fd_update, TEST_APP_NAME)) != MEMIF_ERR_SUCCESS)
+ memif_init (control_fd_update, TEST_APP_NAME, NULL,
+ NULL)) != MEMIF_ERR_SUCCESS)
ck_abort_msg ("err code: %u, err msg: %s", err, memif_strerror (err));
strncpy ((char *) args.interface_name, TEST_IF_NAME, strlen (TEST_IF_NAME));
- strncpy ((char *) args.instance_name, TEST_APP_NAME,
- strlen (TEST_APP_NAME));
if ((err = memif_create (&conn, &args, on_connect,
on_disconnect, on_interrupt,
@@ -147,7 +148,6 @@ START_TEST (test_create)
ck_assert_ptr_ne (c->on_interrupt, NULL);
ck_assert_str_eq (c->args.interface_name, args.interface_name);
- ck_assert_str_eq (c->args.instance_name, args.instance_name);
ck_assert_str_eq (c->args.socket_filename, SOCKET_FILENAME);
struct itimerspec timer;
@@ -176,12 +176,11 @@ START_TEST (test_create_master)
libmemif_main_t *lm = &libmemif_main;
if ((err =
- memif_init (control_fd_update, TEST_APP_NAME)) != MEMIF_ERR_SUCCESS)
+ memif_init (control_fd_update, TEST_APP_NAME, NULL,
+ NULL)) != MEMIF_ERR_SUCCESS)
ck_abort_msg ("err code: %u, err msg: %s", err, memif_strerror (err));
strncpy ((char *) args.interface_name, TEST_IF_NAME, strlen (TEST_IF_NAME));
- strncpy ((char *) args.instance_name, TEST_APP_NAME,
- strlen (TEST_APP_NAME));
if ((err = memif_create (&conn, &args, on_connect,
on_disconnect, on_interrupt,
@@ -213,7 +212,6 @@ START_TEST (test_create_master)
ck_assert_ptr_ne (c->on_interrupt, NULL);
ck_assert_str_eq (c->args.interface_name, args.interface_name);
- ck_assert_str_eq (c->args.instance_name, args.instance_name);
ck_assert_str_eq (c->args.socket_filename, SOCKET_FILENAME);
struct stat file_stat;
@@ -239,12 +237,11 @@ START_TEST (test_create_mult)
libmemif_main_t *lm = &libmemif_main;
if ((err =
- memif_init (control_fd_update, TEST_APP_NAME)) != MEMIF_ERR_SUCCESS)
+ memif_init (control_fd_update, TEST_APP_NAME, NULL,
+ NULL)) != MEMIF_ERR_SUCCESS)
ck_abort_msg ("err code: %u, err msg: %s", err, memif_strerror (err));
strncpy ((char *) args.interface_name, TEST_IF_NAME, strlen (TEST_IF_NAME));
- strncpy ((char *) args.instance_name, TEST_APP_NAME,
- strlen (TEST_APP_NAME));
if ((err = memif_create (&conn, &args, on_connect,
on_disconnect, on_interrupt,
@@ -300,10 +297,8 @@ START_TEST (test_create_mult)
ck_assert_ptr_ne (c1->on_interrupt, NULL);
ck_assert_str_eq (c->args.interface_name, args.interface_name);
- ck_assert_str_eq (c->args.instance_name, args.instance_name);
ck_assert_str_eq (c->args.socket_filename, SOCKET_FILENAME);
ck_assert_str_eq (c1->args.interface_name, args.interface_name);
- ck_assert_str_eq (c1->args.instance_name, args.instance_name);
ck_assert_str_eq (c1->args.socket_filename, SOCKET_FILENAME);
struct itimerspec timer;
@@ -334,12 +329,11 @@ START_TEST (test_control_fd_handler)
libmemif_main_t *lm = &libmemif_main;
if ((err =
- memif_init (control_fd_update, TEST_APP_NAME)) != MEMIF_ERR_SUCCESS)
+ memif_init (control_fd_update, TEST_APP_NAME, NULL,
+ NULL)) != MEMIF_ERR_SUCCESS)
ck_abort_msg ("err code: %u, err msg: %s", err, memif_strerror (err));
strncpy ((char *) args.interface_name, TEST_IF_NAME, strlen (TEST_IF_NAME));
- strncpy ((char *) args.instance_name, TEST_APP_NAME,
- strlen (TEST_APP_NAME));
if ((err = memif_create (&conn, &args, on_connect,
on_disconnect, on_interrupt,
@@ -406,12 +400,11 @@ START_TEST (test_buffer_alloc)
libmemif_main_t *lm = &libmemif_main;
if ((err =
- memif_init (control_fd_update, TEST_APP_NAME)) != MEMIF_ERR_SUCCESS)
+ memif_init (control_fd_update, TEST_APP_NAME, NULL,
+ NULL)) != MEMIF_ERR_SUCCESS)
ck_abort_msg ("err code: %u, err msg: %s", err, memif_strerror (err));
strncpy ((char *) args.interface_name, TEST_IF_NAME, strlen (TEST_IF_NAME));
- strncpy ((char *) args.instance_name, TEST_APP_NAME,
- strlen (TEST_APP_NAME));
if ((err = memif_create (&conn, &args, on_connect,
on_disconnect, on_interrupt,
@@ -437,12 +430,13 @@ START_TEST (test_buffer_alloc)
qid = 0;
if ((err =
memif_buffer_alloc (conn, qid, bufs, max_buf,
- &buf, 0)) != MEMIF_ERR_SUCCESS)
+ &buf,
+ MEMIF_DEFAULT_BUFFER_SIZE)) != MEMIF_ERR_SUCCESS)
ck_abort_msg ("err code: %u, err msg: %s", err, memif_strerror (err));
ck_assert_uint_eq (buf, max_buf);
for (i = 0; i < max_buf; i++)
- ck_assert_uint_eq (bufs[i].buffer_len, MEMIF_DEFAULT_BUFFER_SIZE);
+ ck_assert_uint_eq (bufs[i].len, MEMIF_DEFAULT_BUFFER_SIZE);
/* test buffer allocation qid 1 (positive) */
free (bufs);
@@ -451,12 +445,13 @@ START_TEST (test_buffer_alloc)
qid = 1;
if ((err =
memif_buffer_alloc (conn, qid, bufs, max_buf,
- &buf, 0)) != MEMIF_ERR_SUCCESS)
+ &buf,
+ MEMIF_DEFAULT_BUFFER_SIZE)) != MEMIF_ERR_SUCCESS)
ck_abort_msg ("err code: %u, err msg: %s", err, memif_strerror (err));
ck_assert_uint_eq (buf, max_buf);
for (i = 0; i < max_buf; i++)
- ck_assert_uint_eq (bufs[i].buffer_len, MEMIF_DEFAULT_BUFFER_SIZE);
+ ck_assert_uint_eq (bufs[i].len, MEMIF_DEFAULT_BUFFER_SIZE);
/* test buffer allocation qid 2 (negative) */
@@ -466,7 +461,8 @@ START_TEST (test_buffer_alloc)
qid = 2;
if ((err =
memif_buffer_alloc (conn, qid, bufs, max_buf,
- &buf, 0)) != MEMIF_ERR_SUCCESS)
+ &buf,
+ MEMIF_DEFAULT_BUFFER_SIZE)) != MEMIF_ERR_SUCCESS)
ck_assert_msg (err == MEMIF_ERR_QID, "err code: %u, err msg: %s", err,
memif_strerror (err));
@@ -498,12 +494,11 @@ START_TEST (test_tx_burst)
libmemif_main_t *lm = &libmemif_main;
if ((err =
- memif_init (control_fd_update, TEST_APP_NAME)) != MEMIF_ERR_SUCCESS)
+ memif_init (control_fd_update, TEST_APP_NAME, NULL,
+ NULL)) != MEMIF_ERR_SUCCESS)
ck_abort_msg ("err code: %u, err msg: %s", err, memif_strerror (err));
strncpy ((char *) args.interface_name, TEST_IF_NAME, strlen (TEST_IF_NAME));
- strncpy ((char *) args.instance_name, TEST_APP_NAME,
- strlen (TEST_APP_NAME));
if ((err = memif_create (&conn, &args, on_connect,
on_disconnect, on_interrupt,
@@ -528,12 +523,13 @@ START_TEST (test_tx_burst)
qid = 0;
if ((err =
memif_buffer_alloc (conn, qid, bufs, max_buf,
- &buf, 0)) != MEMIF_ERR_SUCCESS)
+ &buf,
+ MEMIF_DEFAULT_BUFFER_SIZE)) != MEMIF_ERR_SUCCESS)
ck_abort_msg ("err code: %u, err msg: %s", err, memif_strerror (err));
ck_assert_uint_eq (buf, max_buf);
for (i = 0; i < max_buf; i++)
- ck_assert_uint_eq (bufs[i].buffer_len, MEMIF_DEFAULT_BUFFER_SIZE);
+ ck_assert_uint_eq (bufs[i].len, MEMIF_DEFAULT_BUFFER_SIZE);
if ((err =
memif_tx_burst (conn, qid, bufs, max_buf, &tx)) != MEMIF_ERR_SUCCESS)
@@ -549,12 +545,13 @@ START_TEST (test_tx_burst)
qid = 1;
if ((err =
memif_buffer_alloc (conn, qid, bufs, max_buf,
- &buf, 0)) != MEMIF_ERR_SUCCESS)
+ &buf,
+ MEMIF_DEFAULT_BUFFER_SIZE)) != MEMIF_ERR_SUCCESS)
ck_abort_msg ("err code: %u, err msg: %s", err, memif_strerror (err));
ck_assert_uint_eq (buf, max_buf);
for (i = 0; i < max_buf; i++)
- ck_assert_uint_eq (bufs[i].buffer_len, MEMIF_DEFAULT_BUFFER_SIZE);
+ ck_assert_uint_eq (bufs[i].len, MEMIF_DEFAULT_BUFFER_SIZE);
if ((err =
memif_tx_burst (conn, qid, bufs, max_buf, &tx)) != MEMIF_ERR_SUCCESS)
@@ -602,12 +599,11 @@ START_TEST (test_rx_burst)
libmemif_main_t *lm = &libmemif_main;
if ((err =
- memif_init (control_fd_update, TEST_APP_NAME)) != MEMIF_ERR_SUCCESS)
+ memif_init (control_fd_update, TEST_APP_NAME, NULL,
+ NULL)) != MEMIF_ERR_SUCCESS)
ck_abort_msg ("err code: %u, err msg: %s", err, memif_strerror (err));
strncpy ((char *) args.interface_name, TEST_IF_NAME, strlen (TEST_IF_NAME));
- strncpy ((char *) args.instance_name, TEST_APP_NAME,
- strlen (TEST_APP_NAME));
if ((err = memif_create (&conn, &args, on_connect,
on_disconnect, on_interrupt,
@@ -630,7 +626,7 @@ START_TEST (test_rx_burst)
qid = 0;
mq = &c->rx_queues[qid];
ring = mq->ring;
- ring->head += max_buf;
+ ring->tail += max_buf;
bufs = malloc (sizeof (memif_buffer_t) * max_buf);
@@ -646,7 +642,7 @@ START_TEST (test_rx_burst)
qid = 1;
mq = &c->rx_queues[qid];
ring = mq->ring;
- ring->head += max_buf;
+ ring->tail += max_buf;
free (bufs);
bufs = malloc (sizeof (memif_buffer_t) * max_buf);
@@ -679,124 +675,6 @@ START_TEST (test_rx_burst)
}
END_TEST
-START_TEST (test_buffer_free)
-{
- int err, i;
- uint16_t max_buf = 10, buf, rx;
- uint8_t qid;
- memif_buffer_t *bufs;
- memif_queue_t *mq;
- memif_ring_t *ring;
- ready_called = 0;
- memif_conn_handle_t conn = NULL;
- memif_conn_args_t args;
- memset (&args, 0, sizeof (args));
- args.num_s2m_rings = 2;
- args.num_m2s_rings = 2;
-
- libmemif_main_t *lm = &libmemif_main;
-
- if ((err =
- memif_init (control_fd_update, TEST_APP_NAME)) != MEMIF_ERR_SUCCESS)
- ck_abort_msg ("err code: %u, err msg: %s", err, memif_strerror (err));
-
- strncpy ((char *) args.interface_name, TEST_IF_NAME, strlen (TEST_IF_NAME));
- strncpy ((char *) args.instance_name, TEST_APP_NAME,
- strlen (TEST_APP_NAME));
-
- if ((err = memif_create (&conn, &args, on_connect,
- on_disconnect, on_interrupt,
- NULL)) != MEMIF_ERR_SUCCESS)
- ck_abort_msg ("err code: %u, err msg: %s", err, memif_strerror (err));
-
- memif_connection_t *c = (memif_connection_t *) conn;
-
- c->run_args.num_s2m_rings = 2;
- c->run_args.num_m2s_rings = 2;
- c->run_args.log2_ring_size = 10;
- c->run_args.buffer_size = 2048;
-
- if ((err = memif_init_regions_and_queues (c)) != MEMIF_ERR_SUCCESS)
- ck_abort_msg ("err code: %u, err msg: %s", err, memif_strerror (err));
-
- c->fd = 69;
-
- /* test buffer free qid 0 (positive) */
- qid = 0;
- mq = &c->rx_queues[qid];
- ring = mq->ring;
- ring->head += 10;
-
- bufs = malloc (sizeof (memif_buffer_t) * max_buf);
-
- if ((err =
- memif_rx_burst (conn, qid, bufs, max_buf, &rx)) != MEMIF_ERR_SUCCESS)
- ck_abort_msg ("err code: %u, err msg: %s", err, memif_strerror (err));
-
- ck_assert_uint_eq (rx, max_buf);
- for (i = 0; i < max_buf; i++)
- ck_assert_ptr_ne (bufs[i].data, NULL);
-
- if ((err =
- memif_buffer_free (conn, qid, bufs, max_buf,
- &buf)) != MEMIF_ERR_SUCCESS)
- ck_abort_msg ("err code: %u, err msg: %s", err, memif_strerror (err));
-
- ck_assert_uint_eq (buf, max_buf);
- for (i = 0; i < max_buf; i++)
- ck_assert_ptr_eq (bufs[i].data, NULL);
- ck_assert_uint_eq (ring->head, ring->tail);
-
- /* test buffer free qid 1 (positive) */
- qid = 1;
- mq = &c->rx_queues[qid];
- ring = mq->ring;
- ring->head += 10;
-
- free (bufs);
- bufs = malloc (sizeof (memif_buffer_t) * max_buf);
-
- if ((err =
- memif_rx_burst (conn, qid, bufs, max_buf, &rx)) != MEMIF_ERR_SUCCESS)
- ck_abort_msg ("err code: %u, err msg: %s", err, memif_strerror (err));
-
- ck_assert_uint_eq (rx, max_buf);
- for (i = 0; i < max_buf; i++)
- ck_assert_ptr_ne (bufs[i].data, NULL);
-
- if ((err =
- memif_buffer_free (conn, qid, bufs, max_buf,
- &buf)) != MEMIF_ERR_SUCCESS)
- ck_abort_msg ("err code: %u, err msg: %s", err, memif_strerror (err));
-
- ck_assert_uint_eq (buf, max_buf);
- for (i = 0; i < max_buf; i++)
- ck_assert_ptr_eq (bufs[i].data, NULL);
- ck_assert_uint_eq (ring->head, ring->tail);
-
-
- /* test buffer free qid 2 (negative) */
- qid = 2;
- free (bufs);
- bufs = malloc (sizeof (memif_buffer_t) * max_buf);
-
- if ((err =
- memif_buffer_free (conn, qid, bufs, max_buf,
- &buf)) != MEMIF_ERR_SUCCESS)
- ck_assert_msg (err == MEMIF_ERR_QID, "err code: %u, err msg: %s", err,
- memif_strerror (err));
-
- if (lm->timerfd > 0)
- close (lm->timerfd);
- lm->timerfd = -1;
- free (bufs);
- bufs = NULL;
-
- memif_delete (&conn);
- ck_assert_ptr_eq (conn, NULL);
-}
-
-END_TEST
START_TEST (test_get_details)
{
int err, i;
@@ -810,12 +688,11 @@ START_TEST (test_get_details)
libmemif_main_t *lm = &libmemif_main;
if ((err =
- memif_init (control_fd_update, TEST_APP_NAME)) != MEMIF_ERR_SUCCESS)
+ memif_init (control_fd_update, TEST_APP_NAME, NULL,
+ NULL)) != MEMIF_ERR_SUCCESS)
ck_abort_msg ("err code: %u, err msg: %s", err, memif_strerror (err));
strncpy ((char *) args.interface_name, TEST_IF_NAME, strlen (TEST_IF_NAME));
- strncpy ((char *) args.instance_name, TEST_APP_NAME,
- strlen (TEST_APP_NAME));
if ((err = memif_create (&conn, &args, on_connect,
on_disconnect, on_interrupt,
@@ -842,7 +719,6 @@ START_TEST (test_get_details)
ck_abort_msg ("err code: %u, err msg: %s", err, memif_strerror (err));
ck_assert_str_eq (md.if_name, c->args.interface_name);
- ck_assert_str_eq (md.inst_name, c->args.instance_name);
ck_assert_str_eq (md.remote_if_name, c->remote_if_name);
ck_assert_str_eq (md.remote_inst_name, c->remote_name);
ck_assert_str_eq (md.secret, c->args.secret);
@@ -889,12 +765,11 @@ START_TEST (test_init_regions_and_queues)
libmemif_main_t *lm = &libmemif_main;
if ((err =
- memif_init (control_fd_update, TEST_APP_NAME)) != MEMIF_ERR_SUCCESS)
+ memif_init (control_fd_update, TEST_APP_NAME, NULL,
+ NULL)) != MEMIF_ERR_SUCCESS)
ck_abort_msg ("err code: %u, err msg: %s", err, memif_strerror (err));
strncpy ((char *) args.interface_name, TEST_IF_NAME, strlen (TEST_IF_NAME));
- strncpy ((char *) args.instance_name, TEST_APP_NAME,
- strlen (TEST_APP_NAME));
if ((err = memif_create (&conn, &args, on_connect,
on_disconnect, on_interrupt,
@@ -945,12 +820,11 @@ START_TEST (test_connect1)
libmemif_main_t *lm = &libmemif_main;
if ((err =
- memif_init (control_fd_update, TEST_APP_NAME)) != MEMIF_ERR_SUCCESS)
+ memif_init (control_fd_update, TEST_APP_NAME, NULL,
+ NULL)) != MEMIF_ERR_SUCCESS)
ck_abort_msg ("err code: %u, err msg: %s", err, memif_strerror (err));
strncpy ((char *) args.interface_name, TEST_IF_NAME, strlen (TEST_IF_NAME));
- strncpy ((char *) args.instance_name, TEST_APP_NAME,
- strlen (TEST_APP_NAME));
if ((err = memif_create (&conn, &args, on_connect,
on_disconnect, on_interrupt,
@@ -992,12 +866,11 @@ START_TEST (test_disconnect_internal)
libmemif_main_t *lm = &libmemif_main;
if ((err =
- memif_init (control_fd_update, TEST_APP_NAME)) != MEMIF_ERR_SUCCESS)
+ memif_init (control_fd_update, TEST_APP_NAME, NULL,
+ NULL)) != MEMIF_ERR_SUCCESS)
ck_abort_msg ("err code: %u, err msg: %s", err, memif_strerror (err));
strncpy ((char *) args.interface_name, TEST_IF_NAME, strlen (TEST_IF_NAME));
- strncpy ((char *) args.instance_name, TEST_APP_NAME,
- strlen (TEST_APP_NAME));
if ((err = memif_create (&conn, &args, on_connect,
on_disconnect, on_interrupt,
@@ -1038,7 +911,8 @@ START_TEST (test_disconnect_internal)
ck_assert_ptr_eq (conn, NULL);
}
-END_TEST Suite * main_suite ()
+END_TEST Suite *
+main_suite ()
{
Suite *s;
@@ -1060,7 +934,6 @@ END_TEST Suite * main_suite ()
tcase_add_test (tc_api, test_buffer_alloc);
tcase_add_test (tc_api, test_tx_burst);
tcase_add_test (tc_api, test_rx_burst);
- tcase_add_test (tc_api, test_buffer_free);
tcase_add_test (tc_api, test_get_details);
/* create internal test case */
diff --git a/extras/libmemif/test/socket_test.c b/extras/libmemif/test/socket_test.c
index f148495afb2..720d68630d4 100644
--- a/extras/libmemif/test/socket_test.c
+++ b/extras/libmemif/test/socket_test.c
@@ -46,10 +46,17 @@ queue_free (memif_msg_queue_elt_t ** e)
START_TEST (test_msg_queue)
{
+ int err;
+ if ((err =
+ memif_init (control_fd_update, TEST_APP_NAME, NULL,
+ NULL)) != MEMIF_ERR_SUCCESS)
+ ck_abort_msg ("err code: %u, err msg: %s", err, memif_strerror (err));
+
memif_connection_t conn;
conn.msg_queue = NULL;
conn.fd = -1;
+
int i, len = 10;
for (i = 0; i < len; i++)
@@ -88,6 +95,10 @@ END_TEST
START_TEST (test_enq_ack)
{
int err;
+ if ((err =
+ memif_init (control_fd_update, TEST_APP_NAME, NULL,
+ NULL)) != MEMIF_ERR_SUCCESS)
+ ck_abort_msg ("err code: %u, err msg: %s", err, memif_strerror (err));
memif_connection_t conn;
conn.msg_queue = NULL;
@@ -104,14 +115,16 @@ END_TEST
START_TEST (test_enq_init)
{
int err;
+ if ((err =
+ memif_init (control_fd_update, TEST_APP_NAME, NULL,
+ NULL)) != MEMIF_ERR_SUCCESS)
+ ck_abort_msg ("err code: %u, err msg: %s", err, memif_strerror (err));
memif_connection_t conn;
conn.msg_queue = NULL;
conn.args.interface_id = 69;
conn.args.mode = 0;
- strncpy ((char *) conn.args.instance_name, TEST_APP_NAME,
- strlen (TEST_APP_NAME));
strncpy ((char *) conn.args.secret, TEST_SECRET, strlen (TEST_SECRET));
if ((err = memif_msg_enq_init (&conn)) != MEMIF_ERR_SUCCESS)
@@ -127,7 +140,6 @@ START_TEST (test_enq_init)
ck_assert_uint_eq (i->version, MEMIF_VERSION);
ck_assert_uint_eq (i->id, conn.args.interface_id);
ck_assert_uint_eq (i->mode, conn.args.mode);
- ck_assert_str_eq (i->name, conn.args.instance_name);
ck_assert_str_eq (i->secret, conn.args.secret);
queue_free (&conn.msg_queue);
}
@@ -136,6 +148,10 @@ END_TEST
START_TEST (test_enq_add_region)
{
int err;
+ if ((err =
+ memif_init (control_fd_update, TEST_APP_NAME, NULL,
+ NULL)) != MEMIF_ERR_SUCCESS)
+ ck_abort_msg ("err code: %u, err msg: %s", err, memif_strerror (err));
memif_connection_t conn;
conn.msg_queue = NULL;
conn.regions = (memif_region_t *) malloc (sizeof (memif_region_t));
@@ -168,6 +184,11 @@ END_TEST
START_TEST (test_enq_add_ring)
{
int err;
+ if ((err =
+ memif_init (control_fd_update, TEST_APP_NAME, NULL,
+ NULL)) != MEMIF_ERR_SUCCESS)
+ ck_abort_msg ("err code: %u, err msg: %s", err, memif_strerror (err));
+
memif_connection_t conn;
conn.msg_queue = NULL;
conn.rx_queues = (memif_queue_t *) malloc (sizeof (memif_queue_t));
@@ -204,6 +225,10 @@ END_TEST
START_TEST (test_enq_connect)
{
int err;
+ if ((err =
+ memif_init (control_fd_update, TEST_APP_NAME, NULL,
+ NULL)) != MEMIF_ERR_SUCCESS)
+ ck_abort_msg ("err code: %u, err msg: %s", err, memif_strerror (err));
memif_connection_t conn;
conn.msg_queue = NULL;
memset (conn.args.interface_name, 0, sizeof (conn.args.interface_name));
@@ -225,6 +250,10 @@ END_TEST
START_TEST (test_enq_connected)
{
int err;
+ if ((err =
+ memif_init (control_fd_update, TEST_APP_NAME, NULL,
+ NULL)) != MEMIF_ERR_SUCCESS)
+ ck_abort_msg ("err code: %u, err msg: %s", err, memif_strerror (err));
memif_connection_t conn;
conn.msg_queue = NULL;
memset (conn.args.interface_name, 0, sizeof (conn.args.interface_name));
@@ -261,12 +290,10 @@ START_TEST (test_send_hello)
int err;
memif_connection_t conn;
conn.fd = -1;
- memset (conn.args.instance_name, 0, sizeof (conn.args.instance_name));
- strncpy ((char *) conn.args.instance_name, TEST_APP_NAME,
- strlen (TEST_APP_NAME));
if ((err =
- memif_init (control_fd_update, TEST_APP_NAME)) != MEMIF_ERR_SUCCESS)
+ memif_init (control_fd_update, TEST_APP_NAME, NULL,
+ NULL)) != MEMIF_ERR_SUCCESS)
ck_abort_msg ("err code: %u, err msg: %s", err, memif_strerror (err));
if ((err = memif_msg_send_hello (conn.fd)) != MEMIF_ERR_SUCCESS)
@@ -363,7 +390,8 @@ START_TEST (test_recv_init)
add_list_elt (&elt, &ms.interface_list, &ms.interface_list_len);
if ((err =
- memif_init (control_fd_update, TEST_APP_NAME)) != MEMIF_ERR_SUCCESS)
+ memif_init (control_fd_update, TEST_APP_NAME, NULL,
+ NULL)) != MEMIF_ERR_SUCCESS)
ck_abort_msg ("err code: %u, err msg: %s", err, memif_strerror (err));
if ((err = memif_msg_receive_init (&ms, -1, &msg)) != MEMIF_ERR_SUCCESS)
@@ -478,7 +506,8 @@ START_TEST (test_recv_connect)
args.mode = 0;
if ((err =
- memif_init (control_fd_update, TEST_APP_NAME)) != MEMIF_ERR_SUCCESS)
+ memif_init (control_fd_update, TEST_APP_NAME, NULL,
+ NULL)) != MEMIF_ERR_SUCCESS)
ck_abort_msg ("err code: %u, err msg: %s", err, memif_strerror (err));
if ((err = memif_create (&c, &args, on_connect,
@@ -522,7 +551,8 @@ START_TEST (test_recv_connected)
args.mode = 0;
if ((err =
- memif_init (control_fd_update, TEST_APP_NAME)) != MEMIF_ERR_SUCCESS)
+ memif_init (control_fd_update, TEST_APP_NAME, NULL,
+ NULL)) != MEMIF_ERR_SUCCESS)
ck_abort_msg ("err code: %u, err msg: %s", err, memif_strerror (err));
if ((err = memif_create (&c, &args, on_connect,
@@ -570,7 +600,8 @@ START_TEST (test_recv_disconnect)
ck_assert_str_eq (conn.remote_disconnect_string, "unit_test_dc");
}
-END_TEST Suite * socket_suite ()
+END_TEST Suite *
+socket_suite ()
{
Suite *s;
TCase *tc_msg_queue;
diff --git a/extras/libmemif/test/unit_test.h b/extras/libmemif/test/unit_test.h
index fae3cbaae2a..a24887d7fca 100644
--- a/extras/libmemif/test/unit_test.h
+++ b/extras/libmemif/test/unit_test.h
@@ -21,6 +21,7 @@
#include <stdlib.h>
#include <check.h>
+#include <memif.h>
#include <libmemif.h>
#define TEST_APP_NAME "unit_test_app"