git: 9d5a33d9c294 - main - [tests] lib/libc/gen:assert_test: undefine `NDEBUG`
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Fri, 02 Oct 2026 20:43:14 UTC
The branch main has been updated by ngie:
URL: https://cgit.FreeBSD.org/src/commit/?id=9d5a33d9c294b01cead6ff65b0773b5b5ab85ccd
commit 9d5a33d9c294b01cead6ff65b0773b5b5ab85ccd
Author: Enji Cooper <ngie@FreeBSD.org>
AuthorDate: 2026-10-02 19:27:51 +0000
Commit: Enji Cooper <ngie@FreeBSD.org>
CommitDate: 2026-10-02 20:42:53 +0000
[tests] lib/libc/gen:assert_test: undefine `NDEBUG`
In the event `NDEBUG` was defined, `assert` would become a no-op,
breaking some of the expectations in `assert_test` around `assert(..)`
failing generating a coredump.
This is a better approach than the previous one committed in 6f3445006a
as it continues to test the `assert(..)` function instead of just
skipping it if `NDEBUG` was defined.
Suggested by: kevans
MFC after: 4 days
MFC with: 6f3445006a
Fixes: 6f3445006a
Differential Revision: https://reviews.freebsd.org/D60253
---
contrib/netbsd-tests/lib/libc/gen/t_assert.c | 26 ++++++--------------------
1 file changed, 6 insertions(+), 20 deletions(-)
diff --git a/contrib/netbsd-tests/lib/libc/gen/t_assert.c b/contrib/netbsd-tests/lib/libc/gen/t_assert.c
index b4023223b446..cec98c3beed0 100644
--- a/contrib/netbsd-tests/lib/libc/gen/t_assert.c
+++ b/contrib/netbsd-tests/lib/libc/gen/t_assert.c
@@ -28,6 +28,12 @@
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
+
+#if defined(__FreeBSD__)
+/* TODO: upstream this. */
+#undef NDEBUG
+#endif
+
#include <sys/cdefs.h>
__RCSID("$NetBSD: t_assert.c,v 1.3 2017/01/10 15:17:57 christos Exp $");
@@ -43,18 +49,6 @@ __RCSID("$NetBSD: t_assert.c,v 1.3 2017/01/10 15:17:57 christos Exp $");
#include <string.h>
#include <unistd.h>
-#ifdef __FreeBSD__
-/* TODO: upstream this. */
-static void
-skip_if_ndebug_set(void)
-{
-
-#ifdef NDEBUG
- atf_tc_skip("Testcase requires code to be compiled without -DNDEBUG.");
-#endif
-}
-#endif
-
static void
disable_corefile(void)
{
@@ -86,10 +80,6 @@ ATF_TC_BODY(assert_false, tc)
pid_t pid;
int sta;
-#ifdef __FreeBSD__
- skip_if_ndebug_set();
-#endif
-
pid = fork();
ATF_REQUIRE(pid >= 0);
@@ -128,10 +118,6 @@ ATF_TC_BODY(assert_true, tc)
pid_t pid;
int sta;
-#ifdef __FreeBSD__
- skip_if_ndebug_set();
-#endif
-
pid = fork();
ATF_REQUIRE(pid >= 0);