Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 16 Feb 2026 17:58:18 +0000
From:      Konstantin Belousov <kib@FreeBSD.org>
Subject:   git: 793e891f4ad1 - main - pdrfork(2) tests: enable on x86
Message-ID:  <69935aba.3617e.62380cb7@gitrepo.freebsd.org>

index | next in thread | raw e-mail

The branch main has been updated by kib:

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

commit 793e891f4ad1ef450f562a241fb0bd3b21d72251
Author:     Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2026-02-15 15:23:03 +0000
Commit:     Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2026-02-16 17:57:53 +0000

    pdrfork(2) tests: enable on x86
    
    Use pfrfork_thread(3) instead of pdrfork(RFSPAWN) to make tests working
    on x86.
    
    Tested by:      pho
    Reviewed by:    markj
    Sponsored by:   The FreeBSD Foundation
    MFC after:      1 week
    Differential revision:  https://reviews.freebsd.org/D55306
---
 tests/sys/kern/pdrfork.c | 29 ++++++++++++++++++++---------
 1 file changed, 20 insertions(+), 9 deletions(-)

diff --git a/tests/sys/kern/pdrfork.c b/tests/sys/kern/pdrfork.c
index 8244a34b6577..30045e0a05a5 100644
--- a/tests/sys/kern/pdrfork.c
+++ b/tests/sys/kern/pdrfork.c
@@ -145,18 +145,31 @@ ATF_TC_BODY(rfprocdesc, tc)
 	basic_usage(RFPROC | RFPROCDESC);
 }
 
+static int
+rfspawn_fn(void *arg)
+{
+	_exit(0);
+	return (0);
+}
+
 /* basic usage with RFSPAWN */
-/*
- * Skip on i386 and x86_64 because RFSPAWN cannot be used from C code on those
- * architectures.  See lib/libc/gen/posix_spawn.c for details.
- */
-#if !(defined(__i386__)) && !(defined(__amd64__))
 ATF_TC_WITHOUT_HEAD(rfspawn);
 ATF_TC_BODY(rfspawn, tc)
 {
-	basic_usage(RFSPAWN);
-}
+	char *stack = NULL;
+	int pd = -1;
+	pid_t pid;
+
+#if defined(__i386__) || defined(__amd64__)
+#define STACK_SZ	(PAGE_SIZE * 10)
+	stack = mmap(NULL, STACK_SZ, PROT_READ | PROT_WRITE, MAP_ANON,
+	    -1, 0);
+	ATF_REQUIRE(stack != MAP_FAILED);
+	stack += STACK_SZ;
 #endif
+	pid = pdrfork_thread(&pd, 0, RFSPAWN, stack, rfspawn_fn, NULL);
+	basic_usage_tail(pd, pid);
+}
 
 ATF_TP_ADD_TCS(tp)
 {
@@ -164,9 +177,7 @@ ATF_TP_ADD_TCS(tp)
 	ATF_TP_ADD_TC(tp, efault);
 	ATF_TP_ADD_TC(tp, einval);
 	ATF_TP_ADD_TC(tp, rfprocdesc);
-#if !(defined(__i386__)) && !(defined(__amd64__))
 	ATF_TP_ADD_TC(tp, rfspawn);
-#endif
 
 	return (atf_no_error());
 }


home | help

Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?69935aba.3617e.62380cb7>