Store loggers in conftest separately, not on charon

This commit is contained in:
Tobias Brunner 2012-10-02 14:49:26 +02:00
parent 3c4d383443
commit 18a8893e8e
2 changed files with 19 additions and 6 deletions

View File

@ -322,6 +322,7 @@ static bool load_hooks()
*/
static void cleanup()
{
file_logger_t *logger;
hook_t *hook;
DESTROY_IF(conftest->test);
@ -344,6 +345,13 @@ static void cleanup()
}
conftest->config->destroy(conftest->config);
}
while (conftest->loggers->remove_last(conftest->loggers,
(void**)&logger) == SUCCESS)
{
charon->bus->remove_logger(charon->bus, &logger->logger);
logger->destroy(logger);
}
conftest->loggers->destroy(conftest->loggers);
free(conftest->suite_dir);
free(conftest);
libcharon_deinit();
@ -394,7 +402,7 @@ static void load_loggers(file_logger_t *logger)
logger = file_logger_create(file, NULL, FALSE);
load_log_levels(logger, section);
charon->bus->add_logger(charon->bus, &logger->logger);
charon->file_loggers->insert_last(charon->file_loggers, logger);
conftest->loggers->insert_last(conftest->loggers, logger);
}
}
enumerator->destroy(enumerator);
@ -433,16 +441,16 @@ int main(int argc, char *argv[])
INIT(conftest,
.creds = mem_cred_create(),
.config = config_create(),
.hooks = linked_list_create(),
.loggers = linked_list_create(),
);
lib->credmgr->add_set(lib->credmgr, &conftest->creds->set);
logger = file_logger_create(stdout, NULL, FALSE);
logger->set_level(logger, DBG_ANY, LEVEL_CTRL);
charon->bus->add_logger(charon->bus, &logger->logger);
charon->file_loggers->insert_last(charon->file_loggers, logger);
lib->credmgr->add_set(lib->credmgr, &conftest->creds->set);
conftest->hooks = linked_list_create();
conftest->config = config_create();
conftest->loggers->insert_last(conftest->loggers, logger);
atexit(cleanup);

View File

@ -64,6 +64,11 @@ struct conftest_t {
* Action handling
*/
actions_t *actions;
/**
* Test specific loggers
*/
linked_list_t *loggers;
};
/**