@@ -171,6 +171,94 @@ static void cleanup_test_output(struct flb_output_instance *out)
171171 }
172172}
173173
174+ static void cleanup_test_routing_scenario (struct flb_input_chunk * ic ,
175+ struct flb_output_instance * stdout_one ,
176+ struct flb_output_instance * stdout_two ,
177+ struct flb_output_instance * http_out ,
178+ struct flb_input_instance * in ,
179+ struct flb_config * config ,
180+ struct cio_chunk * chunk ,
181+ struct cio_ctx * ctx ,
182+ int config_ready ,
183+ const char * stream_path )
184+ {
185+ if (ic ) {
186+ flb_input_chunk_destroy (ic , FLB_TRUE );
187+ }
188+
189+ cleanup_test_output (stdout_one );
190+ cleanup_test_output (stdout_two );
191+ cleanup_test_output (http_out );
192+
193+ if (config_ready == FLB_TRUE ) {
194+ flb_input_instance_exit (in , config );
195+
196+ /* Manual cleanup for stack-allocated instance */
197+ /* Remove from list first (before destroying hash tables) */
198+ mk_list_del (& in -> _head );
199+
200+ /* Destroy hash tables */
201+ if (in -> ht_log_chunks ) {
202+ flb_hash_table_destroy (in -> ht_log_chunks );
203+ in -> ht_log_chunks = NULL ;
204+ }
205+ if (in -> ht_metric_chunks ) {
206+ flb_hash_table_destroy (in -> ht_metric_chunks );
207+ in -> ht_metric_chunks = NULL ;
208+ }
209+ if (in -> ht_trace_chunks ) {
210+ flb_hash_table_destroy (in -> ht_trace_chunks );
211+ in -> ht_trace_chunks = NULL ;
212+ }
213+ if (in -> ht_profile_chunks ) {
214+ flb_hash_table_destroy (in -> ht_profile_chunks );
215+ in -> ht_profile_chunks = NULL ;
216+ }
217+
218+ /* Release properties */
219+ flb_kv_release (& in -> properties );
220+ flb_kv_release (& in -> net_properties );
221+
222+ /* Destroy metrics (created by flb_input_instance_init) */
223+ #ifdef FLB_HAVE_METRICS
224+ if (in -> cmt ) {
225+ cmt_destroy (in -> cmt );
226+ in -> cmt = NULL ;
227+ }
228+ if (in -> metrics ) {
229+ flb_metrics_destroy (in -> metrics );
230+ in -> metrics = NULL ;
231+ }
232+ #endif
233+
234+ /* Destroy config map if created */
235+ if (in -> tls_config_map ) {
236+ flb_config_map_destroy (in -> tls_config_map );
237+ in -> tls_config_map = NULL ;
238+ }
239+ if (in -> net_config_map ) {
240+ flb_config_map_destroy (in -> net_config_map );
241+ in -> net_config_map = NULL ;
242+ }
243+
244+ flb_routes_empty_mask_destroy (config );
245+ if (config -> env ) {
246+ flb_env_destroy (config -> env );
247+ config -> env = NULL ;
248+ }
249+ }
250+
251+ if (chunk ) {
252+ cio_chunk_close (chunk , CIO_TRUE );
253+ }
254+
255+ if (ctx ) {
256+ cio_destroy (ctx );
257+ }
258+
259+ cio_utils_recursive_delete (stream_path );
260+ }
261+
174262static int write_legacy_chunk_metadata (struct cio_chunk * chunk ,
175263 int event_type ,
176264 const char * tag ,
@@ -522,83 +610,9 @@ static void test_chunk_restore_alias_plugin_match_multiple()
522610 & config ) == 0 );
523611
524612cleanup :
525- if (ic ) {
526- flb_input_chunk_destroy (ic , FLB_TRUE );
527- ic = NULL ;
528- }
529-
530- cleanup_test_output (& stdout_one );
531- cleanup_test_output (& stdout_two );
532- cleanup_test_output (& http_out );
533-
534- if (config_ready == FLB_TRUE ) {
535- flb_input_instance_exit (& in , & config );
536-
537- /* Manual cleanup for stack-allocated instance */
538- /* Remove from list first (before destroying hash tables) */
539- mk_list_del (& in ._head );
540-
541- /* Destroy hash tables */
542- if (in .ht_log_chunks ) {
543- flb_hash_table_destroy (in .ht_log_chunks );
544- in .ht_log_chunks = NULL ;
545- }
546- if (in .ht_metric_chunks ) {
547- flb_hash_table_destroy (in .ht_metric_chunks );
548- in .ht_metric_chunks = NULL ;
549- }
550- if (in .ht_trace_chunks ) {
551- flb_hash_table_destroy (in .ht_trace_chunks );
552- in .ht_trace_chunks = NULL ;
553- }
554- if (in .ht_profile_chunks ) {
555- flb_hash_table_destroy (in .ht_profile_chunks );
556- in .ht_profile_chunks = NULL ;
557- }
558-
559- /* Release properties */
560- flb_kv_release (& in .properties );
561- flb_kv_release (& in .net_properties );
562-
563- /* Destroy metrics (created by flb_input_instance_init) */
564- #ifdef FLB_HAVE_METRICS
565- if (in .cmt ) {
566- cmt_destroy (in .cmt );
567- in .cmt = NULL ;
568- }
569- if (in .metrics ) {
570- flb_metrics_destroy (in .metrics );
571- in .metrics = NULL ;
572- }
573- #endif
574-
575- /* Destroy config map if created */
576- if (in .tls_config_map ) {
577- flb_config_map_destroy (in .tls_config_map );
578- in .tls_config_map = NULL ;
579- }
580- if (in .net_config_map ) {
581- flb_config_map_destroy (in .net_config_map );
582- in .net_config_map = NULL ;
583- }
584-
585- flb_routes_empty_mask_destroy (& config );
586- if (config .env ) {
587- flb_env_destroy (config .env );
588- config .env = NULL ;
589- }
590- }
591-
592- if (chunk ) {
593- cio_chunk_close (chunk , CIO_TRUE );
594- chunk = NULL ;
595- }
596-
597- if (ctx ) {
598- cio_destroy (ctx );
599- }
600-
601- cio_utils_recursive_delete (TEST_STREAM_PATH_MATCH );
613+ cleanup_test_routing_scenario (ic , & stdout_one , & stdout_two , & http_out ,
614+ & in , & config , chunk , ctx , config_ready ,
615+ TEST_STREAM_PATH_MATCH );
602616}
603617
604618static void test_chunk_restore_alias_plugin_null_matches_all ()
@@ -757,83 +771,9 @@ static void test_chunk_restore_alias_plugin_null_matches_all()
757771 & config ) == 1 );
758772
759773cleanup :
760- if (ic ) {
761- flb_input_chunk_destroy (ic , FLB_TRUE );
762- ic = NULL ;
763- }
764-
765- cleanup_test_output (& stdout_one );
766- cleanup_test_output (& stdout_two );
767- cleanup_test_output (& http_out );
768-
769- if (config_ready == FLB_TRUE ) {
770- flb_input_instance_exit (& in , & config );
771-
772- /* Manual cleanup for stack-allocated instance */
773- /* Remove from list first (before destroying hash tables) */
774- mk_list_del (& in ._head );
775-
776- /* Destroy hash tables */
777- if (in .ht_log_chunks ) {
778- flb_hash_table_destroy (in .ht_log_chunks );
779- in .ht_log_chunks = NULL ;
780- }
781- if (in .ht_metric_chunks ) {
782- flb_hash_table_destroy (in .ht_metric_chunks );
783- in .ht_metric_chunks = NULL ;
784- }
785- if (in .ht_trace_chunks ) {
786- flb_hash_table_destroy (in .ht_trace_chunks );
787- in .ht_trace_chunks = NULL ;
788- }
789- if (in .ht_profile_chunks ) {
790- flb_hash_table_destroy (in .ht_profile_chunks );
791- in .ht_profile_chunks = NULL ;
792- }
793-
794- /* Release properties */
795- flb_kv_release (& in .properties );
796- flb_kv_release (& in .net_properties );
797-
798- /* Destroy metrics (created by flb_input_instance_init) */
799- #ifdef FLB_HAVE_METRICS
800- if (in .cmt ) {
801- cmt_destroy (in .cmt );
802- in .cmt = NULL ;
803- }
804- if (in .metrics ) {
805- flb_metrics_destroy (in .metrics );
806- in .metrics = NULL ;
807- }
808- #endif
809-
810- /* Destroy config map if created */
811- if (in .tls_config_map ) {
812- flb_config_map_destroy (in .tls_config_map );
813- in .tls_config_map = NULL ;
814- }
815- if (in .net_config_map ) {
816- flb_config_map_destroy (in .net_config_map );
817- in .net_config_map = NULL ;
818- }
819-
820- flb_routes_empty_mask_destroy (& config );
821- if (config .env ) {
822- flb_env_destroy (config .env );
823- config .env = NULL ;
824- }
825- }
826-
827- if (chunk ) {
828- cio_chunk_close (chunk , CIO_TRUE );
829- chunk = NULL ;
830- }
831-
832- if (ctx ) {
833- cio_destroy (ctx );
834- }
835-
836- cio_utils_recursive_delete (TEST_STREAM_PATH_NULL );
774+ cleanup_test_routing_scenario (ic , & stdout_one , & stdout_two , & http_out ,
775+ & in , & config , chunk , ctx , config_ready ,
776+ TEST_STREAM_PATH_NULL );
837777}
838778
839779TEST_LIST = {
0 commit comments