@@ -1144,6 +1144,75 @@ void flb_test_skip_empty_lines()
11441144 test_tail_ctx_destroy (ctx );
11451145}
11461146
1147+ void flb_test_skip_empty_lines_crlf ()
1148+ {
1149+ struct flb_lib_out_cb cb_data ;
1150+ struct test_tail_ctx * ctx ;
1151+ char * file [] = {"skip_empty_lines_crlf.log" };
1152+ char * empty_lines [] = {"\r\n" , "\r\n" };
1153+ char * msg = "lalala" ;
1154+ int ret ;
1155+ int num ;
1156+ int i ;
1157+
1158+ char * expected_strs [] = {msg };
1159+ struct str_list expected = {
1160+ .size = sizeof (expected_strs )/sizeof (char * ),
1161+ .lists = & expected_strs [0 ],
1162+ };
1163+
1164+ clear_output_num ();
1165+
1166+ cb_data .cb = cb_check_json_str_list ;
1167+ cb_data .data = & expected ;
1168+
1169+ ctx = test_tail_ctx_create (& cb_data , & file [0 ], sizeof (file )/sizeof (char * ), FLB_TRUE );
1170+ if (!TEST_CHECK (ctx != NULL )) {
1171+ TEST_MSG ("test_ctx_create failed" );
1172+ exit (EXIT_FAILURE );
1173+ }
1174+
1175+ ret = flb_input_set (ctx -> flb , ctx -> o_ffd ,
1176+ "path" , file [0 ],
1177+ "skip_empty_lines" , "true" ,
1178+ "Read_From_Head" , "true" ,
1179+ NULL );
1180+ TEST_CHECK (ret == 0 );
1181+
1182+ ret = flb_output_set (ctx -> flb , ctx -> o_ffd ,
1183+ "format" , "json" ,
1184+ NULL );
1185+ TEST_CHECK (ret == 0 );
1186+
1187+ ret = write_msg (ctx , msg , strlen (msg ));
1188+ if (!TEST_CHECK (ret > 0 )) {
1189+ test_tail_ctx_destroy (ctx );
1190+ exit (EXIT_FAILURE );
1191+ }
1192+
1193+ for (i = 0 ; i < sizeof (empty_lines )/sizeof (char * ); i ++ ) {
1194+ ret = write_msg (ctx , empty_lines [i ], strlen (empty_lines [i ]));
1195+ if (!TEST_CHECK (ret > 0 )) {
1196+ test_tail_ctx_destroy (ctx );
1197+ exit (EXIT_FAILURE );
1198+ }
1199+ }
1200+
1201+ /* Start the engine */
1202+ ret = flb_start (ctx -> flb );
1203+ TEST_CHECK (ret == 0 );
1204+
1205+ /* waiting to flush */
1206+ flb_time_msleep (500 );
1207+
1208+ num = get_output_num ();
1209+ if (!TEST_CHECK (num == 1 )) {
1210+ TEST_MSG ("output error: expect=1 got=%d" , num );
1211+ }
1212+
1213+ test_tail_ctx_destroy (ctx );
1214+ }
1215+
11471216static int ignore_older (int expected , char * ignore_older )
11481217{
11491218 struct flb_lib_out_cb cb_data ;
@@ -1557,6 +1626,7 @@ TEST_LIST = {
15571626 {"exclude_path" , flb_test_exclude_path },
15581627 {"offset_key" , flb_test_offset_key },
15591628 {"skip_empty_lines" , flb_test_skip_empty_lines },
1629+ {"skip_empty_lines_crlf" , flb_test_skip_empty_lines_crlf },
15601630 {"ignore_older" , flb_test_ignore_older },
15611631#ifdef FLB_HAVE_INOTIFY
15621632 {"inotify_watcher_false" , flb_test_inotify_watcher_false },
0 commit comments