[systemd-devel] [PATCH 0/3] Using assert_se() on actions with side effects on test cases
Lennart Poettering
lennart at poettering.net
Tue Aug 26 11:32:43 PDT 2014
On Mon, 25.08.14 22:05, Filipe Brandenburger (filbranden at google.com) wrote:
Applied all three! Thanks!
And yes, I agree, all tests should use assert_se(), never
assert(). Quite a few tests snuck in though that used assert()
instead. WOuld be happy to take a patch correcting this!
> I bumped into these when building systemd with CPPFLAGS='-DNDEBUG' (which is
> the default for one of my build environments) which ends up optimizing out the
> assert() statements. It turns out that they were being used in some places in
> test cases where there was a side effect, so optimizing them out would cause
> the tests to crash.
>
> More to the point, maybe it would make sense to have *all* the assertions in
> tests be assert_se. Maybe a global search/replace?
>
> Not sure if this issue is not present elsewhere in systemd either... Not sure
> if it's really worth supporting -DNDEBUG. Considering systemd is already
> redefining assert(), maybe make it unconditional?
>
> Cheers,
> Filipe
>
>
> Filipe Brandenburger (3):
> test-compress: make sure asserts with side effects use assert_se()
> test-path-util: use assert_se in all assertions
> test-util: use assert_se() for call to safe_mkdir with side effect
>
> src/journal/test-compress.c | 4 ++--
> src/test/test-path-util.c | 30 +++++++++++++++---------------
> src/test/test-util.c | 2 +-
> 3 files changed, 18 insertions(+), 18 deletions(-)
>
Lennart
--
Lennart Poettering, Red Hat
More information about the systemd-devel
mailing list