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 <[email protected]>
Reviewed by:	ngie
Differential Revision:	https://reviews.freebsd.org/D60358
This commit is contained in:
Xiaoqiang Zhao authored and Enji Cooper committed 2026-10-10 10:43:46 -07:00
1 parent e8431fae65
commit d45f069002
2 files changed
+21 -7

No files matched your search

+10 -4
View File
@@ -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
+11 -3
View File
@@ -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.