in fabtests/unit/resource_freeing.c [47:218]
int test_resource_freeing(enum test_depth test_depth,
const char *fabric_service)
{
int our_ret = FI_SUCCESS;
int ret;
uint64_t flags;
struct fi_info *info;
/* Setup fabric */
hints = fi_allocinfo();
if (!hints) {
our_ret = -FI_ENOMEM;
goto error_return;
}
flags = FI_SOURCE;
hints->caps = FI_RMA;
hints->ep_attr->type = FI_EP_RDM;
ret = fi_getinfo(FT_FIVERSION, NULL, fabric_service, flags,
hints, &info);
if (ret) {
FT_PRINTERR("fi_getinfo", ret);
our_ret = ret;
goto free_hints;
}
ret = fi_fabric(info->fabric_attr, &fabric, NULL);
if (ret) {
FT_PRINTERR("fi_fabric", ret);
our_ret = ret;
goto free_info;
}
if (test_depth == DEPTH_FABRIC) {
goto close_fabric;
}
ret = fi_domain(fabric, info, &domain, NULL);
if (ret) {
FT_PRINTERR("fi_domain", ret);
our_ret = ret;
goto close_fabric;
}
if (test_depth == DEPTH_DOMAIN) {
goto close_domain;
}
/* Create pre-endpoint resources */
av_attr.type = info->domain_attr->av_type;
av_attr.count = 0;
av_attr.name = NULL;
ret = fi_av_open(domain, &av_attr, &av, NULL);
if (ret) {
FT_PRINTERR("fi_av_open", ret);
our_ret = ret;
goto close_domain;
}
cntr_attr.events = FI_CNTR_EVENTS_COMP;
cntr_attr.wait_obj = FI_WAIT_UNSPEC;
ret = fi_cntr_open(domain, &cntr_attr, &txcntr, NULL);
if (ret) {
FT_PRINTERR("fi_cntr_open", ret);
our_ret = ret;
goto close_av;
}
ret = fi_cq_open(domain, &cq_attr, &txcq, NULL);
if (ret) {
FT_PRINTERR("fi_cq_open", ret);
our_ret = ret;
goto close_txcntr;
}
ret = fi_endpoint(domain, info, &ep, NULL);
if (ret) {
FT_PRINTERR("fi_endpoint", ret);
our_ret = ret;
goto close_txcq;
}
/* Bind pre-endpoint resources to ep */
ret = fi_ep_bind(ep, &txcntr->fid, FI_WRITE);
if (ret) {
FT_PRINTERR("fi_ep_bind", ret);
our_ret = ret;
goto close_ep;
}
ret = fi_ep_bind(ep, &av->fid, 0);
if (ret) {
FT_PRINTERR("fi_ep_bind", ret);
our_ret = ret;
goto close_ep;
}
ret = fi_ep_bind(ep, &txcq->fid, FI_TRANSMIT);
if (ret) {
FT_PRINTERR("fi_ep_bind", ret);
our_ret = ret;
goto close_ep;
}
/* Enable ep */
ret = fi_enable(ep);
if (ret) {
FT_PRINTERR("fi_enable", ret);
our_ret = ret;
goto close_ep;
}
if (test_depth == DEPTH_ENABLE_ENDPOINT) {
goto close_ep;
}
close_ep:
ret = fi_close(&ep->fid);
if (ret) {
FT_PRINTERR("fi_close", ret);
our_ret = our_ret ? our_ret : ret;
}
close_txcq:
ret = fi_close(&txcq->fid);
if (ret) {
FT_PRINTERR("fi_close", ret);
our_ret = our_ret ? our_ret : ret;
}
close_txcntr:
ret = fi_close(&txcntr->fid);
if (ret) {
FT_PRINTERR("fi_close", ret);
our_ret = our_ret ? our_ret : ret;
}
close_av:
ret = fi_close(&av->fid);
if (ret) {
FT_PRINTERR("fi_close", ret);
our_ret = our_ret ? our_ret : ret;
}
close_domain:
ret = fi_close(&domain->fid);
if (ret) {
FT_PRINTERR("fi_close", ret);
our_ret = our_ret ? our_ret : ret;
}
close_fabric:
ret = fi_close(&fabric->fid);
if (ret) {
FT_PRINTERR("fi_close", ret);
our_ret = our_ret ? our_ret : ret;
}
free_info:
fi_freeinfo(info);
free_hints:
fi_freeinfo(hints);
error_return:
return our_ret;
}