/*
 * client_create_error -- check if valid errno is set if error status returned
 */
static void
client_create_error(char *target)
{
	struct rpmem_req_attr req = {
		.pool_size = POOL_SIZE,
		.nlanes = NLANES,
		.provider = PROVIDER,
		.pool_desc = POOL_DESC,
	};

	struct rpmem_pool_attr pool_attr = POOL_ATTR_INIT;

	struct rpmem_resp_attr res;
	int ret;

	for (enum rpmem_err e = 1; e < MAX_RPMEM_ERR; e++) {
		int ex_errno = rpmem_util_proto_errno(e);
		struct rpmem_obc *rpc = rpmem_obc_init();
		UT_ASSERTne(rpc, NULL);

		client_connect_wait(rpc, target);

		ret = rpmem_obc_create(rpc, &req, &res, &pool_attr);
		UT_ASSERTne(ret, 0);
		UT_ASSERTeq(errno, ex_errno);

		rpmem_obc_disconnect(rpc);

		rpmem_obc_fini(rpc);
	}
}
Exemple #2
0
/*
 * client_open -- perform open request
 */
int
client_open(const struct test_case *tc, int argc, char *argv[])
{
	if (argc < 1)
		UT_FATAL("usage: %s <addr>[:<port>]", tc->name);

	char *target = argv[0];

	int ret;
	struct rpmem_obc *rpc;
	struct rpmem_target_info *info;
	struct rpmem_req_attr req = REQ_ATTR_INIT;
	struct rpmem_pool_attr ex_pool_attr = POOL_ATTR_INIT;
	struct rpmem_pool_attr pool_attr;
	struct rpmem_resp_attr ex_res = RESP_ATTR_INIT;
	struct rpmem_resp_attr res;

	info = rpmem_target_parse(target);
	UT_ASSERTne(info, NULL);

	rpc = rpmem_obc_init();
	UT_ASSERTne(rpc, NULL);

	ret = rpmem_obc_connect(rpc, info);
	UT_ASSERTeq(ret, 0);

	rpmem_target_free(info);

	ret = rpmem_obc_monitor(rpc, 1);
	UT_ASSERTeq(ret, 1);

	ret = rpmem_obc_open(rpc, &req, &res, &pool_attr);
	UT_ASSERTeq(ret, 0);
	UT_ASSERTeq(ex_res.port, res.port);
	UT_ASSERTeq(ex_res.rkey, res.rkey);
	UT_ASSERTeq(ex_res.raddr, res.raddr);
	UT_ASSERTeq(ex_res.persist_method, res.persist_method);
	UT_ASSERTeq(ex_res.nlanes, res.nlanes);
	UT_ASSERTeq(memcmp(&ex_pool_attr, &pool_attr,
			sizeof(ex_pool_attr)), 0);

	ret = rpmem_obc_monitor(rpc, 1);
	UT_ASSERTeq(ret, 1);

	ret = rpmem_obc_close(rpc);
	UT_ASSERTeq(ret, 0);

	ret = rpmem_obc_disconnect(rpc);
	UT_ASSERTeq(ret, 0);

	rpmem_obc_fini(rpc);

	return 1;
}
Exemple #3
0
/*
 * client_set_attr -- perform set attributes request
 */
int
client_set_attr(const struct test_case *tc, int argc, char *argv[])
{
	if (argc < 1)
		UT_FATAL("usage: %s <addr>[:<port>]", tc->name);

	char *target = argv[0];

	int ret;
	struct rpmem_obc *rpc;
	struct rpmem_target_info *info;
	const struct rpmem_pool_attr pool_attr = POOL_ATTR_ALT;


	info = rpmem_target_parse(target);
	UT_ASSERTne(info, NULL);

	rpc = rpmem_obc_init();
	UT_ASSERTne(rpc, NULL);

	ret = rpmem_obc_connect(rpc, info);
	UT_ASSERTeq(ret, 0);

	rpmem_target_free(info);

	ret = rpmem_obc_monitor(rpc, 1);
	UT_ASSERTeq(ret, 1);

	ret = rpmem_obc_set_attr(rpc, &pool_attr);
	UT_ASSERTeq(ret, 0);

	ret = rpmem_obc_monitor(rpc, 1);
	UT_ASSERTeq(ret, 1);

	ret = rpmem_obc_close(rpc);
	UT_ASSERTeq(ret, 0);

	ret = rpmem_obc_disconnect(rpc);
	UT_ASSERTeq(ret, 0);

	rpmem_obc_fini(rpc);

	return 1;
}
/*
 * client_create_errno -- perform create request operation and expect
 * specified errno, repeat the operation specified number of times.
 * If ex_errno is zero expect certain values in res struct.
 */
static void
client_create_errno(char *target, int ex_errno, int count)
{
	struct rpmem_req_attr req = {
		.pool_size = POOL_SIZE,
		.nlanes = NLANES,
		.provider = PROVIDER,
		.pool_desc = POOL_DESC,
	};

	struct rpmem_pool_attr pool_attr = POOL_ATTR_INIT;

	struct rpmem_resp_attr res;
	int ret;

	for (int i = 0; i < count; i++) {
		struct rpmem_obc *rpc = rpmem_obc_init();
		UT_ASSERTne(rpc, NULL);

		client_connect_wait(rpc, target);

		ret = rpmem_obc_create(rpc, &req, &res, &pool_attr);
		if (ex_errno) {
			UT_ASSERTne(ret, 0);
			UT_ASSERTeq(errno, ex_errno);
		} else {
			UT_ASSERTeq(ret, 0);

			UT_ASSERTeq(res.port, CREATE_RESP.ibc.port);
			UT_ASSERTeq(res.rkey, CREATE_RESP.ibc.rkey);
			UT_ASSERTeq(res.raddr, CREATE_RESP.ibc.raddr);
			UT_ASSERTeq(res.persist_method,
					CREATE_RESP.ibc.persist_method);
			UT_ASSERTeq(res.nlanes,
					CREATE_RESP.ibc.nlanes);
		}

		rpmem_obc_disconnect(rpc);

		rpmem_obc_fini(rpc);
	}
}