Motr  M0
lnet_ut.c File Reference
#include "net/lnet/lnet_main.c"
#include "lib/trace.h"
#include "lib/assert.h"
#include "lib/arith.h"
#include "lib/thread.h"
#include "ut/ut.h"
Include dependency graph for lnet_ut.c:

Go to the source code of this file.

Data Structures

struct  ut_data
 

Macros

#define M0_TRACE_SUBSYSTEM   M0_TRACE_SUBSYS_UT
 
#define zvUT(x, expRC)
 
#define zUT(x)   zvUT(x, 0)
 
#define PAGE_SIZE   (1UL << PAGE_SHIFT)
 
#define DOM1   (&td->dom1)
 
#define DOM2   (&td->dom2)
 
#define TM1   (&td->tm1)
 
#define TM2   (&td->tm2)
 
#define CBD1   (&td->cbd1)
 
#define CBD2   (&td->cbd2)
 
#define SETUP_DOM(which)
 
#define TEARDOWN_DOM(which)
 
#define RESET_RECV_COUNTERS()
 
#define TEST_MATCH_BIT_ENCODE(_t, _c)
 
#define VALIDATE_MATCH_BITS(mb, s_lctm)
 

Typedefs

typedef void(* ut_test_fw_body_t) (struct ut_data *td)
 
typedef void(* ut_test_fw_prestart_cb_t) (struct ut_data *td, int which)
 

Enumerations

enum  {
  STARTSTOP_DOM_NR = 3, STARTSTOP_PID = 12345, STARTSTOP_PORTAL = 30, STARTSTOP_STAT_SECS = 3,
  STARTSTOP_STAT_PER_PERIOD = 1, STARTSTOP_STAT_BUF_NR = 4
}
 
enum  { UT_CB_INVALID_STATUS = 9999999 }
 
enum  {
  UT_BUFS1 = 2, UT_BUFSEGS1 = 4, UT_BUFS2 = 1, UT_BUFSEGS2 = 2,
  UT_MSG_SIZE = PAGE_SIZE / 2, UT_BULK_SIZE = 2 * PAGE_SIZE, UT_PAGE_SHIFT = PAGE_SHIFT
}
 
enum  { UT_MSG_OPS = 4 }
 

Functions

static void ut_save_subs (void)
 
static void ut_restore_subs (void)
 
static bool ut_chan_timedwait (struct m0_clink *link, uint32_t secs)
 
static void ut_net_buffer_sign (struct m0_net_buffer *nb, m0_bcount_t len, unsigned char seed)
 
static bool ut_net_buffer_authenticate (struct m0_net_buffer *nb, m0_bcount_t len, m0_bcount_t offset, unsigned char seed)
 
static void ecb_reset (void)
 
static void ut_tm_ecb (const struct m0_net_tm_event *ev)
 
static void ut_buf_cb1 (const struct m0_net_buffer_event *ev)
 
static void ut_cbreset1 (void)
 
static void ut_buf_cb2 (const struct m0_net_buffer_event *ev)
 
static void ut_cbreset2 (void)
 
static void ut_cbreset (void)
 
static void ut_test_framework_dom_cleanup (struct ut_data *td, struct m0_net_domain *dom)
 
static void ut_test_framework (ut_test_fw_body_t body, ut_test_fw_prestart_cb_t ps_cb, int dbg)
 
static int test_lnet_init (void)
 
static int test_lnet_fini (void)
 
static void ntc_event_callback (const struct m0_net_tm_event *ev)
 
static void test_fail (void)
 
static void test_tm_initfini (void)
 
static void test_tm_startstop (void)
 
static bool test_msg_send_loop (struct ut_data *td, uint32_t num_recv_bufs, uint32_t recv_max_msgs, struct m0_net_end_point *ep2, m0_bcount_t send_len_first, m0_bcount_t send_len_rest, bool space_exhausted)
 
static void test_msg_body (struct ut_data *td)
 
static void test_msg (void)
 
static void test_buf_desc_body (struct ut_data *td)
 
static void test_buf_desc (void)
 
static int test_bulk_passive_send (struct ut_data *td)
 
static int test_bulk_passive_recv (struct ut_data *td)
 
static void test_bulk_body (struct ut_data *td)
 
static void test_bulk (void)
 
static void test_sync_msg_send_cb2 (const struct m0_net_buffer_event *ev)
 
static void test_sync_msg_recv_cb1 (const struct m0_net_buffer_event *ev)
 
static void test_sync_body (struct ut_data *td)
 
static void test_sync_prestart (struct ut_data *td, int which)
 
static void test_sync (void)
 
static void test_timeout_msg_recv_cb1 (const struct m0_net_buffer_event *ev)
 
static m0_time_t test_timeout_tm_get_buffer_timeout_tick (const struct m0_net_transfer_mc *tm)
 
static int test_timeout_tm_timeout_buffers (struct m0_net_transfer_mc *tm, m0_time_t now)
 
static void test_timeout_body (struct ut_data *td)
 
static void test_timeout (void)
 

Variables

static int ut_verbose = 0
 
static int ut_subs_saved
 
static struct nlx_xo_interceptable_subs saved_xo_subs
 
static enum m0_net_tm_ev_type ecb_evt
 
static enum m0_net_tm_state ecb_tms
 
static int32_t ecb_status
 
static int ecb_count
 
static enum m0_net_queue_type cb_qt1
 
static struct m0_net_buffercb_nb1
 
static int32_t cb_status1
 
static m0_bcount_t cb_length1
 
static m0_bindex_t cb_offset1
 
static bool cb_save_ep1
 
static struct m0_net_end_pointcb_ep1
 
static unsigned cb_called1
 
static enum m0_net_queue_type cb_qt2
 
static struct m0_net_buffercb_nb2
 
static int32_t cb_status2
 
static m0_bcount_t cb_length2
 
static m0_bindex_t cb_offset2
 
static bool cb_save_ep2
 
static struct m0_net_end_pointcb_ep2
 
static unsigned cb_called2
 
static struct m0_threadtest_sync_ut_handle
 
static struct m0_atomic64 test_timeout_ttb_called
 
static struct m0_atomic64 test_timeout_ttb_retval
 
struct m0_ut_suite m0_net_lnet_ut
 

Macro Definition Documentation

◆ CBD1

#define CBD1   (&td->cbd1)

Definition at line 322 of file lnet_ut.c.

◆ CBD2

#define CBD2   (&td->cbd2)

Definition at line 323 of file lnet_ut.c.

◆ DOM1

#define DOM1   (&td->dom1)

Definition at line 318 of file lnet_ut.c.

◆ DOM2

#define DOM2   (&td->dom2)

Definition at line 319 of file lnet_ut.c.

◆ M0_TRACE_SUBSYSTEM

#define M0_TRACE_SUBSYSTEM   M0_TRACE_SUBSYS_UT

Definition at line 25 of file lnet_ut.c.

◆ PAGE_SIZE

#define PAGE_SIZE   (1UL << PAGE_SHIFT)

Definition at line 277 of file lnet_ut.c.

◆ RESET_RECV_COUNTERS

#define RESET_RECV_COUNTERS ( )
Value:
do { \
offset = 0; \
bevs_left = recv_max_msgs; \
/* 1 buf only as all recv space not used */ \
space_left = td->buf_size1; \
} while (0)

◆ SETUP_DOM

#define SETUP_DOM (   which)

◆ TEARDOWN_DOM

#define TEARDOWN_DOM (   which)
Value:
do { \
struct m0_net_domain *dom; \
struct m0_net_transfer_mc *tm = &td->tm ## which; \
m0_clink_add_lock(&tm->ntm_chan, &td->tmwait ## which); \
M0_UT_ASSERT(!m0_net_tm_stop(tm, false)); \
m0_chan_wait(&td->tmwait ## which); \
m0_clink_del_lock(&td->tmwait ## which); \
M0_UT_ASSERT(tm->ntm_state == M0_NET_TM_STOPPED); \
fini ## which: \
tm = &td->tm ## which; \
m0_net_tm_fini(tm); \
dereg ## which: \
dom = &td->dom ## which; \
for (i = 0; i < UT_BUFS ## which; ++i) { \
struct m0_net_buffer *nb; \
nb = &td->bufs ## which [i]; \
if (nb->nb_buffer.ov_vec.v_nr == 0) \
continue; \
m0_net_buffer_deregister(nb, dom); \
m0_bufvec_free_aligned(&nb->nb_buffer, UT_PAGE_SHIFT); \
} \
if (td->nidstrs ## which != NULL) \
m0_net_lnet_ifaces_put(dom, &td->nidstrs ## which); \
M0_UT_ASSERT(td->nidstrs ## which == NULL); \
m0_net_domain_fini(dom); \
} while (0)
#define NULL
Definition: misc.h:38
int i
Definition: dir.c:1033
static struct m0_stob_domain * dom
Definition: storage.c:38
M0_INTERNAL int m0_net_tm_stop(struct m0_net_transfer_mc *tm, bool abort)
Definition: tm.c:293

◆ TEST_MATCH_BIT_ENCODE

#define TEST_MATCH_BIT_ENCODE (   _t,
  _c 
)
Value:
&tmid, &counter); \
M0_UT_ASSERT(tmid == (_t)); \
M0_UT_ASSERT(counter == (_c))
static void nlx_core_match_bits_decode(uint64_t mb, uint32_t *tmid, uint64_t *counter)
Definition: lnet_core.c:258
static int counter
Definition: mutex.c:32
static uint64_t nlx_core_match_bits_encode(uint32_t tmid, uint64_t counter)
Definition: lnet_core.c:243

◆ TM1

#define TM1   (&td->tm1)

Definition at line 320 of file lnet_ut.c.

◆ TM2

#define TM2   (&td->tm2)

Definition at line 321 of file lnet_ut.c.

◆ VALIDATE_MATCH_BITS

#define VALIDATE_MATCH_BITS (   mb,
  s_lctm 
)
Value:
M0_UT_ASSERT(tmid == s_lctm->ctm_addr.cepa_tmid); \
M0_UT_ASSERT(counter == s_lctm->ctm_mb_counter - 1)
static void nlx_core_match_bits_decode(uint64_t mb, uint32_t *tmid, uint64_t *counter)
Definition: lnet_core.c:258
struct mock_balloc mb
Definition: ad.c:173
static int counter
Definition: mutex.c:32

◆ zUT

#define zUT (   x)    zvUT(x, 0)

Definition at line 266 of file lnet_ut.c.

◆ zvUT

#define zvUT (   x,
  expRC 
)
Value:
do { \
int rc = x; \
int erc = expRC; \
if (rc != erc) \
M0_ASSERT_INFO(rc == erc, "%d != %d (%s : %s)", \
rc, erc, #x, #expRC); \
} while (0)
static bool x
Definition: sm.c:168
int32_t rc
Definition: trigger_fop.h:47

Definition at line 258 of file lnet_ut.c.

Typedef Documentation

◆ ut_test_fw_body_t

typedef void(* ut_test_fw_body_t) (struct ut_data *td)

Definition at line 325 of file lnet_ut.c.

◆ ut_test_fw_prestart_cb_t

typedef void(* ut_test_fw_prestart_cb_t) (struct ut_data *td, int which)

Definition at line 326 of file lnet_ut.c.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
STARTSTOP_DOM_NR 
STARTSTOP_PID 
STARTSTOP_PORTAL 
STARTSTOP_STAT_SECS 
STARTSTOP_STAT_PER_PERIOD 
STARTSTOP_STAT_BUF_NR 

Definition at line 154 of file lnet_ut.c.

◆ anonymous enum

anonymous enum
Enumerator
UT_CB_INVALID_STATUS 

Definition at line 183 of file lnet_ut.c.

◆ anonymous enum

anonymous enum
Enumerator
UT_BUFS1 
UT_BUFSEGS1 
UT_BUFS2 
UT_BUFSEGS2 
UT_MSG_SIZE 
UT_BULK_SIZE 
UT_PAGE_SHIFT 

Definition at line 280 of file lnet_ut.c.

◆ anonymous enum

anonymous enum
Enumerator
UT_MSG_OPS 

Definition at line 895 of file lnet_ut.c.

Function Documentation

◆ ecb_reset()

static void ecb_reset ( void  )
static

Definition at line 138 of file lnet_ut.c.

Here is the caller graph for this function:

◆ ntc_event_callback()

static void ntc_event_callback ( const struct m0_net_tm_event ev)
static

Definition at line 605 of file lnet_ut.c.

Here is the caller graph for this function:

◆ test_buf_desc()

static void test_buf_desc ( void  )
static

Definition at line 1514 of file lnet_ut.c.

Here is the call graph for this function:

◆ test_buf_desc_body()

static void test_buf_desc_body ( struct ut_data td)
static

Definition at line 1248 of file lnet_ut.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ test_bulk()

static void test_bulk ( void  )
static

Definition at line 1798 of file lnet_ut.c.

Here is the call graph for this function:

◆ test_bulk_body()

static void test_bulk_body ( struct ut_data td)
static

Definition at line 1728 of file lnet_ut.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ test_bulk_passive_recv()

static int test_bulk_passive_recv ( struct ut_data td)
static

Definition at line 1625 of file lnet_ut.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ test_bulk_passive_send()

static int test_bulk_passive_send ( struct ut_data td)
static

Definition at line 1519 of file lnet_ut.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ test_fail()

static void test_fail ( void  )
static

Definition at line 610 of file lnet_ut.c.

Here is the call graph for this function:

◆ test_lnet_fini()

static int test_lnet_fini ( void  )
static

Definition at line 596 of file lnet_ut.c.

Here is the call graph for this function:

◆ test_lnet_init()

static int test_lnet_init ( void  )
static

Definition at line 572 of file lnet_ut.c.

Here is the call graph for this function:

◆ test_msg()

static void test_msg ( void  )
static

Definition at line 1243 of file lnet_ut.c.

Here is the call graph for this function:

◆ test_msg_body()

static void test_msg_body ( struct ut_data td)
static

Definition at line 1068 of file lnet_ut.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ test_msg_send_loop()

static bool test_msg_send_loop ( struct ut_data td,
uint32_t  num_recv_bufs,
uint32_t  recv_max_msgs,
struct m0_net_end_point ep2,
m0_bcount_t  send_len_first,
m0_bcount_t  send_len_rest,
bool  space_exhausted 
)
static

Definition at line 903 of file lnet_ut.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ test_sync()

static void test_sync ( void  )
static

Definition at line 1967 of file lnet_ut.c.

Here is the call graph for this function:

◆ test_sync_body()

static void test_sync_body ( struct ut_data td)
static

Definition at line 1832 of file lnet_ut.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ test_sync_msg_recv_cb1()

static void test_sync_msg_recv_cb1 ( const struct m0_net_buffer_event ev)
static

Definition at line 1821 of file lnet_ut.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ test_sync_msg_send_cb2()

static void test_sync_msg_send_cb2 ( const struct m0_net_buffer_event ev)
static

Definition at line 1812 of file lnet_ut.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ test_sync_prestart()

static void test_sync_prestart ( struct ut_data td,
int  which 
)
static

Definition at line 1959 of file lnet_ut.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ test_timeout()

static void test_timeout ( void  )
static

Definition at line 2215 of file lnet_ut.c.

Here is the call graph for this function:

◆ test_timeout_body()

static void test_timeout_body ( struct ut_data td)
static

Definition at line 2002 of file lnet_ut.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ test_timeout_msg_recv_cb1()

static void test_timeout_msg_recv_cb1 ( const struct m0_net_buffer_event ev)
static

Definition at line 1974 of file lnet_ut.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ test_timeout_tm_get_buffer_timeout_tick()

static m0_time_t test_timeout_tm_get_buffer_timeout_tick ( const struct m0_net_transfer_mc tm)
static

Definition at line 1983 of file lnet_ut.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ test_timeout_tm_timeout_buffers()

static int test_timeout_tm_timeout_buffers ( struct m0_net_transfer_mc tm,
m0_time_t  now 
)
static

Definition at line 1991 of file lnet_ut.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ test_tm_initfini()

static void test_tm_initfini ( void  )
static

Definition at line 645 of file lnet_ut.c.

Here is the call graph for this function:

◆ test_tm_startstop()

static void test_tm_startstop ( void  )
static

Definition at line 732 of file lnet_ut.c.

Here is the call graph for this function:

◆ ut_buf_cb1()

static void ut_buf_cb1 ( const struct m0_net_buffer_event ev)
static

Definition at line 185 of file lnet_ut.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ut_buf_cb2()

static void ut_buf_cb2 ( const struct m0_net_buffer_event ev)
static

Definition at line 223 of file lnet_ut.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ut_cbreset()

static void ut_cbreset ( void  )
static

Definition at line 252 of file lnet_ut.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ut_cbreset1()

static void ut_cbreset1 ( void  )
static

Definition at line 202 of file lnet_ut.c.

Here is the caller graph for this function:

◆ ut_cbreset2()

static void ut_cbreset2 ( void  )
static

Definition at line 240 of file lnet_ut.c.

Here is the caller graph for this function:

◆ ut_chan_timedwait()

static bool ut_chan_timedwait ( struct m0_clink link,
uint32_t  secs 
)
static

Definition at line 61 of file lnet_ut.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ut_net_buffer_authenticate()

static bool ut_net_buffer_authenticate ( struct m0_net_buffer nb,
m0_bcount_t  len,
m0_bcount_t  offset,
unsigned char  seed 
)
static

Definition at line 94 of file lnet_ut.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ut_net_buffer_sign()

static void ut_net_buffer_sign ( struct m0_net_buffer nb,
m0_bcount_t  len,
unsigned char  seed 
)
static

Definition at line 68 of file lnet_ut.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ut_restore_subs()

static void ut_restore_subs ( void  )
static

Definition at line 52 of file lnet_ut.c.

Here is the caller graph for this function:

◆ ut_save_subs()

static void ut_save_subs ( void  )
static

Definition at line 41 of file lnet_ut.c.

Here is the caller graph for this function:

◆ ut_test_framework()

static void ut_test_framework ( ut_test_fw_body_t  body,
ut_test_fw_prestart_cb_t  ps_cb,
int  dbg 
)
static

Definition at line 426 of file lnet_ut.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ut_test_framework_dom_cleanup()

static void ut_test_framework_dom_cleanup ( struct ut_data td,
struct m0_net_domain dom 
)
static

Definition at line 328 of file lnet_ut.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ut_tm_ecb()

static void ut_tm_ecb ( const struct m0_net_tm_event ev)
static

Definition at line 146 of file lnet_ut.c.

Here is the caller graph for this function:

Variable Documentation

◆ cb_called1

unsigned cb_called1
static

Definition at line 182 of file lnet_ut.c.

◆ cb_called2

unsigned cb_called2
static

Definition at line 221 of file lnet_ut.c.

◆ cb_ep1

struct m0_net_end_point* cb_ep1
static

Definition at line 181 of file lnet_ut.c.

◆ cb_ep2

struct m0_net_end_point* cb_ep2
static

Definition at line 220 of file lnet_ut.c.

◆ cb_length1

m0_bcount_t cb_length1
static

Definition at line 178 of file lnet_ut.c.

◆ cb_length2

m0_bcount_t cb_length2
static

Definition at line 217 of file lnet_ut.c.

◆ cb_nb1

struct m0_net_buffer* cb_nb1
static

Definition at line 176 of file lnet_ut.c.

◆ cb_nb2

struct m0_net_buffer* cb_nb2
static

Definition at line 215 of file lnet_ut.c.

◆ cb_offset1

m0_bindex_t cb_offset1
static

Definition at line 179 of file lnet_ut.c.

◆ cb_offset2

m0_bindex_t cb_offset2
static

Definition at line 218 of file lnet_ut.c.

◆ cb_qt1

enum m0_net_queue_type cb_qt1
static

Definition at line 175 of file lnet_ut.c.

◆ cb_qt2

enum m0_net_queue_type cb_qt2
static

Definition at line 214 of file lnet_ut.c.

◆ cb_save_ep1

bool cb_save_ep1
static

Definition at line 180 of file lnet_ut.c.

◆ cb_save_ep2

bool cb_save_ep2
static

Definition at line 219 of file lnet_ut.c.

◆ cb_status1

int32_t cb_status1
static

Definition at line 177 of file lnet_ut.c.

◆ cb_status2

int32_t cb_status2
static

Definition at line 216 of file lnet_ut.c.

◆ ecb_count

int ecb_count
static

Definition at line 137 of file lnet_ut.c.

◆ ecb_evt

enum m0_net_tm_ev_type ecb_evt
static

Definition at line 134 of file lnet_ut.c.

◆ ecb_status

int32_t ecb_status
static

Definition at line 136 of file lnet_ut.c.

◆ ecb_tms

enum m0_net_tm_state ecb_tms
static

Definition at line 135 of file lnet_ut.c.

◆ m0_net_lnet_ut

struct m0_ut_suite m0_net_lnet_ut
Initial value:
= {
.ts_name = "net-lnet",
.ts_init = test_lnet_init,
.ts_fini = test_lnet_fini,
.ts_tests = {
{ "net_lnet_fail", test_fail },
{ "net_lnet_tm_initfini", test_tm_initfini },
{ "net_lnet_tm_startstop", test_tm_startstop },
{ "net_lnet_msg", test_msg },
{ "net_lnet_buf_desc", test_buf_desc },
{ "net_lnet_bulk", test_bulk },
{ "net_lnet_sync", test_sync },
{ "net_lnet_timeout", test_timeout },
{ NULL, NULL }
}
}
#define NULL
Definition: misc.h:38
static void test_tm_initfini(void)
Definition: lnet_ut.c:645
static void test_msg(void)
Definition: lnet_ut.c:1243
static int test_lnet_fini(void)
Definition: lnet_ut.c:596
static int test_lnet_init(void)
Definition: lnet_ut.c:572
static void test_fail(void)
Definition: lnet_ut.c:610
static void test_tm_startstop(void)
Definition: lnet_ut.c:732
static void test_sync(void)
Definition: lnet_ut.c:1967
static void test_bulk(void)
Definition: lnet_ut.c:1798
static void test_buf_desc(void)
Definition: lnet_ut.c:1514
static void test_timeout(void)
Definition: lnet_ut.c:2215

Definition at line 2231 of file lnet_ut.c.

◆ saved_xo_subs

struct nlx_xo_interceptable_subs saved_xo_subs
static

Definition at line 36 of file lnet_ut.c.

◆ test_sync_ut_handle

struct m0_thread* test_sync_ut_handle
static

Definition at line 1809 of file lnet_ut.c.

◆ test_timeout_ttb_called

struct m0_atomic64 test_timeout_ttb_called
static

Definition at line 1989 of file lnet_ut.c.

◆ test_timeout_ttb_retval

struct m0_atomic64 test_timeout_ttb_retval
static

Definition at line 1990 of file lnet_ut.c.

◆ ut_subs_saved

int ut_subs_saved
static

Definition at line 35 of file lnet_ut.c.

◆ ut_verbose

int ut_verbose = 0
static

Definition at line 33 of file lnet_ut.c.