@@ -579,19 +579,42 @@ int flb_output_set_callback(flb_ctx_t *ctx, int ffd, char *name,
579579int flb_output_set_test (flb_ctx_t * ctx , int ffd , char * test_name ,
580580 void (* out_callback ) (void * , int , int , void * , size_t , void * ),
581581 void * out_callback_data ,
582- void * test_ctx )
582+ void * flush_ctx )
583583{
584- return flb_output_set_test_with_ctx_callback (ctx , ffd , test_name , out_callback ,
585- out_callback_data , test_ctx , NULL );
584+ struct flb_output_instance * o_ins ;
585+
586+ o_ins = out_instance_get (ctx , ffd );
587+ if (!o_ins ) {
588+ return -1 ;
589+ }
590+
591+ /*
592+ * Enabling a test, set the output instance in 'test' mode, so no real
593+ * flush callback is invoked, only the desired implemented test.
594+ */
595+
596+ /* Formatter test */
597+ if (strcmp (test_name , "formatter" ) == 0 ) {
598+ o_ins -> test_mode = FLB_TRUE ;
599+ o_ins -> test_formatter .rt_ctx = ctx ;
600+ o_ins -> test_formatter .rt_ffd = ffd ;
601+ o_ins -> test_formatter .rt_out_callback = out_callback ;
602+ o_ins -> test_formatter .rt_data = out_callback_data ;
603+ o_ins -> test_formatter .flush_ctx = flush_ctx ;
604+ }
605+ else {
606+ return -1 ;
607+ }
608+
609+ return 0 ;
586610}
587611
588- int flb_output_set_test_with_ctx_callback (flb_ctx_t * ctx , int ffd , char * test_name ,
589- void (* out_callback ) (void * , int , int , void * , size_t , void * ),
590- void * out_callback_data ,
591- void * test_ctx ,
592- void * (* test_ctx_callback ) (struct flb_config * ,
593- struct flb_input_instance * ,
594- void * , void * ))
612+ int flb_output_set_test_flush_ctx_callback (flb_ctx_t * ctx , int ffd ,
613+ char * test_name ,
614+ void * (* flush_ctx_callback ) (struct flb_config * ,
615+ struct flb_input_instance * ,
616+ void * , void * ),
617+ void * flush_ctx )
595618{
596619 struct flb_output_instance * o_ins ;
597620
@@ -610,10 +633,8 @@ int flb_output_set_test_with_ctx_callback(flb_ctx_t *ctx, int ffd, char *test_na
610633 o_ins -> test_mode = FLB_TRUE ;
611634 o_ins -> test_formatter .rt_ctx = ctx ;
612635 o_ins -> test_formatter .rt_ffd = ffd ;
613- o_ins -> test_formatter .rt_out_callback = out_callback ;
614- o_ins -> test_formatter .rt_data = out_callback_data ;
615- o_ins -> test_formatter .flush_ctx = test_ctx ;
616- o_ins -> test_formatter .flush_ctx_callback = test_ctx_callback ;
636+ o_ins -> test_formatter .flush_ctx = flush_ctx ;
637+ o_ins -> test_formatter .flush_ctx_callback = flush_ctx_callback ;
617638 }
618639 else {
619640 return -1 ;
0 commit comments