Skip to content

Commit b41cff3

Browse files
cosmo0920edsiper
authored andcommitted
tests: internal: verify configuration parsing from an open stream
Signed-off-by: Hiroshi Hatake <hiroshi@chronosphere.io>
1 parent dee7ae0 commit b41cff3

2 files changed

Lines changed: 41 additions & 0 deletions

File tree

‎tests/internal/config_format_fluentbit.c‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,27 @@ static void test_snake_case_key()
363363
TEST_CHECK(check_snake_case("interval_Sec", "interval_sec") == FLB_TRUE);
364364
}
365365

366+
static void test_entry_stream(void)
367+
{
368+
struct flb_cf *cf;
369+
struct flb_cf *parsed;
370+
FILE *stream;
371+
372+
stream = fopen(FLB_000, "rb");
373+
TEST_ASSERT(stream != NULL);
374+
cf = flb_cf_create();
375+
TEST_ASSERT(cf != NULL);
376+
cf->entry_file = stream;
377+
parsed = flb_cf_create_from_file(cf, FLB_006);
378+
TEST_CHECK(parsed == cf);
379+
TEST_CHECK(mk_list_size(&cf->inputs) == 1);
380+
cf->entry_file = NULL;
381+
TEST_CHECK(fclose(stream) == 0);
382+
flb_cf_destroy(cf);
383+
}
384+
366385
TEST_LIST = {
386+
{"entry_stream", test_entry_stream},
367387
{ "basic" , test_basic},
368388
{ "missing_value_issue5880" , missing_value},
369389
{ "indent_level_error" , indent_level_error},

‎tests/internal/config_format_yaml.c‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1090,7 +1090,28 @@ static void test_include_hardlink_cycle()
10901090
}
10911091
#endif
10921092

1093+
static void test_entry_stream(void)
1094+
{
1095+
struct flb_cf *cf;
1096+
struct flb_cf *parsed;
1097+
FILE *stream;
1098+
1099+
stream = fopen(FLB_BASIC, "rb");
1100+
TEST_ASSERT(stream != NULL);
1101+
cf = flb_cf_create();
1102+
TEST_ASSERT(cf != NULL);
1103+
cf->entry_file = stream;
1104+
/* The named fixture fails on its own; the opened entry supplies the data. */
1105+
parsed = flb_cf_create_from_file(cf, FLB_007);
1106+
TEST_CHECK(parsed == cf);
1107+
TEST_CHECK(mk_list_size(&cf->inputs) > 0);
1108+
cf->entry_file = NULL;
1109+
TEST_CHECK(fclose(stream) == 0);
1110+
flb_cf_destroy(cf);
1111+
}
1112+
10931113
TEST_LIST = {
1114+
{"entry_stream", test_entry_stream},
10941115
#ifdef FLB_SYSTEM_WINDOWS
10951116
{ "include_hardlink_cycle", test_include_hardlink_cycle},
10961117
#endif

0 commit comments

Comments
 (0)