Skip to content

Commit

Permalink
tests: runtime: filter_rewrite_tag: add test case reported on #5846
Browse files Browse the repository at this point in the history
Signed-off-by: Takahiro Yamashita <[email protected]>
  • Loading branch information
nokute78 authored and edsiper committed Sep 27, 2022
1 parent 1452140 commit 1a4cc61
Showing 1 changed file with 48 additions and 0 deletions.
48 changes: 48 additions & 0 deletions tests/runtime/filter_rewrite_tag.c
Original file line number Diff line number Diff line change
Expand Up @@ -505,12 +505,60 @@ static void flb_test_issue_4518()
filter_test_destroy(ctx);
}

/* $TAG as a key of rule causes SIGSEGV */
static void flb_test_issue_5846()
{
struct flb_lib_out_cb cb_data;
struct filter_test *ctx;
int ret;
int not_used = 0;
int bytes;
char *p = "[0, {\"key\":\"rewrite\"}]";

/* Prepare output callback with expected result */
cb_data.cb = cb_count_msgpack;
cb_data.data = &not_used;

/* Create test context */
ctx = filter_test_create((void *) &cb_data);
if (!ctx) {
exit(EXIT_FAILURE);
}
clear_output_num();
/* Configure filter */
ret = flb_filter_set(ctx->flb, ctx->f_ffd,
"Rule", "$TAG ^(rewrite)$ updated false",
NULL);
TEST_CHECK(ret == 0);

/* Configure output */
ret = flb_output_set(ctx->flb, ctx->o_ffd,
"Match", "updated",
NULL);
TEST_CHECK(ret == 0);

/* Start the engine */
ret = flb_start(ctx->flb);
TEST_CHECK(ret == 0);

/* ingest record */
bytes = flb_lib_push(ctx->flb, ctx->i_ffd, p, strlen(p));
TEST_CHECK(bytes == strlen(p));

flb_time_msleep(1500); /* waiting flush */

/* It is OK, if there is no SIGSEGV. */

filter_test_destroy(ctx);
}

TEST_LIST = {
{"matched", flb_test_matched},
{"not_matched", flb_test_not_matched},
{"keep_true", flb_test_keep_true},
{"heavy_input_pause_emitter", flb_test_heavy_input_pause_emitter},
{"issue_4518", flb_test_issue_4518},
{"issue_4793", flb_test_issue_4793},
{"sigsegv_issue_5846", flb_test_issue_5846},
{NULL, NULL}
};

0 comments on commit 1a4cc61

Please sign in to comment.