-
Notifications
You must be signed in to change notification settings - Fork 254
tests/unit/test_exit_if_null.c: Test through XMALLOC() instead of xaprintf() #1384
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
|
The code changes look good, but the PR lacks sufficient context and explanation. Do you mind adding a proper title and description to the PR? The information that is in the commits themselves should be sufficient. I don't want to come back in the future and ask myself why I approved this PR and try to understand what was happening. |
Done. Thanks! |
ikerexxe
left a comment
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 feel more comfortable with merging the bare minimum. Thank you!
…ull() This test is actually for exit_if_null(), not xaprintf(). Rename the test file and functions, and make strings more generic. Tested-by: Silvan Mosberger <github@infinisil.com> Reviewed-by: Iker Pedrosa <ipedrosa@redhat.com> Signed-off-by: Alejandro Colomar <alx@kernel.org>
…rintf() Both are indirect tests for exit_if_null(), but through XMALLOC() we can test it more robustly, as we don't need to wrap vasprintf(3) to make it fail. It's trivial to make MALLOC(3) fail: pass a huge size. The tests with xaprintf() were failing on Nix. I suspect the compiler was inlining aggressively, and as a result, the interposition of vasprintf(3) in cmocka wasn't actually working. The approach with XMALLOC() seems to work on Nix, as we don't need to interpose malloc(3). We still need to interpose exit(3), but for some reason that works fine. Closes: <shadow-maint#1382> Reported-by: Silvan Mosberger <github@infinisil.com> Tested-by: Silvan Mosberger <github@infinisil.com> Reviewed-by: Iker Pedrosa <ipedrosa@redhat.com> Signed-off-by: Alejandro Colomar <alx@kernel.org>
|
Thanks! I'll merge. |
This is a subset of #1383.
@ikerexxe This is the minimum fix.
Closes: #1382
Reported-by: @infinisil
Tested-by: @infinisil
Revisions:
v2
v2b