git: d45f069002f2 - main - tests/libc: use an allowlist for sbrk in NetBSD-derived tests

From: Enji Cooper <ngie_at_FreeBSD.org>
Date: Sat, 10 Oct 2026 17:43:58 UTC
The branch main has been updated by ngie:

URL: https://cgit.FreeBSD.org/src/commit/?id=d45f069002f211398fd7790509fbd25ec6d1c713

commit d45f069002f211398fd7790509fbd25ec6d1c713
Author:     Xiaoqiang Zhao <zhaoxiaoqiang007@gmail.com>
AuthorDate: 2026-10-10 17:39:44 +0000
Commit:     Enji Cooper <ngie@FreeBSD.org>
CommitDate: 2026-10-10 17:43:46 +0000

    tests/libc: use an allowlist for sbrk in NetBSD-derived tests
    
    sbrk is obsolete and libc only provides it on amd64, arm, i386 and
    powerpc.  Replace the growing exclusion lists in t_dir.c and t_mlock.c
    with a single positive HAVE_SBRK definition per file, so architectures
    without sbrk need not be enumerated as they are added.
    
    Signed-off-by: Xiaoqiang Zhao <zhaoxiaoqiang007@gmail.com>
    Reviewed by:    ngie
    Differential Revision:  https://reviews.freebsd.org/D60358
---
 contrib/netbsd-tests/lib/libc/gen/t_dir.c   | 14 ++++++++++----
 contrib/netbsd-tests/lib/libc/sys/t_mlock.c | 14 +++++++++++---
 2 files changed, 21 insertions(+), 7 deletions(-)

diff --git a/contrib/netbsd-tests/lib/libc/gen/t_dir.c b/contrib/netbsd-tests/lib/libc/gen/t_dir.c
index 53d1fce26e2d..49800bfb3f34 100644
--- a/contrib/netbsd-tests/lib/libc/gen/t_dir.c
+++ b/contrib/netbsd-tests/lib/libc/gen/t_dir.c
@@ -38,7 +38,14 @@
 #include <string.h>
 #include <unistd.h>
 
-
+/*
+ * sbrk is obsolete, and libc only provides it on a subset of
+ * architectures.
+ */
+#if defined(__amd64__) || defined(__arm__) || defined(__i386__) || \
+    defined(__powerpc__)
+#define	HAVE_SBRK
+#endif
 
 ATF_TC(seekdir_basic);
 ATF_TC_HEAD(seekdir_basic, tc)
@@ -134,8 +141,7 @@ ATF_TC_BODY(seekdir_basic, tc)
 	free(wasname);
 }
 
-/* There is no sbrk on AArch64 and RISC-V */
-#if !defined(__aarch64__) && !defined(__riscv)
+#ifdef HAVE_SBRK
 ATF_TC(telldir_leak);
 ATF_TC_HEAD(telldir_leak, tc)
 {
@@ -185,7 +191,7 @@ ATF_TP_ADD_TCS(tp)
 {
 
 	ATF_TP_ADD_TC(tp, seekdir_basic);
-#if !defined(__aarch64__) && !defined(__riscv)
+#ifdef HAVE_SBRK
 	ATF_TP_ADD_TC(tp, telldir_leak);
 #endif
 
diff --git a/contrib/netbsd-tests/lib/libc/sys/t_mlock.c b/contrib/netbsd-tests/lib/libc/sys/t_mlock.c
index d9ffbe366a04..b081c60bbecc 100644
--- a/contrib/netbsd-tests/lib/libc/sys/t_mlock.c
+++ b/contrib/netbsd-tests/lib/libc/sys/t_mlock.c
@@ -46,6 +46,15 @@ __RCSID("$NetBSD: t_mlock.c,v 1.6 2016/08/09 12:02:44 kre Exp $");
 #include <stdlib.h>
 #include <unistd.h>
 
+/*
+ * sbrk is obsolete, and libc only provides it on a subset of
+ * architectures.
+ */
+#if defined(__amd64__) || defined(__arm__) || defined(__i386__) || \
+    defined(__powerpc__)
+#define	HAVE_SBRK
+#endif
+
 #ifdef __FreeBSD__
 #include <limits.h>
 #define _KMEMUSER
@@ -103,7 +112,7 @@ ATF_TC_BODY(mlock_err, tc)
 	unsigned long vmin = 0;
 	size_t len = sizeof(vmin);
 #endif
-#if !defined(__aarch64__) && !defined(__riscv)
+#ifdef HAVE_SBRK
 	void *invalid_ptr;
 #endif
 	void *buf;
@@ -159,8 +168,7 @@ ATF_TC_BODY(mlock_err, tc)
 #endif
 	(void)free(buf);
 
-/* There is no sbrk on AArch64 and RISC-V */
-#if !defined(__aarch64__) && !defined(__riscv)
+#ifdef HAVE_SBRK
 	/*
 	 * Try to create a pointer to an unmapped page - first after current
 	 * brk will likely do.