void cfg_free(GlobalConfig *self) { g_assert(self->persist == NULL); if (self->state) persist_state_free(self->state); g_free(self->file_template_name); g_free(self->proto_template_name); log_template_unref(self->file_template); log_template_unref(self->proto_template); log_template_options_destroy(&self->template_options); host_resolve_options_destroy(&self->host_resolve_options); if (self->bad_hostname_compiled) regfree(&self->bad_hostname); g_free(self->bad_hostname_re); dns_cache_options_destroy(&self->dns_cache_options); g_free(self->custom_domain); plugin_free_plugins(self); plugin_free_candidate_modules(self); cfg_tree_free_instance(&self->tree); g_hash_table_unref(self->module_config); g_free(self); }
static void assert_almighty_always_pipe (gboolean always_pipe_value, gboolean tree_start_expected, gboolean tree_stop_expected, gboolean was_init_called, gboolean was_deinit_called) { CfgTree tree; AlmightyAlwaysPipe *pipe; cfg_tree_init_instance (&tree, NULL); pipe = create_and_attach_almighty_pipe (&tree, always_pipe_value); assert_gboolean (cfg_tree_start (&tree), tree_start_expected, "cfg_tree_start() did not return the expected value"); assert_gboolean (cfg_tree_stop (&tree), tree_stop_expected, "cfg_tree_stop() did not return the epxected value"); assert_gboolean (pipe->init_called, was_init_called, "->init was called state"); assert_gboolean (pipe->deinit_called, was_deinit_called, "->deinit was called state"); cfg_tree_free_instance (&tree); }
void cfg_free(GlobalConfig *self) { g_assert(self->persist == NULL); if (self->state) persist_state_free(self->state); g_free(self->file_template_name); g_free(self->proto_template_name); log_template_unref(self->file_template); log_template_unref(self->proto_template); if (self->bad_hostname_compiled) regfree(&self->bad_hostname); g_free(self->bad_hostname_re); g_free(self->dns_cache_hosts); g_list_free(self->plugins); plugin_free_candidate_modules(self); cfg_tree_free_instance(&self->tree); g_free(self); }
static void test_pipe_init_multi_success (void) { CfgTree tree; testcase_begin ("A pipe of all good nodes will start & stop properly"); cfg_tree_init_instance (&tree, NULL); create_and_attach_almighty_pipe (&tree, TRUE); create_and_attach_almighty_pipe (&tree, TRUE); create_and_attach_almighty_pipe (&tree, TRUE); assert_true (cfg_tree_start (&tree), "Starting a tree of all-good nodes works"); assert_true (cfg_tree_stop (&tree), "Stopping a tree of all-good nodes works"); cfg_tree_free_instance (&tree); testcase_end (); }
static void test_pipe_init_multi_with_bad_node (void) { AlmightyAlwaysPipe *pipe1, *pipe2, *pipe3; CfgTree tree; testcase_begin ("A pipe of some bad nodes will not start, but cleans up nicely."); cfg_tree_init_instance (&tree, NULL); pipe1 = create_and_attach_almighty_pipe (&tree, TRUE); pipe2 = create_and_attach_almighty_pipe (&tree, FALSE); pipe3 = create_and_attach_almighty_pipe (&tree, TRUE); assert_false (cfg_tree_start (&tree), "Starting a tree of all-good nodes works"); assert_true (cfg_tree_stop (&tree), "Stopping a tree of all-good nodes works"); assert_true (pipe1->init_called, "The initializer of the first good pipe is called"); assert_true (pipe2->init_called, "The initializer of the bad pipe is called"); assert_false (pipe3->init_called, "The initializer of the second good pipe is NOT called"); assert_true (pipe1->deinit_called, "The deinitializer of the first good pipe is called"); assert_false (pipe2->deinit_called, "The deinitializer of the bad pipe is NOT called"); assert_false (pipe3->deinit_called, "The deinitializer of the second good pipe is NOT called"); cfg_tree_free_instance (&tree); testcase_end (); }