From a library POV asserts are not wanted, since it would lead to crashes. From a test POV, the crash (or crash-like) behaviour is exactly what we want. In addition meson (since v0.50 or thereabouts) sets -DNDEBUG for --buildtype=release, thus the asserts get removed.
Seemingly we have two conflicting needs... Ideally we'll nuke all the asserts and/or replace them with something more suitable. As an alternative we could build the assert containing code twice - normal + one for our code/test coverage (always undefine NDEBUG)
Rough list of ideas/tasks:
list all asserts and their use-case - test, oh-shit-we-might-break-it-in-the-future, other
remove any genuinely unwanted asserts
check/augment the tests so the oh-shit-we-might-break-it-in-the-future cases are covered
add wrapper for each use-case and/or build assert containing code twice, other
As inspired by https://github.com/kmod-project/kmod/pull/239#pullrequestreview-2440374673 and related reply, we currently have a handful of asserts across the code-base - libkmod, shared, testsuite, tools.
From a library POV asserts are not wanted, since it would lead to crashes. From a test POV, the crash (or crash-like) behaviour is exactly what we want. In addition meson (since v0.50 or thereabouts) sets
-DNDEBUG
for--buildtype=release
, thus the asserts get removed.Seemingly we have two conflicting needs... Ideally we'll nuke all the asserts and/or replace them with something more suitable. As an alternative we could build the assert containing code twice - normal + one for our code/test coverage (always undefine
NDEBUG
)Rough list of ideas/tasks:
oh-shit-we-might-break-it-in-the-future
cases are covered