-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
tests: internal: log_event_encoder: Add test code #7736
Conversation
Signed-off-by: Takahiro Yamashita <[email protected]>
Signed-off-by: Takahiro Yamashita <[email protected]>
654020e
to
205f2e7
Compare
Signed-off-by: Takahiro Yamashita <[email protected]>
205f2e7
to
6c71b38
Compare
Windows CI on x86_64 failed... |
Signed-off-by: Takahiro Yamashita <[email protected]>
I tested following minimum test code. #include <stdio.h>
#include <stdarg.h>
#include <string.h>
void Test(int loop_cnt, ...)
{
va_list arg;
int type1;
int type2;
char* str;
size_t len1;
size_t len2;
int i;
va_start(arg, loop_cnt);
for (i = 0; i < loop_cnt; i++) {
printf("i=%d\n", i);
type1 = va_arg(arg, int);
if (type1 != 1) {
printf("%d:type is not 1\n", i);
}
len1 = va_arg(arg, size_t);
if (len1 > 20) {
printf("%d: len error. len=%zu\n", i, len1);
}
type2 = va_arg(arg, int);
if (type2 != 2) {
printf("%d:type is not 2\n", i);
}
str = va_arg(arg, char*);
len2 = va_arg(arg, size_t);
if (len2 != strlen(str)) {
printf("%d: len error2. len=%zu\n", i, len2);
}
if (len1 != len2) {
printf("%d: len error3. len1=%zu len2=%zu\n", i, len1, len2);
}
}
va_end(arg);
}
int main(void) {
int cnt = 2;
Test(cnt,
(int)1, (size_t)strlen("key1"), (int)2, (char*)"key1", (size_t)strlen("key1"),
(int)1, (size_t)strlen("value2"), (int)2, (char*)"value2", (size_t)strlen("value2"));
return 0;
} |
I checked assembly code and it passed |
Windows x86_64 passes dword size_t and it causes encoder error. Since size_t should be unsigned __int64. We define dword flb_log_event_size_t to prevent invalid casting as a workaround. Signed-off-by: Takahiro Yamashita <[email protected]>
ea267be
to
2485d34
Compare
@edsiper @leonardo-albertovich Wow CI on Windows x64 passed! I defined I also tried to define |
ping |
Hi @nokute78, I have this on my queue, I'll independently verify the claims in your PR using your test case in master because I'm not quite convinced about it. I'll get back to you as soon as I'm able to. |
@leonardo-albertovich Thank you. The point is following code will cause runtime error using MSVC + The code is to imitate a following macro ret = flb_log_event_encoder_append_body_values(
&encoder,
FLB_LOG_EVENT_CSTRING_VALUE("key1"),
FLB_LOG_EVENT_CSTRING_VALUE("value2"), MSVC outputs an assembly |
I have opened PR #7971 to fix this issue, once it's merged you can rebase and revert the rest of the changes so this PR only adds the test case. I have verified the PR with your test case and it works as expected. The issue is not that msvc defines |
You can revert the rest of the modifications and rebase from master now leaving only the new test case. |
I created a new PR #7992 |
This is a refactor PR for #7584
This patch is to add test code for log_event_encoder.
Enter
[N/A]
in the box, if an item is not applicable to your change.Testing
Before we can approve your change; please submit the following in a comment:
If this is a change to packaging of containers or native binaries then please confirm it works for all targets.
ok-package-test
label to test for all targets (requires maintainer to do).Documentation
Backporting
Fluent Bit is licensed under Apache 2.0, by submitting this pull request I understand that this code will be released under the terms of that license.