> Some, maybe the majority, of the leaks are not that critical. As a major
> example, the security unittests have a whole bunch of reported leak
> failures as a result of invoking the googletest framework macro
> ASSERT_TRUE. 

This has come up more than once on stack exchange: how do I clean up if
a gtest assert fails. The answer is pretty much - you don't; if you
needed to, you chose the wrong form of assertion in your code. Here's
googletest itself on the subject:

===
Assertions

Google Test assertions are macros that resemble function calls. You test
a class or function by making assertions about its behavior. When an
assertion fails, Google Test prints the assertion's source file and line
number location, along with a failure message. You may also supply a
custom failure message which will be appended to Google Test's message.

The assertions come in pairs that test the same thing but have different
effects on the current function. ASSERT_* versions generate fatal
failures when they fail, and abort the current function. EXPECT_*
versions generate nonfatal failures, which don't abort the current
function. Usually EXPECT_* are preferred, as they allow more than one
failures to be reported in a test. However, you should use ASSERT_* if
it doesn't make sense to continue when the assertion in question fails.

Since a failed ASSERT_* returns from the current function immediately,
possibly skipping clean-up code that comes after it, it may cause a
space leak. Depending on the nature of the leak, it may or may not be
worth fixing - so keep this in mind if you get a heap checker error in
addition to assertion errors.
===

So assuming the code has chosen correctly when it uses ASSERT, there's
not much to do.  I do not know how to teach valgrind not complain; since
they're macros, and valgrind operates at runtime level where is has no
idea of macros that vanished at preprocessing.



_______________________________________________
iotivity-dev mailing list
iotivity-dev@lists.iotivity.org
https://lists.iotivity.org/mailman/listinfo/iotivity-dev

Reply via email to