From 3af1adb8aaea49ae2e2256d3cb6f988545ea4d68 Mon Sep 17 00:00:00 2001 From: Shuhei Matsumoto Date: Wed, 25 Mar 2020 15:45:30 +0900 Subject: [PATCH] ut/compress: Use SPDK thread library Use SPDK thread library in unit tests for compress bdev. This will enable us to write unit tests for refactoring. Signed-off-by: Shuhei Matsumoto Change-Id: Iac3867cca460b998c9b3953aae5241ffddc3168b Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/1451 Tested-by: SPDK CI Jenkins Reviewed-by: Ben Walker Reviewed-by: Paul Luse Reviewed-by: Darek Stojaczyk --- test/unit/lib/bdev/compress.c/compress_ut.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/test/unit/lib/bdev/compress.c/compress_ut.c b/test/unit/lib/bdev/compress.c/compress_ut.c index d6adc1ae2..dae03cf3e 100644 --- a/test/unit/lib/bdev/compress.c/compress_ut.c +++ b/test/unit/lib/bdev/compress.c/compress_ut.c @@ -520,8 +520,15 @@ rte_compressdev_enqueue_burst(uint8_t dev_id, uint16_t qp_id, struct rte_comp_op static int test_setup(void) { + struct spdk_thread *thread; int i; + spdk_thread_lib_init(NULL, 0); + + thread = spdk_thread_create(NULL, NULL); + spdk_set_thread(thread); + + g_comp_bdev.reduce_thread = thread; g_comp_bdev.backing_dev.unmap = _comp_reduce_unmap; g_comp_bdev.backing_dev.readv = _comp_reduce_readv; g_comp_bdev.backing_dev.writev = _comp_reduce_writev; @@ -572,6 +579,7 @@ test_setup(void) g_bdev_io->u.bdev.iovs = calloc(128, sizeof(struct iovec)); g_bdev_io->bdev = &g_comp_bdev.comp_bdev; g_io_ch = calloc(1, sizeof(struct spdk_io_channel) + sizeof(struct comp_io_channel)); + g_io_ch->thread = thread; g_comp_ch = (struct comp_io_channel *)((uint8_t *)g_io_ch + sizeof(struct spdk_io_channel)); g_io_ctx = (struct comp_bdev_io *)g_bdev_io->driver_ctx; @@ -597,6 +605,7 @@ test_setup(void) static int test_cleanup(void) { + struct spdk_thread *thread; int i; for (i = 0; i < UT_MBUFS_PER_OP_BOUND_TEST; i++) { @@ -608,6 +617,13 @@ test_cleanup(void) free(g_bdev_io->u.bdev.iovs); free(g_bdev_io); free(g_io_ch); + + thread = spdk_get_thread(); + spdk_thread_exit(thread); + spdk_thread_destroy(thread); + + spdk_thread_lib_fini(); + return 0; }