@@ -115,7 +115,7 @@ void flb_test_logrotate_basic_rotation(void)
115115 TEST_CHECK (out_ffd >= 0 );
116116 flb_output_set (ctx , out_ffd , "match" , "test" , NULL );
117117 flb_output_set (ctx , out_ffd , "file" , TEST_LOGFILE , NULL );
118- flb_output_set (ctx , out_ffd , "max_size" , "1 " , NULL ); /* 1 MB */
118+ flb_output_set (ctx , out_ffd , "max_size" , "1M " , NULL ); /* 1 MB */
119119 flb_output_set (ctx , out_ffd , "max_files" , "3" , NULL );
120120 flb_output_set (ctx , out_ffd , "gzip" , "false" , NULL );
121121
@@ -142,13 +142,8 @@ void flb_test_logrotate_basic_rotation(void)
142142 fclose (fp );
143143 }
144144
145- /* Check that a rotated file was created */
146- fp = fopen (rotated_file , "r" );
147- TEST_CHECK (fp != NULL );
148- if (fp != NULL ) {
149- fclose (fp );
150- remove (rotated_file );
151- }
145+ /* Check that at least one rotated file exists: "flb_test_logrotate.log.*" */
146+ TEST_CHECK (count_files_in_directory ("." , "flb_test_logrotate.log." ) >= 1 );
152147
153148 remove (TEST_LOGFILE );
154149}
@@ -187,7 +182,7 @@ void flb_test_logrotate_gzip_compression(void)
187182 TEST_CHECK (out_ffd >= 0 );
188183 flb_output_set (ctx , out_ffd , "match" , "test" , NULL );
189184 flb_output_set (ctx , out_ffd , "file" , TEST_LOGFILE , NULL );
190- flb_output_set (ctx , out_ffd , "max_size" , "1 " , NULL ); /* 1 MB */
185+ flb_output_set (ctx , out_ffd , "max_size" , "1M " , NULL ); /* 1 MB */
191186 flb_output_set (ctx , out_ffd , "max_files" , "3" , NULL );
192187 flb_output_set (ctx , out_ffd , "gzip" , "true" , NULL );
193188
@@ -206,10 +201,23 @@ void flb_test_logrotate_gzip_compression(void)
206201 flb_stop (ctx );
207202 flb_destroy (ctx );
208203
209- /* Check that a gzipped rotated file was created */
210- snprintf (rotated_file , sizeof (rotated_file ), "%s.%s" , TEST_LOGFILE , timestamp );
211- ret = check_gzip_file_exists (rotated_file );
212- TEST_CHECK (ret == 1 );
204+ /* Check that a gzipped rotated file exists: "flb_test_logrotate.log.*.gz" */
205+ ret = 0 ;
206+ {
207+ DIR * dir = opendir ("." );
208+ struct dirent * entry ;
209+ if (dir ) {
210+ while ((entry = readdir (dir )) != NULL ) {
211+ if (strstr (entry -> d_name , "flb_test_logrotate.log." ) == entry -> d_name &&
212+ strstr (entry -> d_name , ".gz" ) != NULL ) {
213+ ret = 1 ;
214+ break ;
215+ }
216+ }
217+ closedir (dir );
218+ }
219+ }
220+ TEST_CHECK (ret == 1 );
213221
214222 /* Clean up */
215223 remove (rotated_file );
@@ -241,7 +249,7 @@ void flb_test_logrotate_max_files_cleanup(void)
241249 TEST_CHECK (out_ffd >= 0 );
242250 flb_output_set (ctx , out_ffd , "match" , "test" , NULL );
243251 flb_output_set (ctx , out_ffd , "file" , TEST_LOGFILE , NULL );
244- flb_output_set (ctx , out_ffd , "max_size" , "1 " , NULL ); /* 1 MB */
252+ flb_output_set (ctx , out_ffd , "max_size" , "1M " , NULL ); /* 1 MB */
245253 flb_output_set (ctx , out_ffd , "max_files" , "2" , NULL ); /* Only keep 2 files */
246254 flb_output_set (ctx , out_ffd , "gzip" , "false" , NULL );
247255
@@ -293,7 +301,7 @@ void flb_test_logrotate_counter_based_size(void)
293301 TEST_CHECK (out_ffd >= 0 );
294302 flb_output_set (ctx , out_ffd , "match" , "test" , NULL );
295303 flb_output_set (ctx , out_ffd , "file" , TEST_LOGFILE , NULL );
296- flb_output_set (ctx , out_ffd , "max_size" , "1 " , NULL ); /* 1 MB */
304+ flb_output_set (ctx , out_ffd , "max_size" , "1M " , NULL ); /* 1 MB */
297305 flb_output_set (ctx , out_ffd , "max_files" , "3" , NULL );
298306 flb_output_set (ctx , out_ffd , "gzip" , "false" , NULL );
299307
@@ -352,7 +360,8 @@ void flb_test_logrotate_different_formats(void)
352360 flb_output_set (ctx , out_ffd , "match" , "test" , NULL );
353361 flb_output_set (ctx , out_ffd , "file" , TEST_LOGFILE , NULL );
354362 flb_output_set (ctx , out_ffd , "format" , "csv" , NULL );
355- flb_output_set (ctx , out_ffd , "max_size" , "10" , NULL ); /* 10 MB */
363+ flb_output_set (ctx , out_ffd , "csv_column_names" , "true" , NULL );
364+ flb_output_set (ctx , out_ffd , "max_size" , "10M" , NULL ); /* 10 MB */
356365 flb_output_set (ctx , out_ffd , "max_files" , "3" , NULL );
357366 flb_output_set (ctx , out_ffd , "gzip" , "false" , NULL );
358367
@@ -420,7 +429,7 @@ void flb_test_logrotate_mkdir_support(void)
420429 flb_output_set (ctx , out_ffd , "match" , "test" , NULL );
421430 flb_output_set (ctx , out_ffd , "path" , TEST_LOGPATH , NULL );
422431 flb_output_set (ctx , out_ffd , "mkdir" , "true" , NULL );
423- flb_output_set (ctx , out_ffd , "max_size" , "10 " , NULL );
432+ flb_output_set (ctx , out_ffd , "max_size" , "10M " , NULL );
424433 flb_output_set (ctx , out_ffd , "max_files" , "3" , NULL );
425434 flb_output_set (ctx , out_ffd , "gzip" , "false" , NULL );
426435
@@ -474,7 +483,7 @@ void flb_test_logrotate_performance_test(void)
474483 TEST_CHECK (out_ffd >= 0 );
475484 flb_output_set (ctx , out_ffd , "match" , "test" , NULL );
476485 flb_output_set (ctx , out_ffd , "file" , TEST_LOGFILE , NULL );
477- flb_output_set (ctx , out_ffd , "max_size" , "10 " , NULL ); /* 10 MB */
486+ flb_output_set (ctx , out_ffd , "max_size" , "10M " , NULL ); /* 10 MB */
478487 flb_output_set (ctx , out_ffd , "max_files" , "3" , NULL );
479488 flb_output_set (ctx , out_ffd , "gzip" , "false" , NULL );
480489
0 commit comments