2323#include <sys/types.h>
2424#include <sys/stat.h>
2525#include <fcntl.h>
26+ #ifndef _WIN32
2627#include <unistd.h>
28+ #else
29+ #include <io.h>
30+ #endif
2731#include <string.h>
2832#include <stdlib.h>
2933#include <stdio.h>
@@ -89,15 +93,19 @@ static void test_ctx_destroy(struct test_ctx *ctx)
8993{
9094 TEST_CHECK (ctx != NULL );
9195
92- sleep ( 1 );
96+ flb_time_msleep ( 1000 );
9397 flb_stop (ctx -> flb );
9498 flb_destroy (ctx -> flb );
9599 flb_free (ctx );
96100}
97101
98102void delete_csv_file ()
99103{
104+ #ifdef _WIN32
105+ _unlink (TMP_CSV_PATH );
106+ #else
100107 unlink (TMP_CSV_PATH );
108+ #endif
101109}
102110
103111int create_csv_file (char * csv_content )
@@ -342,7 +350,7 @@ void flb_test_lookup_large_numbers(void)
342350 struct test_ctx * ctx ;
343351 struct flb_lib_out_cb cb_data ;
344352 char large_number_str [64 ];
345- snprintf (large_number_str , sizeof (large_number_str ), "%" PRId64 , LLONG_MAX );
353+ snprintf (large_number_str , sizeof (large_number_str ), "%lld" , ( long long ) LLONG_MAX );
346354
347355 char csv_content [256 ];
348356 snprintf (csv_content , sizeof (csv_content ),
@@ -351,7 +359,7 @@ void flb_test_lookup_large_numbers(void)
351359 "456,Small Number\n" , large_number_str );
352360
353361 char input [128 ];
354- snprintf (input , sizeof (input ), "[0, {\"big_number\": %" PRId64 " }]" , LLONG_MAX );
362+ snprintf (input , sizeof (input ), "[0, {\"big_number\": %lld }]" , ( long long ) LLONG_MAX );
355363
356364 cb_data .cb = cb_check_result_json ;
357365 cb_data .data = "\"number_desc\":\"Very Large Number\"" ;
@@ -516,8 +524,11 @@ void flb_test_lookup_long_csv_lines(void)
516524 fprintf (fp , "long_key," );
517525
518526 /* Write a very long value (> 4096 chars) */
519- for (int i = 0 ; i < 100 ; i ++ ) {
520- fprintf (fp , "This is a very long value that exceeds the original 4096 character buffer limit to test dynamic line reading functionality. " );
527+ {
528+ int i ;
529+ for (i = 0 ; i < 100 ; i ++ ) {
530+ fprintf (fp , "This is a very long value that exceeds the original 4096 character buffer limit to test dynamic line reading functionality. " );
531+ }
521532 }
522533 fprintf (fp , "\n" );
523534 fprintf (fp , "short_key,Short Value\n" );
@@ -649,9 +660,12 @@ void flb_test_dynamic_buffer(void)
649660
650661 /* Test appending characters that will cause growth */
651662 const char * test_str = "This is a test string that is longer than the initial capacity" ;
652- for (size_t i = 0 ; test_str [i ]; i ++ ) {
653- ret = dynbuf_append_char (& buf , test_str [i ]);
654- TEST_CHECK (ret == 0 );
663+ {
664+ size_t i ;
665+ for (i = 0 ; test_str [i ]; i ++ ) {
666+ ret = dynbuf_append_char (& buf , test_str [i ]);
667+ TEST_CHECK (ret == 0 );
668+ }
655669 }
656670
657671 TEST_CHECK (strcmp (buf .data , test_str ) == 0 );
@@ -735,8 +749,11 @@ void flb_test_lookup_large_csv(void)
735749 fprintf (fp , "key,value\n" );
736750
737751 /* Write 10,000 test entries */
738- for (int i = 1 ; i <= 10000 ; i ++ ) {
739- fprintf (fp , "user%d,User %d\n" , i , i );
752+ {
753+ int i ;
754+ for (i = 1 ; i <= 10000 ; i ++ ) {
755+ fprintf (fp , "user%d,User %d\n" , i , i );
756+ }
740757 }
741758 fclose (fp );
742759
@@ -907,13 +924,13 @@ void flb_test_lookup_metrics_matched(void)
907924 TEST_CHECK (skipped == 0 );
908925
909926 if (processed != 3 ) {
910- TEST_MSG ("Expected processed=3, got %" PRIu64 , processed );
927+ TEST_MSG ("Expected processed=3, got %llu" , ( unsigned long long ) processed );
911928 }
912929 if (matched != 2 ) {
913- TEST_MSG ("Expected matched=2, got %" PRIu64 , matched );
930+ TEST_MSG ("Expected matched=2, got %llu" , ( unsigned long long ) matched );
914931 }
915932 if (skipped != 0 ) {
916- TEST_MSG ("Expected skipped=0, got %" PRIu64 , skipped );
933+ TEST_MSG ("Expected skipped=0, got %llu" , ( unsigned long long ) skipped );
917934 }
918935
919936 delete_csv_file ();
@@ -962,19 +979,24 @@ void flb_test_lookup_metrics_processed(void)
962979 /* Send 20 matching records and 10 non-matching records */
963980 const int matching_count = 20 ;
964981 const int non_matching_count = 10 ;
965-
966- for (int i = 0 ; i < matching_count ; i ++ ) {
967- char input [256 ];
968- snprintf (input , sizeof (input ), "[0, {\"test_key\": \"match_key\", \"seq\": %d}]" , i );
969- bytes = flb_lib_push (ctx -> flb , ctx -> i_ffd , input , strlen (input ));
970- TEST_CHECK (bytes == strlen (input ));
982+ {
983+ int i ;
984+ for (i = 0 ; i < matching_count ; i ++ ) {
985+ char input [256 ];
986+ snprintf (input , sizeof (input ), "[0, {\"test_key\": \"match_key\", \"seq\": %d}]" , i );
987+ bytes = flb_lib_push (ctx -> flb , ctx -> i_ffd , input , strlen (input ));
988+ TEST_CHECK (bytes == strlen (input ));
989+ }
971990 }
972991
973- for (int i = 0 ; i < non_matching_count ; i ++ ) {
974- char input [256 ];
975- snprintf (input , sizeof (input ), "[0, {\"test_key\": \"no_match_%d\", \"seq\": %d}]" , i , i );
976- bytes = flb_lib_push (ctx -> flb , ctx -> i_ffd , input , strlen (input ));
977- TEST_CHECK (bytes == strlen (input ));
992+ {
993+ int i ;
994+ for (i = 0 ; i < non_matching_count ; i ++ ) {
995+ char input [256 ];
996+ snprintf (input , sizeof (input ), "[0, {\"test_key\": \"no_match_%d\", \"seq\": %d}]" , i , i );
997+ bytes = flb_lib_push (ctx -> flb , ctx -> i_ffd , input , strlen (input ));
998+ TEST_CHECK (bytes == strlen (input ));
999+ }
9781000 }
9791001
9801002 flb_time_msleep (3000 ); /* Give more time for processing large volume */
@@ -989,13 +1011,13 @@ void flb_test_lookup_metrics_processed(void)
9891011 TEST_CHECK (skipped == 0 );
9901012
9911013 if (processed != matching_count + non_matching_count ) {
992- TEST_MSG ("Expected processed=%d, got %" PRIu64 , matching_count + non_matching_count , processed );
1014+ TEST_MSG ("Expected processed=%d, got %llu" , matching_count + non_matching_count , ( unsigned long long ) processed );
9931015 }
9941016 if (matched != matching_count ) {
995- TEST_MSG ("Expected matched=%d, got %" PRIu64 , matching_count , matched );
1017+ TEST_MSG ("Expected matched=%d, got %llu" , matching_count , ( unsigned long long ) matched );
9961018 }
9971019 if (skipped != 0 ) {
998- TEST_MSG ("Expected skipped=0, got %" PRIu64 , skipped );
1020+ TEST_MSG ("Expected skipped=0, got %llu" , ( unsigned long long ) skipped );
9991021 }
10001022
10011023 delete_csv_file ();
0 commit comments