-
Couldn't load subscription status.
- Fork 5
Fixing unit tests for mem-cpy, -move and -set functions #112
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
Conversation
* mod: Disable memcpy interposition by default Signed-off-by: Diogo Behrens <[email protected]> * cicd: Trigger pipeline on pull requests Signed-off-by: Diogo Behrens <[email protected]> * cicd: Enable memcpy interposition where safe Signed-off-by: Diogo Behrens <[email protected]> --------- Signed-off-by: Diogo Behrens <[email protected]>
Signed-off-by: Diogo Behrens <[email protected]>
Signed-off-by: gigna <[email protected]>
Signed-off-by: gigna <[email protected]>
…ng. enable function did not replace the actual call to functions. For this reason I used #define mem_func fake_mem_func to tell the preprocessor to replace every call to mem func with calls to the fake functions.
|
This is not passing in alpine |
…the intended return values of the mocks.
Signed-off-by: gigna <[email protected]>
Signed-off-by: georgeta-igna <[email protected]>
test/interpose/memcpy_test.c
Outdated
| struct memcpy_event *ev = EVENT_PAYLOAD(ev); | ||
| log_printf("ev->dest %p\n", &ev->dest); | ||
| log_printf("&(&E_memcpy)->dest %p\n", &(&E_memcpy)->dest); | ||
| log_printf("memcmp(&ev->dest, &(&E_memcpy)->dest, sizeof((&E_memcpy)->dest)) == 0 %d\n", memcmp(&ev->dest, &(&E_memcpy)->dest, sizeof(__typeof((&E_memcpy)->dest))) == 0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
redundant typeof() ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we really commit these log messages?
If yes, I recommend defining a macro to avoid writing the same text twice
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no, I am not planning to merge with these. I want to understand better why for the arm with clang the next ensure fails: https://github.com/open-s4c/dice/actions/runs/18745327427/job/53480906689
| ASSERT_FIELD_EQ(&E_memset, ptr); | ||
| ASSERT_FIELD_EQ(&E_memset, value); | ||
| ASSERT_FIELD_EQ(&E_memset, num); | ||
| ASSERT_FIELD_EQ(&E_memset, ret); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
whitespace?
| E_memset.ptr = malloc(5); | ||
| E_memset.value= 3; | ||
| E_memset.num = 2; | ||
| E_memset.ret = E_memset.ptr; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think they are always equal, so we should probably remove this .ret field and just compare with E_memset.ptr
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
E_memset.ret is null without this and it is checked somewhere in the main test: ensure(ret == E_memset.ptr);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean there's no point to have the field at all, it can be removed from the struct. Then you can still ensure(ret == E_memset.ptr);
test/interpose/memcpy_test.c
Outdated
| enable(fake_memset); | ||
| E_memset.ptr = malloc(5); | ||
| E_memset.value= 3; | ||
| E_memset.num = 2; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| log_printf("&(&E_memcpy)->dest %p\n", &(&E_memcpy)->dest); | ||
| log_printf("memcmp(&ev->dest, &(&E_memcpy)->dest, sizeof((&E_memcpy)->dest)) == 0 %d\n", memcmp(&ev->dest, &(&E_memcpy)->dest, sizeof(__typeof((&E_memcpy)->dest))) == 0); | ||
| ASSERT_FIELD_EQ(&E_memcpy, dest); | ||
| ASSERT_FIELD_EQ(&E_memcpy, src); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we add some check that the interceptor really got called? Or is that already checked elsewhere?
…eturn value of these functions as for the original memory handling functions
… from interpose/REAL
Signed-off-by: georgeta-igna <[email protected]>
|
Replaced by #122 |

No description provided.