mirror of
https://github.com/freebsd/freebsd-src.git
synced 2026-10-28 11:25:21 +01:00
[tests] lib/libc/gen:assert_test: skip tests when NDEBUG set
In the event that NDEBUG is specified in CFLAGS--which is most likely triggered via `MK_ASSERT_DEBUG` == "no" -- all assert(3) statements are optimized out by design. This breaks the assert(3) tests as they specifically rely on assert(3) actually raising a `SIGABRT` instead of quietly succeeding. Skip both tests if `NDEBUG` is set. There's no sense running the `assert(true)` test if the result could instead be a false positive. MFC after: 2 weeks
This commit is contained in:
1 file changed
+20
@@ -43,6 +43,18 @@ __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)
|
||||
{
|
||||
@@ -74,6 +86,10 @@ ATF_TC_BODY(assert_false, tc)
|
||||
pid_t pid;
|
||||
int sta;
|
||||
|
||||
#ifdef __FreeBSD__
|
||||
skip_if_ndebug_set();
|
||||
#endif
|
||||
|
||||
pid = fork();
|
||||
ATF_REQUIRE(pid >= 0);
|
||||
|
||||
@@ -112,6 +128,10 @@ ATF_TC_BODY(assert_true, tc)
|
||||
pid_t pid;
|
||||
int sta;
|
||||
|
||||
#ifdef __FreeBSD__
|
||||
skip_if_ndebug_set();
|
||||
#endif
|
||||
|
||||
pid = fork();
|
||||
ATF_REQUIRE(pid >= 0);
|
||||
|
||||
|
||||
Reference in new issue
Block a user