From cd099e00820f12d56e5996e875eb644f460e5293 Mon Sep 17 00:00:00 2001 From: Hiroshi Hatake Date: Fri, 13 Dec 2024 18:46:02 +0900 Subject: [PATCH] in_tail: tests: Add SIMD enabled case of test cases Signed-off-by: Hiroshi Hatake --- .../data/tail/out/unicode_be_c_simd.out | 1 + .../data/tail/out/unicode_be_j_simd.out | 1 + tests/runtime/data/tail/out/unicode_c_simd.out | 1 + tests/runtime/data/tail/out/unicode_j_simd.out | 1 + .../out/unicode_subdivision_flags_be_simd.out | 1 + .../out/unicode_subdivision_flags_simd.out | 1 + tests/runtime/in_tail.c | 18 ++++++++++++++---- 7 files changed, 20 insertions(+), 4 deletions(-) create mode 100644 tests/runtime/data/tail/out/unicode_be_c_simd.out create mode 100644 tests/runtime/data/tail/out/unicode_be_j_simd.out create mode 100644 tests/runtime/data/tail/out/unicode_c_simd.out create mode 100644 tests/runtime/data/tail/out/unicode_j_simd.out create mode 100644 tests/runtime/data/tail/out/unicode_subdivision_flags_be_simd.out create mode 100644 tests/runtime/data/tail/out/unicode_subdivision_flags_simd.out diff --git a/tests/runtime/data/tail/out/unicode_be_c_simd.out b/tests/runtime/data/tail/out/unicode_be_c_simd.out new file mode 100644 index 00000000000..80d85da0976 --- /dev/null +++ b/tests/runtime/data/tail/out/unicode_be_c_simd.out @@ -0,0 +1 @@ +{"log":"在 Fluent Bit 中处理汉字,感觉像是在做梦😀。"} diff --git a/tests/runtime/data/tail/out/unicode_be_j_simd.out b/tests/runtime/data/tail/out/unicode_be_j_simd.out new file mode 100644 index 00000000000..02bcf9b4397 --- /dev/null +++ b/tests/runtime/data/tail/out/unicode_be_j_simd.out @@ -0,0 +1 @@ +{"log":"にほんごテストログふぁいる。文字エンコーディングをUnicodeにできる!?☕😀⚪⚫🔴🔵🟠🟡🟢🟣🟤🇺🇸🇯🇵"} diff --git a/tests/runtime/data/tail/out/unicode_c_simd.out b/tests/runtime/data/tail/out/unicode_c_simd.out new file mode 100644 index 00000000000..6cb70070ab6 --- /dev/null +++ b/tests/runtime/data/tail/out/unicode_c_simd.out @@ -0,0 +1 @@ +{"log"=>"用汉字在 Fluent Bit 中处理日志,就像是一个梦一样😀"} \ No newline at end of file diff --git a/tests/runtime/data/tail/out/unicode_j_simd.out b/tests/runtime/data/tail/out/unicode_j_simd.out new file mode 100644 index 00000000000..02bcf9b4397 --- /dev/null +++ b/tests/runtime/data/tail/out/unicode_j_simd.out @@ -0,0 +1 @@ +{"log":"にほんごテストログふぁいる。文字エンコーディングをUnicodeにできる!?☕😀⚪⚫🔴🔵🟠🟡🟢🟣🟤🇺🇸🇯🇵"} diff --git a/tests/runtime/data/tail/out/unicode_subdivision_flags_be_simd.out b/tests/runtime/data/tail/out/unicode_subdivision_flags_be_simd.out new file mode 100644 index 00000000000..30dfc2ab629 --- /dev/null +++ b/tests/runtime/data/tail/out/unicode_subdivision_flags_be_simd.out @@ -0,0 +1 @@ +{"log"=>"🏴󠁧󠁢󠁥󠁮󠁧󠁿🏴󠁧󠁢󠁳󠁣󠁴󠁿🏴󠁧󠁢󠁷󠁬󠁳󠁿"} \ No newline at end of file diff --git a/tests/runtime/data/tail/out/unicode_subdivision_flags_simd.out b/tests/runtime/data/tail/out/unicode_subdivision_flags_simd.out new file mode 100644 index 00000000000..30dfc2ab629 --- /dev/null +++ b/tests/runtime/data/tail/out/unicode_subdivision_flags_simd.out @@ -0,0 +1 @@ +{"log"=>"🏴󠁧󠁢󠁥󠁮󠁧󠁿🏴󠁧󠁢󠁳󠁣󠁴󠁿🏴󠁧󠁢󠁷󠁬󠁳󠁿"} \ No newline at end of file diff --git a/tests/runtime/in_tail.c b/tests/runtime/in_tail.c index 5476dee1ae4..64e9d2ba35c 100644 --- a/tests/runtime/in_tail.c +++ b/tests/runtime/in_tail.c @@ -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]; @@ -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); @@ -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; } @@ -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) {