Motr  M0
Console

Macros

#define ENDPOINT   M0_NET_XPRT_PREFIX_DEFAULT":"SERVER_ENDPOINT_ADDR
 
#define NAME(ext)   "console_st_srv" ext
 
#define CLIENT_ENDPOINT_ADDR   "0@lo:12345:34:2"
 
#define SERVER_ENDPOINT_ADDR   "0@lo:12345:34:1"
 
#define SERVER_ENDPOINT   M0_NET_XPRT_PREFIX_DEFAULT":"SERVER_ENDPOINT_ADDR
 
#define SERVER_DB_FILE_NAME   "cons_server_db"
 
#define SERVER_STOB_FILE_NAME   "cons_server_stob"
 
#define SERVER_ADDB_STOB_FILE_NAME   "linuxstob:cons_server_addb_stob"
 
#define SERVER_LOG_FILE_NAME   "cons_server.log"
 
#define ALIST(...)   ((char *[]){ __VA_ARGS__, NULL})
 

Enumerations

enum  { COB_DOM_CLIENT_ID = 14, COB_DOM_SERVER_ID = 15 }
 
enum  { CLIENT_COB_DOM_ID = 14, MAX_RPCS_IN_FLIGHT = 1, MAX_RETRIES = 5 }
 

Functions

static int fop_info_show (uint32_t opcode)
 Iterate over FOP and print names of its members. More...
 
static int fop_send_and_print (struct m0_rpc_client_ctx *cctx, uint32_t opcode, const char *fop_input)
 Build the RPC item using FOP (Embedded into item) and send it. More...
 
static void usage (void)
 
static int console_init (void)
 
static void console_fini (void)
 
int main (int argc, char **argv)
 The service to connect to is specified at the command line. More...
 
static int console_fom_create (struct m0_fop *fop, struct m0_reqh *reqh, const struct m0_fom_ops *fom_ops, struct m0_fom **m)
 
static size_t console_fom_home_locality (const struct m0_fom *fom)
 
static void console_fom_fini (struct m0_fom *fom)
 
static int console_device_fom_create (struct m0_fop *fop, struct m0_fom **m, struct m0_reqh *reqh)
 
static int console_fom_tick (struct m0_fom *fom)
 
static int console_test_fom_create (struct m0_fop *fop, struct m0_fom **m, struct m0_reqh *reqh)
 
M0_INTERNAL void m0_console_fop_fini (void)
 
M0_INTERNAL int m0_console_fop_init (void)
 
static void sig_handler (int num)
 
static int cons_init (void)
 
static int cons_fini (void)
 
static void file_redirect_init (void)
 
static void file_redirect_fini (void)
 
static int generate_yaml_file (const char *name)
 
static void check_values (struct m0_fop *fop)
 
static void yaml_basic_test (void)
 
static void input_test (void)
 
static void file_compare (const char *in, const char *out)
 
static void output_test (void)
 
static void yaml_file_test (void)
 
static void yaml_parser_test (void)
 
static void yaml_root_get_test (void)
 
static void yaml_get_value_test (void)
 
static int device_yaml_file (const char *name)
 
static void cons_client_init (struct m0_rpc_client_ctx *cctx)
 
static void cons_client_fini (struct m0_rpc_client_ctx *cctx)
 
static void cons_server_init (struct m0_rpc_server_ctx *sctx)
 
static void cons_server_fini (struct m0_rpc_server_ctx *sctx)
 
static void conn_basic_test (void)
 
static void success_client (int dummy)
 
static void conn_success_test (void)
 
static void mesg_send_client (int dummy)
 
static void mesg_send_test (void)
 
static int console_cmd (char **params)
 
static void console_input_test (void)
 

Variables

bool m0_console_verbose
 
static uint32_t timeout
 
static const char * usage_msg
 
bool m0_console_verbose
 
const struct m0_fom_ops m0_console_fom_device_ops
 
const struct m0_fom_type_ops m0_console_fom_type_device_ops
 
struct m0_fom_ops m0_console_fom_test_ops
 
const struct m0_fom_type_ops m0_console_fom_type_test_ops
 
struct m0_reqh_service_type m0_rpc_service_type
 
struct m0_fop_type m0_cons_fop_device_fopt
 
struct m0_fop_type m0_cons_fop_reply_fopt
 
struct m0_fop_type m0_cons_fop_test_fopt
 
const struct m0_fom_type_ops m0_cons_fom_device_type_ops
 
static int signaled = 0
 
static const char * yaml_file = "/tmp/console_ut.yaml"
 
static const char * err_file = "/tmp/stderr"
 
static const char * out_file = "/tmp/stdout"
 
static const char * in_file = "/tmp/stdin"
 
static struct m0_ut_redirect in_redir
 
static struct m0_ut_redirect out_redir
 
static struct m0_ut_redirect err_redir
 
static struct m0_rpc_machine cons_mach
 
static struct m0_net_domain client_net_dom = { }
 
static struct m0_rpc_client_ctx cctx
 
static char * server_argv []
 
static struct m0_rpc_server_ctx sctx
 
struct m0_ut_suite console_ut
 

Detailed Description

Build a standalone utility that

The console utility can send a DEVICE_FAILURE fop to a server. Server-side processing for fops of this type consists of calling a single stub function. Real implementation will be supplied by the middleware.cm-setup task.

Macro Definition Documentation

◆ ALIST

#define ALIST (   ...)    ((char *[]){ __VA_ARGS__, NULL})

Definition at line 62 of file console.c.

◆ CLIENT_ENDPOINT_ADDR

#define CLIENT_ENDPOINT_ADDR   "0@lo:12345:34:2"

Definition at line 53 of file console.c.

◆ ENDPOINT

Definition at line 48 of file server.c.

◆ NAME

#define NAME (   ext)    "console_st_srv" ext

Definition at line 49 of file server.c.

◆ SERVER_ADDB_STOB_FILE_NAME

#define SERVER_ADDB_STOB_FILE_NAME   "linuxstob:cons_server_addb_stob"

Definition at line 59 of file console.c.

◆ SERVER_DB_FILE_NAME

#define SERVER_DB_FILE_NAME   "cons_server_db"

Definition at line 57 of file console.c.

◆ SERVER_ENDPOINT

#define SERVER_ENDPOINT   M0_NET_XPRT_PREFIX_DEFAULT":"SERVER_ENDPOINT_ADDR

Definition at line 55 of file console.c.

◆ SERVER_ENDPOINT_ADDR

#define SERVER_ENDPOINT_ADDR   "0@lo:12345:34:1"

Definition at line 54 of file console.c.

◆ SERVER_LOG_FILE_NAME

#define SERVER_LOG_FILE_NAME   "cons_server.log"

Definition at line 60 of file console.c.

◆ SERVER_STOB_FILE_NAME

#define SERVER_STOB_FILE_NAME   "cons_server_stob"

Definition at line 58 of file console.c.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
COB_DOM_CLIENT_ID 
COB_DOM_SERVER_ID 

Definition at line 38 of file console.c.

◆ anonymous enum

anonymous enum
Enumerator
CLIENT_COB_DOM_ID 
MAX_RPCS_IN_FLIGHT 
MAX_RETRIES 

Definition at line 64 of file console.c.

Function Documentation

◆ check_values()

static void check_values ( struct m0_fop fop)
static

Definition at line 165 of file console.c.

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

◆ conn_basic_test()

static void conn_basic_test ( void  )
static

Definition at line 467 of file console.c.

Here is the call graph for this function:

◆ conn_success_test()

static void conn_success_test ( void  )
static

Definition at line 481 of file console.c.

Here is the call graph for this function:

◆ cons_client_fini()

static void cons_client_fini ( struct m0_rpc_client_ctx cctx)
static

Definition at line 435 of file console.c.

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

◆ cons_client_init()

static void cons_client_init ( struct m0_rpc_client_ctx cctx)
static

Definition at line 422 of file console.c.

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

◆ cons_fini()

static int cons_fini ( void  )
static

Definition at line 104 of file console.c.

Here is the call graph for this function:

◆ cons_init()

static int cons_init ( void  )
static

Definition at line 90 of file console.c.

Here is the call graph for this function:

◆ cons_server_fini()

static void cons_server_fini ( struct m0_rpc_server_ctx sctx)
static

Definition at line 462 of file console.c.

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

◆ cons_server_init()

static void cons_server_init ( struct m0_rpc_server_ctx sctx)
static

Definition at line 447 of file console.c.

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

◆ console_cmd()

static int console_cmd ( char **  params)
static

Definition at line 539 of file console.c.

Here is the caller graph for this function:

◆ console_device_fom_create()

static int console_device_fom_create ( struct m0_fop fop,
struct m0_fom **  m,
struct m0_reqh reqh 
)
static

Definition at line 96 of file console_fom.c.

Here is the call graph for this function:

◆ console_fini()

static void console_fini ( void  )
static

Definition at line 185 of file console.c.

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

◆ console_fom_create()

static int console_fom_create ( struct m0_fop fop,
struct m0_reqh reqh,
const struct m0_fom_ops fom_ops,
struct m0_fom **  m 
)
static

NOTE: Though service type is NOT set in the FOP_TYPE_INIT for console fops, we are setting it in the console UT, where the client thread creates the fop. So the assertion in m0_fom_init should pass

Definition at line 40 of file console_fom.c.

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

◆ console_fom_fini()

static void console_fom_fini ( struct m0_fom fom)
static

Definition at line 90 of file console_fom.c.

Here is the call graph for this function:

◆ console_fom_home_locality()

static size_t console_fom_home_locality ( const struct m0_fom fom)
static

Definition at line 83 of file console_fom.c.

Here is the call graph for this function:

◆ console_fom_tick()

static int console_fom_tick ( struct m0_fom fom)
static

Definition at line 106 of file console_fom.c.

Here is the call graph for this function:

◆ console_init()

static int console_init ( void  )
static

Definition at line 170 of file console.c.

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

◆ console_input_test()

static void console_input_test ( void  )
static

Definition at line 550 of file console.c.

Here is the call graph for this function:

◆ console_test_fom_create()

static int console_test_fom_create ( struct m0_fop fop,
struct m0_fom **  m,
struct m0_reqh reqh 
)
static

Definition at line 151 of file console_fom.c.

Here is the call graph for this function:

◆ device_yaml_file()

static int device_yaml_file ( const char *  name)
static

Definition at line 392 of file console.c.

Here is the caller graph for this function:

◆ file_compare()

static void file_compare ( const char *  in,
const char *  out 
)
static

Definition at line 220 of file console.c.

Here is the caller graph for this function:

◆ file_redirect_fini()

static void file_redirect_fini ( void  )
static

Definition at line 119 of file console.c.

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

◆ file_redirect_init()

static void file_redirect_init ( void  )
static

Definition at line 112 of file console.c.

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

◆ fop_info_show()

static int fop_info_show ( uint32_t  opcode)
static

Iterate over FOP and print names of its members.

Parameters
opcodeItem type opcode

Definition at line 59 of file console.c.

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

◆ fop_send_and_print()

static int fop_send_and_print ( struct m0_rpc_client_ctx cctx,
uint32_t  opcode,
const char *  fop_input 
)
static

Build the RPC item using FOP (Embedded into item) and send it.

Parameters
cctxRPC Client context
opcodeRPC item opcode

Definition at line 80 of file console.c.

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

◆ generate_yaml_file()

static int generate_yaml_file ( const char *  name)
static

Definition at line 135 of file console.c.

Here is the caller graph for this function:

◆ input_test()

static void input_test ( void  )
static

Definition at line 197 of file console.c.

Here is the call graph for this function:

◆ m0_console_fop_fini()

M0_INTERNAL void m0_console_fop_fini ( void  )

Fini console FOP

Definition at line 42 of file console_fop.c.

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

◆ m0_console_fop_init()

M0_INTERNAL int m0_console_fop_init ( void  )

Init console FOP

Definition at line 51 of file console_fop.c.

Here is the caller graph for this function:

◆ main()

int main ( int  argc,
char **  argv 
)

The service to connect to is specified at the command line.

Test server for m0console.

The fop type to be sent is specified at the command line.

The values of fop fields are specified interactively. The program locates the fop type format (m0_fop_type_format) corresponding to the specified fop type and iterates over fop fields, prompting the user for the field values.

The program supports RECORD, SEQUENCE and UNION aggregation types, as well as all atomic types (U32, U64, BYTE and VOID).

Returns
0 success, -errno failure.

Definition at line 210 of file console.c.

Here is the call graph for this function:

◆ mesg_send_client()

static void mesg_send_client ( int  dummy)
static

Definition at line 496 of file console.c.

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

◆ mesg_send_test()

static void mesg_send_test ( void  )
static

Definition at line 522 of file console.c.

Here is the call graph for this function:

◆ output_test()

static void output_test ( void  )
static

Definition at line 241 of file console.c.

Here is the call graph for this function:

◆ sig_handler()

static void sig_handler ( int  num)
static

Definition at line 53 of file server.c.

◆ success_client()

static void success_client ( int  dummy)
static

Definition at line 475 of file console.c.

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

◆ usage()

static void usage ( void  )
static

Definition at line 155 of file console.c.

Here is the caller graph for this function:

◆ yaml_basic_test()

static void yaml_basic_test ( void  )
static

Definition at line 178 of file console.c.

Here is the call graph for this function:

◆ yaml_file_test()

static void yaml_file_test ( void  )
static

Definition at line 270 of file console.c.

Here is the call graph for this function:

◆ yaml_get_value_test()

static void yaml_get_value_test ( void  )
static

Definition at line 326 of file console.c.

Here is the call graph for this function:

◆ yaml_parser_test()

static void yaml_parser_test ( void  )
static

Definition at line 280 of file console.c.

Here is the call graph for this function:

◆ yaml_root_get_test()

static void yaml_root_get_test ( void  )
static

Definition at line 309 of file console.c.

Here is the call graph for this function:

Variable Documentation

◆ cctx

struct m0_rpc_client_ctx cctx
static
Initial value:
= {
.rcx_net_dom = &client_net_dom,
.rcx_local_addr = CLIENT_ENDPOINT_ADDR,
.rcx_remote_addr = SERVER_ENDPOINT_ADDR,
.rcx_max_rpcs_in_flight = MAX_RPCS_IN_FLIGHT,
.rcx_fid = &g_process_fid,
}
#define SERVER_ENDPOINT_ADDR
Definition: console.c:54
static struct m0_net_domain client_net_dom
Definition: console.c:70
#define CLIENT_ENDPOINT_ADDR
Definition: console.c:53
struct m0_fid g_process_fid
Definition: ut.c:689

Definition at line 72 of file console.c.

◆ client_net_dom

struct m0_net_domain client_net_dom = { }
static

Definition at line 70 of file console.c.

◆ cons_mach

struct m0_rpc_machine cons_mach
static

Definition at line 51 of file console.c.

◆ console_ut

struct m0_ut_suite console_ut
Initial value:
= {
.ts_name = "libconsole-ut",
.ts_init = cons_init,
.ts_fini = cons_fini,
.ts_tests = {
{ "yaml_basic_test", yaml_basic_test },
{ "input_test", input_test },
{ "console_input_test", console_input_test },
{ "output_test", output_test },
{ "yaml_file_test", yaml_file_test },
{ "yaml_parser_test", yaml_parser_test },
{ "yaml_root_get_test", yaml_root_get_test },
{ "yaml_get_value_test", yaml_get_value_test },
{ "conn_basic_test", conn_basic_test },
{ "conn_success_test", conn_success_test },
{ "mesg_send_test", mesg_send_test },
{ NULL, NULL }
}
}
static int cons_init(void)
Definition: console.c:90
#define NULL
Definition: misc.h:38
static void yaml_root_get_test(void)
Definition: console.c:309
static void input_test(void)
Definition: console.c:197
static void conn_basic_test(void)
Definition: console.c:467
static void mesg_send_test(void)
Definition: console.c:522
static void yaml_parser_test(void)
Definition: console.c:280
static void console_input_test(void)
Definition: console.c:550
static int cons_fini(void)
Definition: console.c:104
static void conn_success_test(void)
Definition: console.c:481
static void yaml_basic_test(void)
Definition: console.c:178
static void yaml_file_test(void)
Definition: console.c:270
static void output_test(void)
Definition: console.c:241
static void yaml_get_value_test(void)
Definition: console.c:326

Definition at line 628 of file console.c.

◆ err_file

const char* err_file = "/tmp/stderr"
static

Definition at line 44 of file console.c.

◆ err_redir

struct m0_ut_redirect err_redir
static

Definition at line 50 of file console.c.

◆ in_file

const char* in_file = "/tmp/stdin"
static

Definition at line 46 of file console.c.

◆ in_redir

struct m0_ut_redirect in_redir
static

Definition at line 48 of file console.c.

◆ m0_cons_fom_device_type_ops

const struct m0_fom_type_ops m0_cons_fom_device_type_ops

◆ m0_cons_fop_device_fopt

struct m0_fop_type m0_cons_fop_device_fopt

Definition at line 38 of file console_fop.c.

◆ m0_cons_fop_reply_fopt

struct m0_fop_type m0_cons_fop_reply_fopt

Definition at line 39 of file console_fop.c.

◆ m0_cons_fop_test_fopt

struct m0_fop_type m0_cons_fop_test_fopt

Definition at line 40 of file console_fop.c.

◆ m0_console_fom_device_ops

const struct m0_fom_ops m0_console_fom_device_ops
Initial value:
= {
.fo_tick = console_fom_tick,
.fo_fini = console_fom_fini,
.fo_home_locality = console_fom_home_locality
}
static size_t console_fom_home_locality(const struct m0_fom *fom)
Definition: console_fom.c:83
static void console_fom_fini(struct m0_fom *fom)
Definition: console_fom.c:90
static int console_fom_tick(struct m0_fom *fom)
Definition: console_fom.c:106

Definition at line 141 of file console_fom.c.

◆ m0_console_fom_test_ops

struct m0_fom_ops m0_console_fom_test_ops
Initial value:
= {
.fo_fini = console_fom_fini,
.fo_tick = console_fom_tick,
.fo_home_locality = console_fom_home_locality
}
static size_t console_fom_home_locality(const struct m0_fom *fom)
Definition: console_fom.c:83
static void console_fom_fini(struct m0_fom *fom)
Definition: console_fom.c:90
static int console_fom_tick(struct m0_fom *fom)
Definition: console_fom.c:106

Definition at line 162 of file console_fom.c.

◆ m0_console_fom_type_device_ops

const struct m0_fom_type_ops m0_console_fom_type_device_ops
Initial value:
= {
}
static int console_device_fom_create(struct m0_fop *fop, struct m0_fom **m, struct m0_reqh *reqh)
Definition: console_fom.c:96

Definition at line 147 of file console_fom.c.

◆ m0_console_fom_type_test_ops

const struct m0_fom_type_ops m0_console_fom_type_test_ops
Initial value:
= {
.fto_create = console_test_fom_create,
}
static int console_test_fom_create(struct m0_fop *fop, struct m0_fom **m, struct m0_reqh *reqh)
Definition: console_fom.c:151

Definition at line 168 of file console_fom.c.

◆ m0_console_verbose [1/2]

bool m0_console_verbose

Definition at line 50 of file console.c.

◆ m0_console_verbose [2/2]

bool m0_console_verbose

Definition at line 50 of file console.c.

◆ m0_rpc_service_type

struct m0_reqh_service_type m0_rpc_service_type

Definition at line 120 of file service.c.

◆ out_file

const char* out_file = "/tmp/stdout"
static

Definition at line 45 of file console.c.

◆ out_redir

struct m0_ut_redirect out_redir
static

Definition at line 49 of file console.c.

◆ sctx

struct m0_rpc_server_ctx sctx
static

Definition at line 88 of file console.c.

◆ server_argv

char* server_argv[]
static
Initial value:
= {
"console_ut", "-T", "AD", "-D", SERVER_DB_FILE_NAME,
"-w", "10", "-e", SERVER_ENDPOINT, "-H", SERVER_ENDPOINT_ADDR,
"-c", M0_UT_PATH("conf.xc")
}
#define SERVER_ADDB_STOB_FILE_NAME
Definition: console.c:59
#define SERVER_ENDPOINT_ADDR
Definition: console.c:54
#define SERVER_ENDPOINT
Definition: console.c:55
#define SERVER_DB_FILE_NAME
Definition: console.c:57
#define M0_UT_CONF_PROCESS
Definition: misc.h:45
#define M0_UT_PATH(name)
Definition: misc.h:41
#define SERVER_STOB_FILE_NAME
Definition: console.c:58

Definition at line 80 of file console.c.

◆ signaled

int signaled = 0
static

Definition at line 51 of file server.c.

◆ timeout

uint32_t timeout
static

Definition at line 52 of file console.c.

◆ usage_msg

const char* usage_msg
static
Initial value:
= "Usage: m0console "
" { -l FOP list | -f FOP opcode }"
" [-s server (e.g. 172.18.50.40@o2ib1:12345:34:1) ]"
" [-c client (e.g. 172.18.50.40@o2ib1:12345:34:*) ]"
" [-t timeout]"
" [-d fop_description (in xcode read grammar)] "
" "
" [-h] [-v]"

Definition at line 142 of file console.c.

◆ yaml_file

const char* yaml_file = "/tmp/console_ut.yaml"
static

Definition at line 43 of file console.c.