Closed
Bug 1350508
Opened 8 years ago
Closed 8 years ago
assert() doesn't work in cubeb's gtest
Categories
(Core :: Audio/Video: cubeb, enhancement)
Core
Audio/Video: cubeb
Tracking
()
RESOLVED
FIXED
People
(Reporter: chunmin, Assigned: chunmin)
Details
Attachments
(1 file)
The following code will pass in the cubeb's gtest
TEST(cubeb, test_assert)
{
assert(false);
}
If it's not on purpose, then we should add:
#ifdef NDEBUG
#undef NDEBUG
#endif
before loading the assert.h to make it works.
Assignee | ||
Comment 1•8 years ago
|
||
Is it designed on purpose? or I need to add something to turn on debug mode?
The following code use assert but it does not work:
- test_overload_callback.cpp
- test_resampler.cpp
- test_sanity.cpp
Assignee: nobody → cchang
Flags: needinfo?(kinetik)
Comment 2•8 years ago
|
||
We should discourage the use of assert() in the GTests and use the GTest-provided assertions.
It looks like test_overload_callback is the only one that needs to be fixed. The asserts in test_sanity and test_resampler are deliberate duplicates of the GTest asserts directly above/along side them purely to silence warnings from the clang static analyzer.
Flags: needinfo?(kinetik)
Assignee | ||
Comment 3•8 years ago
|
||
I think there is a bit different between assert and gtest's ASSERT_TRUE. The former is fatal and process will be halted, while the later is not. The assert(output_buffer) in test_resampler.cpp[0] will stop the test when output_buffer is nullptr and prevent from the segmentation fault.
I see the assert(output_buffer) is added in pull 223[1].
Paul, is it why you add assert there?
[0] http://searchfox.org/mozilla-central/rev/7419b368156a6efa24777b21b0e5706be89a9c2f/media/libcubeb/gtest/test_resampler.cpp#656
[1] https://github.com/kinetiknz/cubeb/pull/223/commits/dbd3183abaf59316ccd6e28f5dc1ce802e67cc6a
Flags: needinfo?(padenot)
Comment 4•8 years ago
|
||
Yeah, what kinetik said, this is needed so that scan-build knows that those can't be nullptr.
Flags: needinfo?(padenot)
Assignee | ||
Comment 5•8 years ago
|
||
Assignee | ||
Comment 6•8 years ago
|
||
Status: NEW → RESOLVED
Closed: 8 years ago
Resolution: --- → FIXED
You need to log in
before you can comment on or make changes to this bug.
Description
•