From: Evan Hunt Date: Wed, 13 Nov 2019 07:13:49 +0000 (-0800) Subject: fix netmgr setup/teardown issues; setup and teardown only once in timer_test X-Git-Tag: v9.15.6~11^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bd9f5c3c193843b30378a590468564354bfba8ae;p=thirdparty%2Fbind9.git 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. --- diff --git a/lib/isc/tests/isctest.c b/lib/isc/tests/isctest.c index 5e7827a8e2f..e3d59611e7a 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 613e9c60c06..22325d4a388 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 */