@@ -162,8 +162,18 @@ void do_test(char *system, const char *target, ...)
162162 int out_ffd ;
163163 char path [PATH_MAX ];
164164 struct tail_test_result result = {0 };
165+ char * tmpdir ;
165166 char storage_path [PATH_MAX ];
166167
168+ tmpdir = flb_test_env_tmpdir ();
169+ TEST_CHECK (tmpdir != NULL );
170+ if (!tmpdir ) {
171+ return ;
172+ }
173+ snprintf (storage_path , sizeof (storage_path ) - 1 , "%s/input-chunk-test-%s" ,
174+ tmpdir , target );
175+ flb_free (tmpdir );
176+
167177 result .nMatched = 0 ;
168178 result .target = target ;
169179
@@ -176,8 +186,6 @@ void do_test(char *system, const char *target, ...)
176186
177187 ctx = flb_create ();
178188
179- snprintf (storage_path , sizeof (storage_path ) - 1 , "/tmp/input-chunk-test-%s" , target );
180-
181189 /* create chunks in /tmp folder */
182190 ret = flb_service_set (ctx ,
183191 "Parsers_File" , DPATH "parser.conf" ,
@@ -258,14 +266,21 @@ void flb_test_input_chunk_dropping_chunks()
258266 struct mk_list * head ;
259267 struct flb_input_chunk * ic ;
260268 struct flb_task * task ;
269+ char * storage_path ;
270+
271+ storage_path = flb_test_tmpdir_cat ("/input-chunk-test/" );
272+ TEST_CHECK (storage_path != NULL );
273+ if (!storage_path ) {
274+ return ;
275+ }
261276
262277 /* Create context, flush every second (some checks omitted here) */
263278 ctx = flb_create ();
264279
265280 /* create chunks in /tmp folder */
266281 ret = flb_service_set (ctx ,
267282 "flush" , "2" , "grace" , "1" ,
268- "storage.path" , "/tmp/input-chunk-test/" ,
283+ "storage.path" , storage_path ,
269284 "Log_Level" , "error" ,
270285 NULL );
271286
@@ -307,6 +322,7 @@ void flb_test_input_chunk_dropping_chunks()
307322 flb_time_msleep (2100 );
308323 flb_stop (ctx );
309324 flb_destroy (ctx );
325+ flb_free (storage_path );
310326}
311327
312328static int gen_buf (msgpack_sbuffer * mp_sbuf , char * buf , size_t buf_size )
@@ -365,6 +381,13 @@ void flb_test_input_chunk_fs_chunks_size_real()
365381 char buf [262144 ];
366382 struct mk_event_loop * evl ;
367383 struct cio_options opts = {0 };
384+ char * root_path ;
385+
386+ root_path = flb_test_tmpdir_cat ("/input-chunk-fs_chunks-size_real" );
387+ TEST_CHECK (root_path != NULL );
388+ if (!root_path ) {
389+ return ;
390+ }
368391
369392 flb_init_env ();
370393 cfg = flb_config_init ();
@@ -380,7 +403,7 @@ void flb_test_input_chunk_fs_chunks_size_real()
380403
381404 cio_options_init (& opts );
382405
383- opts .root_path = "/tmp/input-chunk-fs_chunks-size_real" ;
406+ opts .root_path = root_path ;
384407 opts .log_cb = log_cb ;
385408 opts .log_level = CIO_LOG_DEBUG ;
386409 opts .flags = CIO_OPEN ;
@@ -455,6 +478,7 @@ void flb_test_input_chunk_fs_chunks_size_real()
455478 flb_input_exit_all (cfg );
456479 flb_output_exit (cfg );
457480 flb_config_exit (cfg );
481+ flb_free (root_path );
458482}
459483
460484/* This tests uses the subsystems of the engine directly
@@ -475,6 +499,13 @@ void flb_test_input_chunk_correct_total_records(void)
475499 char buf [262144 ];
476500 struct mk_event_loop * evl ;
477501 struct cio_options opts = {0 };
502+ char * root_path ;
503+
504+ root_path = flb_test_tmpdir_cat ("/input-chunk-fs_chunks-size_real" );
505+ TEST_CHECK (root_path != NULL );
506+ if (!root_path ) {
507+ return ;
508+ }
478509
479510 flb_init_env ();
480511 cfg = flb_config_init ();
@@ -490,7 +521,7 @@ void flb_test_input_chunk_correct_total_records(void)
490521
491522 cio_options_init (& opts );
492523
493- opts .root_path = "/tmp/input-chunk-fs_chunks-size_real" ;
524+ opts .root_path = root_path ;
494525 opts .log_cb = log_cb ;
495526 opts .log_level = CIO_LOG_DEBUG ;
496527 opts .flags = CIO_OPEN ;
@@ -541,6 +572,7 @@ void flb_test_input_chunk_correct_total_records(void)
541572 flb_input_exit_all (cfg );
542573 flb_output_exit (cfg );
543574 flb_config_exit (cfg );
575+ flb_free (root_path );
544576}
545577
546578
0 commit comments