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.
This commit is contained in:
@@ -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:
|
||||
|
||||
@@ -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 */
|
||||
|
||||
Reference in New Issue
Block a user