Skip to content

Commit

Permalink
in_tail: tests: Add SIMD enabled case of test cases
Browse files Browse the repository at this point in the history
Signed-off-by: Hiroshi Hatake <[email protected]>
  • Loading branch information
cosmo0920 committed Dec 13, 2024
1 parent e809963 commit cd099e0
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 4 deletions.
1 change: 1 addition & 0 deletions tests/runtime/data/tail/out/unicode_be_c_simd.out
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"log":"在 Fluent Bit 中处理汉字,感觉像是在做梦😀。"}
1 change: 1 addition & 0 deletions tests/runtime/data/tail/out/unicode_be_j_simd.out
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"log":"にほんごテストログふぁいる。文字エンコーディングをUnicodeにできる!?☕😀⚪⚫🔴🔵🟠🟡🟢🟣🟤🇺🇸🇯🇵"}
1 change: 1 addition & 0 deletions tests/runtime/data/tail/out/unicode_c_simd.out
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"log"=>"用汉字在 Fluent Bit 中处理日志,就像是一个梦一样😀"}
1 change: 1 addition & 0 deletions tests/runtime/data/tail/out/unicode_j_simd.out
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"log":"にほんごテストログふぁいる。文字エンコーディングをUnicodeにできる!?☕😀⚪⚫🔴🔵🟠🟡🟢🟣🟤🇺🇸🇯🇵"}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"log"=>"🏴󠁧󠁢󠁥󠁮󠁧󠁿🏴󠁧󠁢󠁳󠁣󠁴󠁿🏴󠁧󠁢󠁷󠁬󠁳󠁿"}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"log"=>"🏴󠁧󠁢󠁥󠁮󠁧󠁿🏴󠁧󠁢󠁳󠁣󠁴󠁿🏴󠁧󠁢󠁷󠁬󠁳󠁿"}
18 changes: 14 additions & 4 deletions tests/runtime/in_tail.c
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ static int file_to_buf(const char *path, char **out_buf, size_t *out_size)
}

/* Given a target, lookup the .out file and return it content in a tail_file_lines structure */
static struct tail_file_lines *get_out_file_content(const char *target)
static struct tail_file_lines *get_out_file_content(const char *target, const char *suffix)
{
int ret;
char file[PATH_MAX];
Expand All @@ -370,7 +370,12 @@ static struct tail_file_lines *get_out_file_content(const char *target)
struct tail_file_lines *file_lines = flb_malloc(sizeof (struct tail_file_lines));
file_lines->lines_c = 0;

snprintf(file, sizeof(file) - 1, DPATH "/out/%s.out", target);
if (suffix != NULL) {
snprintf(file, sizeof(file) - 1, DPATH "/out/%s_%s.out", target, suffix);
}
else {
snprintf(file, sizeof(file) - 1, DPATH "/out/%s.out", target);
}

ret = file_to_buf(file, &out_buf, &out_size);
TEST_CHECK_(ret == 0, "getting output file content: %s", file);
Expand Down Expand Up @@ -410,7 +415,7 @@ static int cb_check_result(void *record, size_t size, void *data)

char *check;

out = get_out_file_content(result->target);
out = get_out_file_content(result->target, NULL);
if (!out->lines_c) {
goto exit;
}
Expand Down Expand Up @@ -450,10 +455,15 @@ static int cb_check_result_unicode(void *record, size_t size, void *data)

char *check;

out = get_out_file_content(result->target);
#ifdef FLB_HAVE_SIMD
out = get_out_file_content(result->target, "simd");
#else
out = get_out_file_content(result->target, NULL);
#endif
if (!out->lines_c) {
goto exit;
}
printf("record = %s\n", record);

valid = flb_unicode_validate(record, size);
if (valid == FLB_FALSE) {
Expand Down

0 comments on commit cd099e0

Please sign in to comment.