testing, system: do not build tests that call fork() where it is absent.

Two places call fork() from code that is compiled unconditionally, which is
fine only for as long as every architecture provides it.  NuttX is splitting
fork() into three primitives -- see apache/nuttx#19562 -- after which
ARCH_HAVE_FORK announces POSIX fork() specifically, and is off until an
architecture implements it.  Both then fail to link.  Each is dropped only
where ARCH_HAVE_FORK is unset, so builds that have fork() are unaffected.

system/libuv: test-fork.c and test-pipe-close-stdout-read-stdin.c are
filtered out of the test-*.c glob.  Nothing is lost even where they are
dropped: every test they define is already excluded from the task list on
NuttX by 0001-libuv-port-for-nuttx.patch, which extends the _WIN32 guards
around them to __NuttX__ -- all nine fork_* entries and
pipe_close_stdout_read_stdin.  They are compiled today but never run.

testing/ltp: the open_posix_testsuite is filtered through LTP's existing
BLACKWORDS mechanism, which already drops tests for absent features and is
already conditioned on configuration symbols.  The pattern spares vfork()
and task_fork().  Where fork() is absent this drops 278 of 1943 test files;
those tests exercise fork() and cannot link without it, and they return per
architecture as fork() lands.

Against today's master this is a no-op: ARCH_HAVE_FORK is set everywhere, so
neither filter drops anything.  It is part of what lets the NuttX side build
against apps master.

Assisted-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
Signed-off-by: Marco Casaroli <marco.casaroli@gmail.com>
This commit is contained in:
Marco Casaroli 2026-08-02 19:05:27 +02:00 committed by Alan C. Assis
parent e59fee53af
commit 795ea8d534
4 changed files with 33 additions and 1 deletions

View file

@ -171,6 +171,13 @@ if(CONFIG_LIBUV)
${LIBUV_TEST_DIR}/run-tests.c ${LIBUV_TEST_DIR}/runner.c
${LIBUV_TEST_DIR}/runner-unix.c ${LIBUV_TEST_DIR}/echo-server.c)
file(GLOB TEST_CSRCS ${LIBUV_TEST_DIR}/test-*.c)
# See system/libuv/Makefile.
if(NOT CONFIG_ARCH_HAVE_FORK)
list(REMOVE_ITEM TEST_CSRCS ${LIBUV_TEST_DIR}/test-fork.c
${LIBUV_TEST_DIR}/test-pipe-close-stdout-read-stdin.c)
endif()
list(APPEND LIBUV_UTILS_TEST_SRCS ${TEST_CSRCS})
nuttx_add_application(
NAME

View file

@ -144,7 +144,19 @@ CSRCS += runner.c
CSRCS += runner-unix.c
CSRCS += echo-server.c
CSRCS += $(wildcard libuv/test/test-*.c)
LIBUV_TEST_CSRCS = $(wildcard libuv/test/test-*.c)
# test-fork.c and test-pipe-close-stdout-read-stdin.c call fork(), so they
# cannot be built where NuttX does not provide it. Nothing is lost either
# way: every test they define is already excluded from the task list on
# NuttX by 0001-libuv-port-for-nuttx.patch.
ifeq ($(CONFIG_ARCH_HAVE_FORK),)
LIBUV_TEST_CSRCS := $(filter-out libuv/test/test-fork.c,$(LIBUV_TEST_CSRCS))
LIBUV_TEST_CSRCS := $(filter-out libuv/test/test-pipe-close-stdout-read-stdin.c,$(LIBUV_TEST_CSRCS))
endif
CSRCS += $(LIBUV_TEST_CSRCS)
endif
ifneq ($(CONFIG_LIBUV_UTILS_BENCHMARK),)

View file

@ -86,6 +86,12 @@ if(CONFIG_TESTING_LTP)
list(APPEND BLACKWORDS "pthread_spin_init" "pthread_spin_destroy"
"pthread_spin_trylock")
endif()
# See testing/ltp/Makefile.
if(NOT CONFIG_ARCH_HAVE_FORK)
list(APPEND BLACKWORDS "[^v_]fork(")
endif()
list(
APPEND
BLACKWORDS

View file

@ -44,6 +44,13 @@ BLACKWORDS += "pthread_spin_destroy"
BLACKWORDS += "pthread_spin_trylock"
endif
# Where NuttX does not declare fork(), a test that calls it cannot be built.
# The pattern spares vfork() and task_fork(), which remain available.
ifeq ($(CONFIG_ARCH_HAVE_FORK),)
BLACKWORDS += "[^v_]fork("
endif
BLACKWORDS += "CHILD_MAX"
BLACKWORDS += "setpgid("
BLACKWORDS += "PTHREAD_SCOPE_PROCESS"