Motr  M0
commands.c File Reference
#include "ut/ut.h"
#include "lib/misc.h"
#include "lib/semaphore.h"
#include "lib/memory.h"
#include "lib/time.h"
#include "lib/errno.h"
#include "net/lnet/lnet.h"
#include "net/test/commands.h"
Include dependency graph for commands.c:

Go to the source code of this file.

Data Structures

struct  net_test_cmd_node
 

Enumerations

enum  {
  NTC_TMID_START = 300, NTC_TMID_CONSOLE = NTC_TMID_START, NTC_TMID_NODE = NTC_TMID_CONSOLE + 1, NTC_MULTIPLE_NODES = 64,
  NTC_MULTIPLE_COMMANDS = 32, NTC_ADDR_LEN_MAX = 0x100, NTC_TIMEOUT_MS = 1000, NTC_CMD_RECV_WAIT_NS = 25000000
}
 

Functions

static m0_time_t timeout_get (void)
 
static m0_time_t timeout_get_abs (void)
 
static int make_addr (char *s, size_t s_len, int svc_id, bool add_comma)
 
static void fill_addr (uint32_t nr)
 
static bool commands_ut_assert (struct net_test_cmd_node *node, bool value)
 
static void barrier_init (struct net_test_cmd_node *node)
 
static void barrier_fini (struct net_test_cmd_node *node)
 
static void barrier_with_main (struct net_test_cmd_node *node)
 
static void barrier_with_nodes (void)
 
static void barrier_disable (struct net_test_cmd_node *node)
 
static void flags_reset (size_t nr)
 
static void flag_set (int index)
 
static bool is_flags_set (size_t nr, bool set)
 
static bool is_flags_set_odd (size_t nr)
 
static void commands_ut_send (struct net_test_cmd_node *node, struct m0_net_test_cmd_ctx *ctx)
 
static void commands_ut_recv (struct net_test_cmd_node *node, struct m0_net_test_cmd_ctx *ctx, m0_time_t deadline, ssize_t *ep_index)
 
static void commands_ut_recv_type (struct net_test_cmd_node *node, struct m0_net_test_cmd_ctx *ctx, m0_time_t deadline, enum m0_net_test_cmd_type type)
 
static void commands_node_thread (struct net_test_cmd_node *node)
 
static void send_all (size_t nr, struct m0_net_test_cmd *cmd)
 
static void commands_ut_send_all (size_t nr)
 
static void commands_ut_send_all_type (size_t nr, enum m0_net_test_cmd_type type)
 
static void commands_ut_recv_all (size_t nr, m0_time_t deadline)
 
static void net_test_command_ut (size_t nr)
 
void m0_net_test_cmd_ut_single (void)
 
void m0_net_test_cmd_ut_multiple (void)
 
static void commands_node_loop (struct net_test_cmd_node *node, struct m0_net_test_cmd *cmd)
 
static void commands_console_loop (struct net_test_cmd_node *node, struct m0_net_test_cmd *cmd)
 
static void commands_node_thread2 (struct net_test_cmd_node *node)
 
void m0_net_test_cmd_ut_multiple2 (void)
 

Variables

static const char NTC_ADDR [] = "0@lo:12345:42:%d"
 
static const size_t NTC_ADDR_LEN = ARRAY_SIZE(NTC_ADDR)
 
static const char NTC_DELIM = ','
 
static char addr_console [NTC_ADDR_LEN_MAX]
 
static char addr_node [NTC_ADDR_LEN_MAX *NTC_MULTIPLE_NODES]
 
static struct m0_net_test_slist slist_node
 
static struct m0_net_test_slist slist_console
 
static struct net_test_cmd_nodenode
 
static struct m0_net_test_cmd_ctx console
 
static struct net_test_cmd_node nodes [NTC_MULTIPLE_NODES]
 

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
NTC_TMID_START 
NTC_TMID_CONSOLE 
NTC_TMID_NODE 
NTC_MULTIPLE_NODES 
NTC_MULTIPLE_COMMANDS 
NTC_ADDR_LEN_MAX 
NTC_TIMEOUT_MS 
NTC_CMD_RECV_WAIT_NS 

Definition at line 34 of file commands.c.

Function Documentation

◆ barrier_disable()

static void barrier_disable ( struct net_test_cmd_node node)
static

Called from the node threads.

Definition at line 189 of file commands.c.

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

◆ barrier_fini()

static void barrier_fini ( struct net_test_cmd_node node)
static

Called from the main thread.

See also
net_test_command_ut().

Definition at line 147 of file commands.c.

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

◆ barrier_init()

static void barrier_init ( struct net_test_cmd_node node)
static

Called from the main thread

Definition at line 134 of file commands.c.

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

◆ barrier_with_main()

static void barrier_with_main ( struct net_test_cmd_node node)
static

Called from the node threads.

See also
commands_node_thread().

Definition at line 157 of file commands.c.

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

◆ barrier_with_nodes()

static void barrier_with_nodes ( void  )
static

Called from the main thread. Also checks for UT failures.

See also
net_test_command_ut().

Definition at line 170 of file commands.c.

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

◆ commands_console_loop()

static void commands_console_loop ( struct net_test_cmd_node node,
struct m0_net_test_cmd cmd 
)
static

Definition at line 623 of file commands.c.

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

◆ commands_node_loop()

static void commands_node_loop ( struct net_test_cmd_node node,
struct m0_net_test_cmd cmd 
)
static

Definition at line 594 of file commands.c.

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

◆ commands_node_thread()

static void commands_node_thread ( struct net_test_cmd_node node)
static

Definition at line 309 of file commands.c.

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

◆ commands_node_thread2()

static void commands_node_thread2 ( struct net_test_cmd_node node)
static

Definition at line 663 of file commands.c.

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

◆ commands_ut_assert()

static bool commands_ut_assert ( struct net_test_cmd_node node,
bool  value 
)
static

M0_UT_ASSERT() isn't thread-safe, so node->ntcn_failures is used for assertion failure tracking. Assuming that M0_UT_ASSERT() will abort program, otherwise will be a deadlock in the barrier_with_main()/barrier_with_nodes(). Called from the node threads.

See also
command_ut_check(), commands_node_thread(), net_test_command_ut().

Definition at line 126 of file commands.c.

Here is the caller graph for this function:

◆ commands_ut_recv()

static void commands_ut_recv ( struct net_test_cmd_node node,
struct m0_net_test_cmd_ctx ctx,
m0_time_t  deadline,
ssize_t *  ep_index 
)
static

Definition at line 243 of file commands.c.

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

◆ commands_ut_recv_all()

static void commands_ut_recv_all ( size_t  nr,
m0_time_t  deadline 
)
static

Definition at line 422 of file commands.c.

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

◆ commands_ut_recv_type()

static void commands_ut_recv_type ( struct net_test_cmd_node node,
struct m0_net_test_cmd_ctx ctx,
m0_time_t  deadline,
enum m0_net_test_cmd_type  type 
)
static

Definition at line 268 of file commands.c.

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

◆ commands_ut_send()

static void commands_ut_send ( struct net_test_cmd_node node,
struct m0_net_test_cmd_ctx ctx 
)
static

Definition at line 228 of file commands.c.

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

◆ commands_ut_send_all()

static void commands_ut_send_all ( size_t  nr)
static

Definition at line 385 of file commands.c.

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

◆ commands_ut_send_all_type()

static void commands_ut_send_all_type ( size_t  nr,
enum m0_net_test_cmd_type  type 
)
static

Definition at line 394 of file commands.c.

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

◆ fill_addr()

static void fill_addr ( uint32_t  nr)
static

Fill addr_console and addr_node strings.

Definition at line 101 of file commands.c.

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

◆ flag_set()

static void flag_set ( int  index)
static

Definition at line 203 of file commands.c.

Here is the caller graph for this function:

◆ flags_reset()

static void flags_reset ( size_t  nr)
static

Definition at line 195 of file commands.c.

Here is the caller graph for this function:

◆ is_flags_set()

static bool is_flags_set ( size_t  nr,
bool  set 
)
static

Definition at line 208 of file commands.c.

Here is the caller graph for this function:

◆ is_flags_set_odd()

static bool is_flags_set_odd ( size_t  nr)
static

Definition at line 218 of file commands.c.

Here is the caller graph for this function:

◆ m0_net_test_cmd_ut_multiple()

void m0_net_test_cmd_ut_multiple ( void  )

Definition at line 589 of file commands.c.

Here is the call graph for this function:

◆ m0_net_test_cmd_ut_multiple2()

void m0_net_test_cmd_ut_multiple2 ( void  )

Definition at line 707 of file commands.c.

Here is the call graph for this function:

◆ m0_net_test_cmd_ut_single()

void m0_net_test_cmd_ut_single ( void  )

Definition at line 584 of file commands.c.

Here is the call graph for this function:

◆ make_addr()

static int make_addr ( char *  s,
size_t  s_len,
int  svc_id,
bool  add_comma 
)
static

Definition at line 86 of file commands.c.

Here is the caller graph for this function:

◆ net_test_command_ut()

static void net_test_command_ut ( size_t  nr)
static
Todo:
set callback

Definition at line 443 of file commands.c.

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

◆ send_all()

static void send_all ( size_t  nr,
struct m0_net_test_cmd cmd 
)
static

Definition at line 372 of file commands.c.

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

◆ timeout_get()

static m0_time_t timeout_get ( void  )
static

Definition at line 76 of file commands.c.

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

◆ timeout_get_abs()

static m0_time_t timeout_get_abs ( void  )
static

Definition at line 81 of file commands.c.

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

Variable Documentation

◆ addr_console

char addr_console[NTC_ADDR_LEN_MAX]
static

Definition at line 67 of file commands.c.

◆ addr_node

char addr_node[NTC_ADDR_LEN_MAX *NTC_MULTIPLE_NODES]
static

Definition at line 68 of file commands.c.

◆ console

struct m0_net_test_cmd_ctx console
static

Definition at line 73 of file commands.c.

◆ node

struct net_test_cmd_node* node
static

Definition at line 72 of file commands.c.

◆ nodes

struct net_test_cmd_node nodes[NTC_MULTIPLE_NODES]
static

Definition at line 74 of file commands.c.

◆ NTC_ADDR

const char NTC_ADDR[] = "0@lo:12345:42:%d"
static

Definition at line 45 of file commands.c.

◆ NTC_ADDR_LEN

const size_t NTC_ADDR_LEN = ARRAY_SIZE(NTC_ADDR)
static

Definition at line 46 of file commands.c.

◆ NTC_DELIM

const char NTC_DELIM = ','
static

Definition at line 47 of file commands.c.

◆ slist_console

struct m0_net_test_slist slist_console
static

Definition at line 71 of file commands.c.

◆ slist_node

struct m0_net_test_slist slist_node
static

Definition at line 70 of file commands.c.