24 #include <sys/types.h> 43 static const char *
yaml_file =
"/tmp/console_ut.yaml";
46 static const char *
in_file =
"/tmp/stdin";
53 #define CLIENT_ENDPOINT_ADDR "0@lo:12345:34:2" 54 #define SERVER_ENDPOINT_ADDR "0@lo:12345:34:1" 55 #define SERVER_ENDPOINT M0_NET_XPRT_PREFIX_DEFAULT":"SERVER_ENDPOINT_ADDR 57 #define SERVER_DB_FILE_NAME "cons_server_db" 58 #define SERVER_STOB_FILE_NAME "cons_server_stob" 59 #define SERVER_ADDB_STOB_FILE_NAME "linuxstob:cons_server_addb_stob" 60 #define SERVER_LOG_FILE_NAME "cons_server.log" 62 #define ALIST(...) ((char *[]){ __VA_ARGS__, NULL}) 143 fprintf(stderr,
"Failed to create yaml file\n");
147 fprintf(
fp,
"# Generated yaml file for console UT\n\n");
148 fprintf(
fp,
"server : localhost\n");
149 fprintf(
fp,
"sport : 23125\n");
150 fprintf(
fp,
"client : localhost\n");
151 fprintf(
fp,
"cport : 23126\n");
153 fprintf(
fp,
"Test FOP:\n");
154 fprintf(
fp,
" - cons_test_type : A\n");
155 fprintf(
fp,
" cons_test_id : 495\n");
156 fprintf(
fp,
" cons_seq : 144\n");
157 fprintf(
fp,
" cons_oid : 233\n");
158 fprintf(
fp,
" cons_size : 5\n");
159 fprintf(
fp,
" cons_buf : abcde\n");
175 test->cons_test_buf.cons_size) == 0);
227 infp = fopen(in,
"r");
229 outfp = fopen(
out,
"r");
232 while ((inc = fgetc(infp)) != EOF &&
233 (outc = fgetc(outfp)) != EOF) {
288 fprintf(
fp,
"# Generated yaml file for console UT\n\n");
289 fprintf(
fp,
"server : localhost\n");
290 fprintf(
fp,
"sport : 23125\n");
291 fprintf(
fp,
"client : localhost\n");
292 fprintf(
fp,
"cport : 23126\n");
294 fprintf(
fp,
"Test FOP:\n");
295 fprintf(
fp,
" - cons_seq : 1\n");
297 fprintf(
fp,
"cons_oid : 2\n");
298 fprintf(
fp,
" cons_test_type : d\n");
299 fprintf(
fp,
" cons_test_id : 64\n");
400 fprintf(stderr,
"Failed to create yaml file\n");
404 fprintf(
fp,
"# Generated yaml file for console UT\n\n");
405 fprintf(
fp,
"server : localhost\n");
406 fprintf(
fp,
"sport : 23125\n");
407 fprintf(
fp,
"client : localhost\n");
408 fprintf(
fp,
"cport : 23126\n");
410 fprintf(
fp,
"Test FOP:\n");
411 fprintf(
fp,
" - cons_seq : 1\n");
412 fprintf(
fp,
" cons_oid : 2\n");
413 fprintf(
fp,
" cons_notify_type : 0\n");
414 fprintf(
fp,
" cons_dev_id : 64\n");
415 fprintf(
fp,
" cons_size : 8\n");
416 fprintf(
fp,
" cons_buf : console\n");
489 0,
"console-client");
531 0,
"console-client");
544 for (numparams = 0;
params[numparams] !=
NULL; ++numparams)
547 return console_main(numparams,
params);
562 fseek(stderr, 0L, SEEK_SET);
569 fseek(stderr, 0L, SEEK_SET);
571 fseek(stdout, 0L, SEEK_SET);
577 fseek(stdout, 0L, SEEK_SET);
582 sprintf(
buf,
"%.2d Device Failed",
587 fseek(stdout, 0L, SEEK_SET);
592 sprintf(
buf,
"%.2d Console Reply",
597 fseek(stdout, 0L, SEEK_SET);
604 fseek(stderr, 0L, SEEK_SET);
611 fseek(stderr, 0L, SEEK_SET);
618 fseek(stderr, 0L, SEEK_SET);
static void cons_client_init(struct m0_rpc_client_ctx *cctx)
static int cons_init(void)
static struct m0_be_active_record_domain dummy
M0_INTERNAL bool m0_error_mesg_match(FILE *fp, const char *mesg)
void m0_net_domain_fini(struct m0_net_domain *dom)
M0_INTERNAL void m0_stream_restore(const struct m0_ut_redirect *redir)
int m0_thread_join(struct m0_thread *q)
const m0_time_t M0_TIME_NEVER
static struct m0_rpc_client_ctx cctx
static int device_yaml_file(const char *name)
int m0_rpc_server_start(struct m0_rpc_server_ctx *sctx)
struct m0_fop_type m0_cons_fop_test_fopt
static void yaml_root_get_test(void)
int const char const void * value
static void cons_client_fini(struct m0_rpc_client_ctx *cctx)
static void input_test(void)
void * m0_fop_data(const struct m0_fop *fop)
M0_INTERNAL int m0_cons_yaml_init(const char *file_path)
Inititalizes parser by opening given file. and also checks for error by getting root node...
static void conn_basic_test(void)
#define M0_THREAD_INIT(thread, TYPE, init, func, arg, namefmt,...)
static const char * in_file
#define SERVER_ADDB_STOB_FILE_NAME
static void check_values(struct m0_fop *fop)
int m0_rpc_item_wait_for_reply(struct m0_rpc_item *item, m0_time_t timeout)
M0_INTERNAL void m0_sm_group_fini(struct m0_sm_group *grp)
#define SERVER_ENDPOINT_ADDR
struct m0_sm_group rm_sm_grp
#define SERVER_DB_FILE_NAME
static void mesg_send_client(int dummy)
static void mesg_send_test(void)
static void file_redirect_init(void)
static void file_compare(const char *in, const char *out)
static void success_client(int dummy)
static void yaml_parser_test(void)
M0_INTERNAL void m0_cons_yaml_fini(void)
Deletes the parser and closes the YAML file.
static struct m0_ut_redirect err_redir
static int console_cmd(char **params)
static void cons_server_init(struct m0_rpc_server_ctx *sctx)
M0_INTERNAL void m0_sm_group_init(struct m0_sm_group *grp)
static void cons_server_fini(struct m0_rpc_server_ctx *sctx)
static void console_input_test(void)
void m0_thread_fini(struct m0_thread *q)
int m0_rpc_client_stop(struct m0_rpc_client_ctx *cctx)
static int cons_fini(void)
struct m0_net_xprt * m0_net_xprt_default_get(void)
int m0_rpc_client_start(struct m0_rpc_client_ctx *cctx)
struct m0_net_xprt ** rsx_xprts
static struct m0_rpc_server_ctx sctx
int m0_rpc_post_sync(struct m0_fop *fop, struct m0_rpc_session *session, const struct m0_rpc_item_ops *ri_ops, m0_time_t deadline)
M0_INTERNAL int m0_cons_fop_obj_output(struct m0_fop *fop)
Helper function for FOP output.
struct m0_ut_suite console_ut
struct m0_net_domain * rcx_net_dom
M0_INTERNAL struct m0_fop_type * m0_fop_type_find(uint32_t opcode)
M0_INTERNAL int m0_cons_fop_obj_input(struct m0_fop *fop)
Helper function for FOP input.
static const char * usage_msg
static void conn_success_test(void)
static struct m0_net_domain client_net_dom
int m0_net_domain_init(struct m0_net_domain *dom, const struct m0_net_xprt *xprt)
struct m0_rpc_session rcx_session
static int generate_yaml_file(const char *name)
#define M0_UT_CONF_PROCESS
static void yaml_basic_test(void)
static const char * out_file
struct m0_net_xprt ** m0_net_all_xprt_get(void)
M0_INTERNAL void * m0_cons_yaml_get_value(const char *name)
Search for specified string and set the respctive value form YAML file. (like "name : console") ...
void m0_fop_put_lock(struct m0_fop *fop)
static void yaml_file_test(void)
static struct m0_fop * fop
static char * server_argv[]
M0_INTERNAL void m0_stream_redirect(FILE *stream, const char *path, struct m0_ut_redirect *redir)
static const char * yaml_file
void m0_rpc_server_stop(struct m0_rpc_server_ctx *sctx)
static struct m0_rpc_machine cons_mach
static void file_redirect_fini(void)
M0_INTERNAL void m0_cons_fop_name_print(const struct m0_fop_type *ftype)
static void output_test(void)
static const char * err_file
M0_INTERNAL int m0_console_fop_init(void)
M0_INTERNAL void m0_console_fop_fini(void)
struct m0_rpc_item f_item
#define CLIENT_ENDPOINT_ADDR
#define SERVER_LOG_FILE_NAME
static void yaml_get_value_test(void)
struct m0_fid g_process_fid
#define SERVER_STOB_FILE_NAME
static struct m0_ut_redirect out_redir
static struct m0_ut_redirect in_redir
struct m0_fop * m0_fop_alloc(struct m0_fop_type *fopt, void *data, struct m0_rpc_machine *mach)