xref: /spdk/test/unit/lib/nvmf/fc.c/fc_ut.c (revision 927f1fd57bd004df581518466ec4c1b8083e5d23)
1 /*
2  *   BSD LICENSE
3  *
4  *   Copyright (c) 2018-2019 Broadcom.  All Rights Reserved.
5  *   The term "Broadcom" refers to Broadcom Inc. and/or its subsidiaries.
6  *
7  *   Redistribution and use in source and binary forms, with or without
8  *   modification, are permitted provided that the following conditions
9  *   are met:
10  *
11  *     * Redistributions of source code must retain the above copyright
12  *       notice, this list of conditions and the following disclaimer.
13  *     * Redistributions in binary form must reproduce the above copyright
14  *       notice, this list of conditions and the following disclaimer in
15  *       the documentation and/or other materials provided with the
16  *       distribution.
17  *     * Neither the name of Intel Corporation nor the names of its
18  *       contributors may be used to endorse or promote products derived
19  *       from this software without specific prior written permission.
20  *
21  *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22  *   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23  *   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24  *   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25  *   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26  *   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27  *   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28  *   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29  *   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30  *   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31  *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32  */
33 
34 /* NVMF FC Transport Unit Test */
35 
36 #include "spdk/env.h"
37 #include "spdk_cunit.h"
38 #include "spdk/nvmf.h"
39 #include "spdk/endian.h"
40 #include "spdk/trace.h"
41 #include "spdk/log.h"
42 
43 #include "ut_multithread.c"
44 
45 #include "transport.h"
46 #include "nvmf_internal.h"
47 
48 #include "nvmf_fc.h"
49 
50 #include "json/json_util.c"
51 #include "json/json_write.c"
52 #include "nvmf/nvmf.c"
53 #include "nvmf/transport.c"
54 #include "spdk/bdev_module.h"
55 #include "nvmf/subsystem.c"
56 #include "nvmf/fc.c"
57 #include "nvmf/fc_ls.c"
58 
59 /*
60  * SPDK Stuff
61  */
62 
63 #ifdef SPDK_CONFIG_RDMA
64 const struct spdk_nvmf_transport_ops spdk_nvmf_transport_rdma = {
65 	.type = SPDK_NVME_TRANSPORT_RDMA,
66 	.opts_init = NULL,
67 	.create = NULL,
68 	.destroy = NULL,
69 
70 	.listen = NULL,
71 	.stop_listen = NULL,
72 	.accept = NULL,
73 
74 	.listener_discover = NULL,
75 
76 	.poll_group_create = NULL,
77 	.poll_group_destroy = NULL,
78 	.poll_group_add = NULL,
79 	.poll_group_poll = NULL,
80 
81 	.req_free = NULL,
82 	.req_complete = NULL,
83 
84 	.qpair_fini = NULL,
85 	.qpair_get_peer_trid = NULL,
86 	.qpair_get_local_trid = NULL,
87 	.qpair_get_listen_trid = NULL,
88 };
89 #endif
90 
91 const struct spdk_nvmf_transport_ops spdk_nvmf_transport_tcp = {
92 	.type = SPDK_NVME_TRANSPORT_TCP,
93 };
94 
95 DEFINE_STUB(spdk_nvme_transport_id_compare, int,
96 	    (const struct spdk_nvme_transport_id *trid1,
97 	     const struct spdk_nvme_transport_id *trid2), 0);
98 DEFINE_STUB(spdk_bdev_get_name, const char *, (const struct spdk_bdev *bdev), "fc_ut_test");
99 DEFINE_STUB_V(nvmf_ctrlr_destruct, (struct spdk_nvmf_ctrlr *ctrlr));
100 DEFINE_STUB_V(nvmf_qpair_free_aer, (struct spdk_nvmf_qpair *qpair));
101 DEFINE_STUB_V(nvmf_qpair_abort_pending_zcopy_reqs, (struct spdk_nvmf_qpair *qpair));
102 DEFINE_STUB(spdk_bdev_get_io_channel, struct spdk_io_channel *, (struct spdk_bdev_desc *desc),
103 	    NULL);
104 DEFINE_STUB_V(spdk_nvmf_request_exec, (struct spdk_nvmf_request *req));
105 DEFINE_STUB_V(nvmf_ctrlr_ns_changed, (struct spdk_nvmf_ctrlr *ctrlr, uint32_t nsid));
106 DEFINE_STUB_V(spdk_bdev_close, (struct spdk_bdev_desc *desc));
107 DEFINE_STUB(spdk_bdev_module_claim_bdev, int,
108 	    (struct spdk_bdev *bdev, struct spdk_bdev_desc *desc,
109 	     struct spdk_bdev_module *module), 0);
110 DEFINE_STUB_V(spdk_bdev_module_release_bdev, (struct spdk_bdev *bdev));
111 DEFINE_STUB(spdk_bdev_get_block_size, uint32_t, (const struct spdk_bdev *bdev), 512);
112 DEFINE_STUB(spdk_bdev_get_num_blocks, uint64_t, (const struct spdk_bdev *bdev), 1024);
113 
114 DEFINE_STUB(nvmf_ctrlr_async_event_ns_notice, int, (struct spdk_nvmf_ctrlr *ctrlr), 0);
115 DEFINE_STUB(nvmf_ctrlr_async_event_ana_change_notice, int,
116 	    (struct spdk_nvmf_ctrlr *ctrlr), 0);
117 DEFINE_STUB_V(spdk_nvme_trid_populate_transport, (struct spdk_nvme_transport_id *trid,
118 		enum spdk_nvme_transport_type trtype));
119 DEFINE_STUB_V(spdk_nvmf_ctrlr_data_init, (struct spdk_nvmf_transport_opts *opts,
120 		struct spdk_nvmf_ctrlr_data *cdata));
121 DEFINE_STUB(spdk_nvmf_request_complete, int, (struct spdk_nvmf_request *req),
122 	    -ENOSPC);
123 
124 DEFINE_STUB_V(nvmf_update_discovery_log,
125 	      (struct spdk_nvmf_tgt *tgt, const char *hostnqn));
126 
127 DEFINE_STUB(rte_hash_create, struct rte_hash *, (const struct rte_hash_parameters *params),
128 	    (void *)1);
129 DEFINE_STUB(rte_hash_del_key, int32_t, (const struct rte_hash *h, const void *key), 0);
130 DEFINE_STUB(rte_hash_lookup_data, int, (const struct rte_hash *h, const void *key, void **data),
131 	    -ENOENT);
132 DEFINE_STUB(rte_hash_add_key_data, int, (const struct rte_hash *h, const void *key, void *data), 0);
133 DEFINE_STUB_V(rte_hash_free, (struct rte_hash *h));
134 DEFINE_STUB(nvmf_fc_lld_port_add, int, (struct spdk_nvmf_fc_port *fc_port), 0);
135 DEFINE_STUB(nvmf_fc_lld_port_remove, int, (struct spdk_nvmf_fc_port *fc_port), 0);
136 
137 DEFINE_STUB_V(spdk_nvmf_request_zcopy_start, (struct spdk_nvmf_request *req));
138 DEFINE_STUB_V(spdk_nvmf_request_zcopy_end, (struct spdk_nvmf_request *req, bool commit));
139 
140 const char *
141 spdk_nvme_transport_id_trtype_str(enum spdk_nvme_transport_type trtype)
142 {
143 	switch (trtype) {
144 	case SPDK_NVME_TRANSPORT_PCIE:
145 		return "PCIe";
146 	case SPDK_NVME_TRANSPORT_RDMA:
147 		return "RDMA";
148 	case SPDK_NVME_TRANSPORT_FC:
149 		return "FC";
150 	default:
151 		return NULL;
152 	}
153 }
154 
155 const char *
156 spdk_nvme_transport_id_adrfam_str(enum spdk_nvmf_adrfam adrfam)
157 {
158 	switch (adrfam) {
159 	case SPDK_NVMF_ADRFAM_IPV4:
160 		return "IPv4";
161 	case SPDK_NVMF_ADRFAM_IPV6:
162 		return "IPv6";
163 	case SPDK_NVMF_ADRFAM_IB:
164 		return "IB";
165 	case SPDK_NVMF_ADRFAM_FC:
166 		return "FC";
167 	default:
168 		return NULL;
169 	}
170 }
171 
172 const struct spdk_uuid *
173 spdk_bdev_get_uuid(const struct spdk_bdev *bdev)
174 {
175 	return &bdev->uuid;
176 }
177 
178 static bool g_lld_init_called = false;
179 
180 int
181 nvmf_fc_lld_init(void)
182 {
183 	g_lld_init_called = true;
184 	return 0;
185 }
186 
187 static bool g_lld_fini_called = false;
188 
189 void
190 nvmf_fc_lld_fini(spdk_nvmf_transport_destroy_done_cb cb_fn, void *ctx)
191 {
192 	g_lld_fini_called = true;
193 }
194 
195 DEFINE_STUB_V(nvmf_fc_lld_start, (void));
196 DEFINE_STUB(nvmf_fc_init_q, int, (struct spdk_nvmf_fc_hwqp *hwqp), 0);
197 DEFINE_STUB_V(nvmf_fc_reinit_q, (void *queues_prev, void *queues_curr));
198 DEFINE_STUB(nvmf_fc_init_rqpair_buffers, int, (struct spdk_nvmf_fc_hwqp *hwqp), 0);
199 DEFINE_STUB(nvmf_fc_set_q_online_state, int, (struct spdk_nvmf_fc_hwqp *hwqp, bool online), 0);
200 DEFINE_STUB(nvmf_fc_put_xchg, int, (struct spdk_nvmf_fc_hwqp *hwqp, struct spdk_nvmf_fc_xchg *xri),
201 	    0);
202 DEFINE_STUB(nvmf_fc_recv_data, int, (struct spdk_nvmf_fc_request *fc_req), 0);
203 DEFINE_STUB(nvmf_fc_send_data, int, (struct spdk_nvmf_fc_request *fc_req), 0);
204 DEFINE_STUB_V(nvmf_fc_rqpair_buffer_release, (struct spdk_nvmf_fc_hwqp *hwqp, uint16_t buff_idx));
205 DEFINE_STUB(nvmf_fc_xmt_rsp, int, (struct spdk_nvmf_fc_request *fc_req, uint8_t *ersp_buf,
206 				   uint32_t ersp_len), 0);
207 DEFINE_STUB(nvmf_fc_xmt_ls_rsp, int, (struct spdk_nvmf_fc_nport *tgtport,
208 				      struct spdk_nvmf_fc_ls_rqst *ls_rqst), 0);
209 DEFINE_STUB(nvmf_fc_issue_abort, int, (struct spdk_nvmf_fc_hwqp *hwqp,
210 				       struct spdk_nvmf_fc_xchg *xri,
211 				       spdk_nvmf_fc_caller_cb cb, void *cb_args), 0);
212 DEFINE_STUB(nvmf_fc_xmt_bls_rsp, int, (struct spdk_nvmf_fc_hwqp *hwqp,
213 				       uint16_t ox_id, uint16_t rx_id,
214 				       uint16_t rpi, bool rjt, uint8_t rjt_exp,
215 				       spdk_nvmf_fc_caller_cb cb, void *cb_args), 0);
216 DEFINE_STUB(nvmf_fc_alloc_srsr_bufs, struct spdk_nvmf_fc_srsr_bufs *, (size_t rqst_len,
217 		size_t rsp_len), NULL);
218 DEFINE_STUB_V(nvmf_fc_free_srsr_bufs, (struct spdk_nvmf_fc_srsr_bufs *srsr_bufs));
219 DEFINE_STUB(nvmf_fc_xmt_srsr_req, int, (struct spdk_nvmf_fc_hwqp *hwqp,
220 					struct spdk_nvmf_fc_srsr_bufs *xmt_srsr_bufs,
221 					spdk_nvmf_fc_caller_cb cb, void *cb_args), 0);
222 DEFINE_STUB(nvmf_fc_q_sync_available, bool, (void), true);
223 DEFINE_STUB(nvmf_fc_issue_q_sync, int, (struct spdk_nvmf_fc_hwqp *hwqp, uint64_t u_id,
224 					uint16_t skip_rq), 0);
225 DEFINE_STUB(nvmf_fc_assign_conn_to_hwqp, bool, (struct spdk_nvmf_fc_hwqp *hwqp,
226 		uint64_t *conn_id, uint32_t sq_size), true);
227 DEFINE_STUB(nvmf_fc_get_hwqp_from_conn_id, struct spdk_nvmf_fc_hwqp *,
228 	    (struct spdk_nvmf_fc_hwqp *queues,
229 	     uint32_t num_queues, uint64_t conn_id), NULL);
230 DEFINE_STUB_V(nvmf_fc_dump_all_queues, (struct spdk_nvmf_fc_hwqp *ls_queue,
231 					struct spdk_nvmf_fc_hwqp *io_queues,
232 					uint32_t num_io_queues,
233 					struct spdk_nvmf_fc_queue_dump_info *dump_info));
234 DEFINE_STUB_V(nvmf_fc_get_xri_info, (struct spdk_nvmf_fc_hwqp *hwqp,
235 				     struct spdk_nvmf_fc_xchg_info *info));
236 DEFINE_STUB(nvmf_fc_get_rsvd_thread, struct spdk_thread *, (void), NULL);
237 
238 uint32_t
239 nvmf_fc_process_queue(struct spdk_nvmf_fc_hwqp *hwqp)
240 {
241 	hwqp->lcore_id++;
242 	return 0; /* always return 0 or else it will poll forever */
243 }
244 
245 struct spdk_nvmf_fc_xchg *
246 nvmf_fc_get_xri(struct spdk_nvmf_fc_hwqp *hwqp)
247 {
248 	static struct spdk_nvmf_fc_xchg xchg;
249 
250 	xchg.xchg_id = 1;
251 	return &xchg;
252 }
253 
254 #define MAX_FC_UT_POLL_THREADS 8
255 static struct spdk_nvmf_poll_group *g_poll_groups[MAX_FC_UT_POLL_THREADS] = {0};
256 #define MAX_FC_UT_HWQPS MAX_FC_UT_POLL_THREADS
257 static struct spdk_nvmf_tgt *g_nvmf_tgt = NULL;
258 static struct spdk_nvmf_transport *g_nvmf_tprt = NULL;
259 uint8_t g_fc_port_handle = 0xff;
260 struct spdk_nvmf_fc_hwqp lld_q[MAX_FC_UT_HWQPS];
261 
262 static void
263 _add_transport_done(void *arg, int status)
264 {
265 	CU_ASSERT(status == 0);
266 }
267 
268 static void
269 _add_transport_done_dup_err(void *arg, int status)
270 {
271 	CU_ASSERT(status == -EEXIST);
272 }
273 
274 static void
275 create_transport_test(void)
276 {
277 	const struct spdk_nvmf_transport_ops *ops = NULL;
278 	struct spdk_nvmf_transport_opts opts = { 0 };
279 	struct spdk_nvmf_target_opts tgt_opts = {
280 		.name = "nvmf_test_tgt",
281 		.max_subsystems = 0
282 	};
283 
284 	allocate_threads(8);
285 	set_thread(0);
286 
287 	g_nvmf_tgt = spdk_nvmf_tgt_create(&tgt_opts);
288 	SPDK_CU_ASSERT_FATAL(g_nvmf_tgt != NULL);
289 
290 	ops = nvmf_get_transport_ops(SPDK_NVME_TRANSPORT_NAME_FC);
291 	SPDK_CU_ASSERT_FATAL(ops != NULL);
292 
293 	ops->opts_init(&opts);
294 
295 	g_lld_init_called = false;
296 	opts.opts_size = sizeof(opts);
297 	g_nvmf_tprt = spdk_nvmf_transport_create("FC", &opts);
298 	SPDK_CU_ASSERT_FATAL(g_nvmf_tprt != NULL);
299 
300 	CU_ASSERT(g_lld_init_called == true);
301 	CU_ASSERT(opts.max_queue_depth == g_nvmf_tprt->opts.max_queue_depth);
302 	CU_ASSERT(opts.max_qpairs_per_ctrlr == g_nvmf_tprt->opts.max_qpairs_per_ctrlr);
303 	CU_ASSERT(opts.in_capsule_data_size == g_nvmf_tprt->opts.in_capsule_data_size);
304 	CU_ASSERT(opts.max_io_size == g_nvmf_tprt->opts.max_io_size);
305 	CU_ASSERT(opts.io_unit_size == g_nvmf_tprt->opts.io_unit_size);
306 	CU_ASSERT(opts.max_aq_depth == g_nvmf_tprt->opts.max_aq_depth);
307 
308 	set_thread(0);
309 
310 	spdk_nvmf_tgt_add_transport(g_nvmf_tgt, g_nvmf_tprt,
311 				    _add_transport_done, 0);
312 	poll_thread(0);
313 
314 	/* Add transport again - should get error */
315 	spdk_nvmf_tgt_add_transport(g_nvmf_tgt, g_nvmf_tprt,
316 				    _add_transport_done_dup_err, 0);
317 	poll_thread(0);
318 
319 	/* create transport with bad args/options */
320 #ifndef SPDK_CONFIG_RDMA
321 	CU_ASSERT(spdk_nvmf_transport_create("RDMA", &opts) == NULL);
322 #endif
323 	CU_ASSERT(spdk_nvmf_transport_create("Bogus Transport", &opts) == NULL);
324 	opts.max_io_size = 1024 ^ 3;
325 	CU_ASSERT(spdk_nvmf_transport_create("FC", &opts) == NULL);
326 	opts.max_io_size = 999;
327 	opts.io_unit_size = 1024;
328 	CU_ASSERT(spdk_nvmf_transport_create("FC", &opts) == NULL);
329 }
330 
331 static void
332 port_init_cb(uint8_t port_handle, enum spdk_fc_event event_type, void *arg, int err)
333 {
334 	CU_ASSERT(err == 0);
335 	CU_ASSERT(port_handle == 2);
336 	g_fc_port_handle = port_handle;
337 }
338 
339 static void
340 create_fc_port_test(void)
341 {
342 	struct spdk_nvmf_fc_hw_port_init_args init_args = { 0 };
343 	struct spdk_nvmf_fc_port *fc_port = NULL;
344 	int err;
345 
346 	SPDK_CU_ASSERT_FATAL(g_nvmf_tprt != NULL);
347 
348 	init_args.port_handle = 2;
349 	init_args.io_queue_cnt = spdk_min(MAX_FC_UT_HWQPS, spdk_env_get_core_count());
350 	init_args.ls_queue_size = 100;
351 	init_args.io_queue_size = 100;
352 	init_args.io_queues = (void *)lld_q;
353 
354 	set_thread(0);
355 	err = nvmf_fc_main_enqueue_event(SPDK_FC_HW_PORT_INIT, (void *)&init_args, port_init_cb);
356 	CU_ASSERT(err == 0);
357 	poll_thread(0);
358 
359 	fc_port = nvmf_fc_port_lookup(g_fc_port_handle);
360 	CU_ASSERT(fc_port != NULL);
361 }
362 
363 static void
364 online_fc_port_test(void)
365 {
366 	struct spdk_nvmf_fc_port *fc_port;
367 	struct spdk_nvmf_fc_hw_port_online_args args;
368 	int err;
369 
370 	SPDK_CU_ASSERT_FATAL(g_nvmf_tprt != NULL);
371 
372 	fc_port = nvmf_fc_port_lookup(g_fc_port_handle);
373 	SPDK_CU_ASSERT_FATAL(fc_port != NULL);
374 
375 	set_thread(0);
376 	args.port_handle = g_fc_port_handle;
377 	err = nvmf_fc_main_enqueue_event(SPDK_FC_HW_PORT_ONLINE, (void *)&args, port_init_cb);
378 	CU_ASSERT(err == 0);
379 	poll_threads();
380 	set_thread(0);
381 	if (err == 0) {
382 		uint32_t i;
383 		for (i = 0; i < fc_port->num_io_queues; i++) {
384 			CU_ASSERT(fc_port->io_queues[i].fgroup != 0);
385 			CU_ASSERT(fc_port->io_queues[i].fgroup != 0);
386 			CU_ASSERT(fc_port->io_queues[i].fgroup->hwqp_count != 0);
387 		}
388 	}
389 }
390 
391 static void
392 create_poll_groups_test(void)
393 {
394 	unsigned i;
395 
396 	SPDK_CU_ASSERT_FATAL(g_nvmf_tprt != NULL);
397 
398 	for (i = 0; i < MAX_FC_UT_POLL_THREADS; i++) {
399 		set_thread(i);
400 		g_poll_groups[i] = spdk_nvmf_poll_group_create(g_nvmf_tgt);
401 		poll_thread(i);
402 		CU_ASSERT(g_poll_groups[i] != NULL);
403 	}
404 	set_thread(0);
405 }
406 
407 static void
408 poll_group_poll_test(void)
409 {
410 	unsigned i;
411 	unsigned poll_cnt =  10;
412 	struct spdk_nvmf_fc_port *fc_port = NULL;
413 
414 	SPDK_CU_ASSERT_FATAL(g_nvmf_tprt != NULL);
415 
416 	set_thread(0);
417 	fc_port = nvmf_fc_port_lookup(g_fc_port_handle);
418 	SPDK_CU_ASSERT_FATAL(fc_port != NULL);
419 
420 	for (i = 0; i < fc_port->num_io_queues; i++) {
421 		fc_port->io_queues[i].lcore_id = 0;
422 	}
423 
424 	for (i = 0; i < poll_cnt; i++) {
425 		/* this should cause spdk_nvmf_fc_poll_group_poll to be called() */
426 		poll_threads();
427 	}
428 
429 	/* check if hwqp's lcore_id has been updated */
430 	for (i = 0; i < fc_port->num_io_queues; i++) {
431 		CU_ASSERT(fc_port->io_queues[i].lcore_id == poll_cnt);
432 	}
433 }
434 
435 static void
436 remove_hwqps_from_poll_groups_test(void)
437 {
438 	unsigned i;
439 	struct spdk_nvmf_fc_port *fc_port = NULL;
440 
441 	SPDK_CU_ASSERT_FATAL(g_nvmf_tprt != NULL);
442 
443 	fc_port = nvmf_fc_port_lookup(g_fc_port_handle);
444 	SPDK_CU_ASSERT_FATAL(fc_port != NULL);
445 
446 	for (i = 0; i < fc_port->num_io_queues; i++) {
447 		nvmf_fc_poll_group_remove_hwqp(&fc_port->io_queues[i], NULL, NULL);
448 		poll_threads();
449 		CU_ASSERT(fc_port->io_queues[i].fgroup == 0);
450 	}
451 }
452 
453 static void
454 destroy_transport_test(void)
455 {
456 	unsigned i;
457 
458 	SPDK_CU_ASSERT_FATAL(g_nvmf_tprt != NULL);
459 
460 	for (i = 0; i < MAX_FC_UT_POLL_THREADS; i++) {
461 		set_thread(i);
462 		spdk_nvmf_poll_group_destroy(g_poll_groups[i], NULL, NULL);
463 		poll_thread(0);
464 	}
465 
466 	set_thread(0);
467 	SPDK_CU_ASSERT_FATAL(g_nvmf_tgt != NULL);
468 	g_lld_fini_called = false;
469 	spdk_nvmf_tgt_destroy(g_nvmf_tgt, NULL, NULL);
470 	poll_threads();
471 	CU_ASSERT(g_lld_fini_called == true);
472 }
473 
474 static int
475 nvmf_fc_tests_init(void)
476 {
477 	return 0;
478 }
479 
480 static int
481 nvmf_fc_tests_fini(void)
482 {
483 	free_threads();
484 	return 0;
485 }
486 
487 int main(int argc, char **argv)
488 {
489 	unsigned int num_failures = 0;
490 	CU_pSuite suite = NULL;
491 
492 	CU_set_error_action(CUEA_ABORT);
493 	CU_initialize_registry();
494 
495 	suite = CU_add_suite("NVMf-FC", nvmf_fc_tests_init, nvmf_fc_tests_fini);
496 
497 	CU_ADD_TEST(suite, create_transport_test);
498 	CU_ADD_TEST(suite, create_poll_groups_test);
499 	CU_ADD_TEST(suite, create_fc_port_test);
500 	CU_ADD_TEST(suite, online_fc_port_test);
501 	CU_ADD_TEST(suite, poll_group_poll_test);
502 	CU_ADD_TEST(suite, remove_hwqps_from_poll_groups_test);
503 	CU_ADD_TEST(suite, destroy_transport_test);
504 
505 	CU_basic_set_mode(CU_BRM_VERBOSE);
506 	CU_basic_run_tests();
507 	num_failures = CU_get_number_of_failures();
508 	CU_cleanup_registry();
509 
510 	return num_failures;
511 }
512