[systemd-devel] [PATCH 0/3] Using assert_se() on actions with side effects on test cases

Filipe Brandenburger filbranden at google.com
Mon Aug 25 22:05:01 PDT 2014


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(-)

-- 
1.9.3



More information about the systemd-devel mailing list