tests/unit/test_exit_if_null.c: Test through XMALLOC() instead of xaprintf()#1384
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.
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 <[email protected]> Reviewed-by: Iker Pedrosa <[email protected]> Signed-off-by: Alejandro Colomar <[email protected]>
…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 <[email protected]> Tested-by: Silvan Mosberger <[email protected]> Reviewed-by: Iker Pedrosa <[email protected]> Signed-off-by: Alejandro Colomar <[email protected]>
|
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