From be2cb0c5350318c47add2cf6cab01eac86b33acc Mon Sep 17 00:00:00 2001 From: Jim Harris Date: Fri, 7 Jul 2017 13:15:22 -0700 Subject: [PATCH] test/bdevio: add delay before starting unit tests This is a bit of a workaround for some upcoming changes where bdev subsystem initialization will not wait for all vbdevs to finish tasting all bdevs that are registered. We need to allow those vbdevs to clean up after themselves after doing their initial tasting, before we start the unit tests, since the unit tests are blocking and won't return to the reactor loop to allow asynchronous tasting I/O to get returned to the vbdev modules. Eventually we should consider modifying bdevio run asynchronously, maybe including removing its use of CUnit for test reporting. Signed-off-by: Jim Harris Change-Id: I6c425dd2711ce06fb6df1678f08294d6228c9ae4 Reviewed-on: https://review.gerrithub.io/368616 Tested-by: SPDK Automated Test System Reviewed-by: Daniel Verkamp Reviewed-by: Ben Walker --- test/lib/bdev/bdevio/bdevio.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/test/lib/bdev/bdevio/bdevio.c b/test/lib/bdev/bdevio/bdevio.c index 0214906dc..fc6d387ba 100644 --- a/test/lib/bdev/bdevio/bdevio.c +++ b/test/lib/bdev/bdevio/bdevio.c @@ -51,6 +51,7 @@ pthread_mutex_t g_test_mutex; pthread_cond_t g_test_cond; +struct spdk_poller *g_start_timer; struct io_target { struct spdk_bdev *bdev; @@ -699,11 +700,13 @@ blockdev_test_reset(void) } static void -test_main(void *arg1, void *arg2) +test_main(void *arg1) { CU_pSuite suite = NULL; unsigned int num_failures; + spdk_poller_unregister(&g_start_timer, NULL); + pthread_mutex_init(&g_test_mutex, NULL); pthread_cond_init(&g_test_cond, NULL); @@ -765,6 +768,12 @@ test_main(void *arg1, void *arg2) spdk_app_stop(num_failures); } +static void +start_timer(void *arg1, void *arg2) +{ + spdk_poller_register(&g_start_timer, test_main, NULL, spdk_env_get_current_core(), 1000 * 1000); +} + int main(int argc, char **argv) { @@ -779,7 +788,7 @@ main(int argc, char **argv) } bdevtest_init(config_file, "0x3", &opts); - num_failures = spdk_app_start(&opts, test_main, NULL, NULL); + num_failures = spdk_app_start(&opts, start_timer, NULL, NULL); spdk_app_fini(); return num_failures;