From bd9f5c3c193843b30378a590468564354bfba8ae Mon Sep 17 00:00:00 2001 From: Evan Hunt Date: Tue, 12 Nov 2019 23:13:49 -0800 Subject: [PATCH] fix netmgr setup/teardown issues; setup and teardown only once in timer_test - the netmgr was not correctly being specified when creating the task manager, and was cleaned up in the wrong order when shutting down. - on freebsd, timer_test appears to be prone to failure if the netmgr is set up and torn down before and after ever test case, but less so if it's only set up once at the beginning and once at the end. --- lib/isc/tests/isctest.c | 10 +++++----- lib/isc/tests/timer_test.c | 12 ++++++------ 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/lib/isc/tests/isctest.c b/lib/isc/tests/isctest.c index 5e7827a8e2..e3d59611e7 100644 --- a/lib/isc/tests/isctest.c +++ b/lib/isc/tests/isctest.c @@ -56,9 +56,6 @@ static isc_logcategory_t categories[] = { static void cleanup_managers(void) { - if (netmgr != NULL) { - isc_nm_detach(&netmgr); - } if (maintask != NULL) { isc_task_shutdown(maintask); isc_task_destroy(&maintask); @@ -72,6 +69,9 @@ cleanup_managers(void) { if (timermgr != NULL) { isc_timermgr_destroy(&timermgr); } + if (netmgr != NULL) { + isc_nm_detach(&netmgr); + } } static isc_result_t @@ -88,13 +88,13 @@ create_managers(unsigned int workers) { workers = atoi(p); } - CHECK(isc_taskmgr_create(test_mctx, workers, 0, NULL, &taskmgr)); + netmgr = isc_nm_start(test_mctx, workers); + CHECK(isc_taskmgr_create(test_mctx, workers, 0, netmgr, &taskmgr)); CHECK(isc_task_create(taskmgr, 0, &maintask)); isc_taskmgr_setexcltask(taskmgr, maintask); CHECK(isc_timermgr_create(test_mctx, &timermgr)); CHECK(isc_socketmgr_create(test_mctx, &socketmgr)); - netmgr = isc_nm_start(test_mctx, 3); return (ISC_R_SUCCESS); cleanup: diff --git a/lib/isc/tests/timer_test.c b/lib/isc/tests/timer_test.c index 613e9c60c0..22325d4a38 100644 --- a/lib/isc/tests/timer_test.c +++ b/lib/isc/tests/timer_test.c @@ -624,11 +624,11 @@ purge(void **state) { int main(int argc, char **argv) { const struct CMUnitTest tests[] = { - cmocka_unit_test_setup_teardown(ticker, _setup, _teardown), - cmocka_unit_test_setup_teardown(once_life, _setup, _teardown), - cmocka_unit_test_setup_teardown(once_idle, _setup, _teardown), - cmocka_unit_test_setup_teardown(reset, _setup, _teardown), - cmocka_unit_test_setup_teardown(purge, _setup, _teardown), + cmocka_unit_test(ticker), + cmocka_unit_test(once_life), + cmocka_unit_test(once_idle), + cmocka_unit_test(reset), + cmocka_unit_test(purge), }; int c; @@ -642,7 +642,7 @@ main(int argc, char **argv) { } } - return (cmocka_run_group_tests(tests, NULL, NULL)); + return (cmocka_run_group_tests(tests, _setup, _teardown)); } #else /* HAVE_CMOCKA */