/* * server_msg_resp -- process a message of specified type, response to client * with specific status value and return status of sending response function */ void server_msg_resp(struct rpmemd_obc *rpdc, enum rpmem_msg_type type, int status) { struct req_cb_arg args = { .ret = 0, .force_ret = 0, .resp = 1, .types = (1 << type), .status = status, }; server_msg_args(rpdc, CONN_WAIT_CLOSE, &args); } /* * server_msg_noresp -- process a message of specified type, do not response to * client and return specific value from process callback */ void server_msg_noresp(struct rpmemd_obc *rpdc, enum rpmem_msg_type type) { struct req_cb_arg args = { .ret = -1, .force_ret = 1, .resp = 0, .types = (1 << type), .status = 0, }; server_msg_args(rpdc, CONN_CLOSE, &args); }
/* * server_msg_resp -- process a message of specified type, response to client * with specific status value and return status of sending response function */ int server_msg_resp(const struct test_case *tc, int argc, char *argv[]) { if (argc < 2) UT_FATAL("usage: %s msg_type status", tc->name); int type = atoi(argv[0]); int status = atoi(argv[1]); int ret; struct rpmemd_obc *rpdc; rpdc = rpmemd_obc_init(STDIN_FILENO, STDOUT_FILENO); UT_ASSERTne(rpdc, NULL); ret = rpmemd_obc_status(rpdc, 0); UT_ASSERTeq(ret, 0); struct req_cb_arg args = { .ret = 0, .force_ret = 0, .resp = 1, .types = (1 << type), .status = status, }; server_msg_args(rpdc, CONN_WAIT_CLOSE, &args); return 2; } /* * server_msg_noresp -- process a message of specified type, do not response to * client and return specific value from process callback */ int server_msg_noresp(const struct test_case *tc, int argc, char *argv[]) { if (argc < 1) UT_FATAL("usage: %s msg_type", tc->name); int type = atoi(argv[0]); int ret; struct rpmemd_obc *rpdc; rpdc = rpmemd_obc_init(STDIN_FILENO, STDOUT_FILENO); UT_ASSERTne(rpdc, NULL); ret = rpmemd_obc_status(rpdc, 0); UT_ASSERTeq(ret, 0); struct req_cb_arg args = { .ret = -1, .force_ret = 1, .resp = 0, .types = (1 << type), .status = 0, }; server_msg_args(rpdc, CONN_CLOSE, &args); return 1; } /* * server_bad_msg -- process a message and expect * error returned from rpmemd_obc_process function */ int server_bad_msg(const struct test_case *tc, int argc, char *argv[]) { int ret; struct rpmemd_obc *rpdc; rpdc = rpmemd_obc_init(STDIN_FILENO, STDOUT_FILENO); UT_ASSERTne(rpdc, NULL); ret = rpmemd_obc_status(rpdc, 0); UT_ASSERTeq(ret, 0); ret = rpmemd_obc_process(rpdc, &REQ_CB, NULL); UT_ASSERTne(ret, 0); rpmemd_obc_fini(rpdc); return 0; }