From d3b7722b3dac6b63a22243c5f4796a80dbd29620 Mon Sep 17 00:00:00 2001 From: Marco Casaroli Date: Tue, 28 Jul 2026 09:17:55 +0200 Subject: [PATCH] testing/ostest: drop the pre-split fork() fallbacks The previous commit had task_fork_test() also accept CONFIG_ARCH_HAVE_FORK, because the nuttx symbols naming the three primitives did not exist yet. nuttx now has them, so each test gates on the one primitive it tests and nothing stands in for anything. The OSTEST_HAVE_* indirection goes with the fallbacks, as does the task_fork()->fork() shim in nand_sim_main.c. The whole-file #ifdef in task_fork.c goes too: the build files already decide whether the file is compiled, which is why fork.c and vfork.c do not carry one either. task_fork_test() keys on CONFIG_TASK_FORK rather than the capability symbol. ARCH_HAVE_TASK_FORK says the architecture can clone a task; TASK_FORK says this build asked for it, and task_fork() is declared only under the latter, so gating on the capability alone would fail to compile a TASK_FORK=n build. TESTING_NAND_SIM depends on the same symbol for the same reason. vfork_test() and fork_test() have no such split and key on ARCH_HAVE_VFORK and ARCH_HAVE_FORK directly. This must not be merged before the nuttx side. Signed-off-by: Marco Casaroli Assisted-by: Claude Opus 5 (1M context) --- interpreters/python/Makefile | 2 +- netutils/libwebsockets/lws_config_private.h | 2 +- testing/drivers/nand_sim/Kconfig | 3 +- testing/drivers/nand_sim/nand_sim_main.c | 7 +--- testing/fs/fdsantest/fdsantest_simple.c | 4 +-- testing/ostest/CMakeLists.txt | 6 +--- testing/ostest/Makefile | 11 +----- testing/ostest/ostest.h | 40 ++------------------- testing/ostest/ostest_main.c | 6 ++-- testing/ostest/task_fork.c | 4 --- 10 files changed, 14 insertions(+), 71 deletions(-) diff --git a/interpreters/python/Makefile b/interpreters/python/Makefile index 8f1a510e0..3f5f878ac 100644 --- a/interpreters/python/Makefile +++ b/interpreters/python/Makefile @@ -114,7 +114,7 @@ ifeq ($(CONFIG_ARCH_HAVE_FORK),y) else @echo "export ac_cv_func_fork=\"no\"" >> $@ endif -ifneq ($(CONFIG_ARCH_HAVE_VFORK)$(CONFIG_ARCH_HAVE_FORK),) +ifeq ($(CONFIG_ARCH_HAVE_VFORK),y) @echo "export ac_cv_func_vfork=\"yes\"" >> $@ else @echo "export ac_cv_func_vfork=\"no\"" >> $@ diff --git a/netutils/libwebsockets/lws_config_private.h b/netutils/libwebsockets/lws_config_private.h index cacf92f5f..057baf73b 100644 --- a/netutils/libwebsockets/lws_config_private.h +++ b/netutils/libwebsockets/lws_config_private.h @@ -119,7 +119,7 @@ #endif /* Define to 1 if `vfork' works. */ -#if defined(CONFIG_ARCH_HAVE_VFORK) || defined(CONFIG_ARCH_HAVE_FORK) +#ifdef CONFIG_ARCH_HAVE_VFORK #define LWS_HAVE_WORKING_VFORK #endif diff --git a/testing/drivers/nand_sim/Kconfig b/testing/drivers/nand_sim/Kconfig index 4baa4425e..008446a89 100644 --- a/testing/drivers/nand_sim/Kconfig +++ b/testing/drivers/nand_sim/Kconfig @@ -5,8 +5,7 @@ config TESTING_NAND_SIM boolean "NAND Flash Simulator" - depends on MTD_NAND_RAM && ENABLE_ALL_SIGNALS - depends on TASK_FORK || (ARCH_HAVE_FORK && !ARCH_HAVE_TASK_FORK) + depends on MTD_NAND_RAM && ENABLE_ALL_SIGNALS && TASK_FORK default n ---help--- Enable the NAND Flash Simulator device. diff --git a/testing/drivers/nand_sim/nand_sim_main.c b/testing/drivers/nand_sim/nand_sim_main.c index 90597faa4..c45df4af8 100644 --- a/testing/drivers/nand_sim/nand_sim_main.c +++ b/testing/drivers/nand_sim/nand_sim_main.c @@ -143,14 +143,9 @@ int main(int argc, FAR char *argv[]) pid_t pid; /* task_fork() rather than fork(): this wants a clone that outlives the - * caller and shares its memory. The fallback below covers a nuttx that - * does not have task_fork() yet. + * caller and shares its memory. */ -#ifndef CONFIG_TASK_FORK -# define task_fork() fork() -#endif - pid = task_fork(); if (pid > 0) diff --git a/testing/fs/fdsantest/fdsantest_simple.c b/testing/fs/fdsantest/fdsantest_simple.c index e5dc46817..114f0aeeb 100644 --- a/testing/fs/fdsantest/fdsantest_simple.c +++ b/testing/fs/fdsantest/fdsantest_simple.c @@ -96,7 +96,7 @@ static void test_case_overflow(void **state) assert_int_equal(open_count, close_count); } -#if defined(CONFIG_ARCH_HAVE_VFORK) || defined(CONFIG_ARCH_HAVE_FORK) +#ifdef CONFIG_ARCH_HAVE_VFORK static void test_case_vfork(void **state) { int fd = open("/dev/null", O_RDONLY); @@ -131,7 +131,7 @@ int main(int argc, FAR char *argv[]) cmocka_unit_test(test_case_unowned_tagged_close), cmocka_unit_test(test_case_owned_tagged_close), cmocka_unit_test(test_case_overflow), -#if defined(CONFIG_ARCH_HAVE_VFORK) || defined(CONFIG_ARCH_HAVE_FORK) +#ifdef CONFIG_ARCH_HAVE_VFORK cmocka_unit_test(test_case_vfork), #endif }; diff --git a/testing/ostest/CMakeLists.txt b/testing/ostest/CMakeLists.txt index 76c1d25d0..ba1fcb23a 100644 --- a/testing/ostest/CMakeLists.txt +++ b/testing/ostest/CMakeLists.txt @@ -143,19 +143,15 @@ if(CONFIG_TESTING_OSTEST) endif() endif() - # See testing/ostest/ostest.h for the one transitional exception. - if(CONFIG_TASK_FORK) list(APPEND SRCS task_fork.c) - elseif(CONFIG_ARCH_HAVE_FORK AND NOT CONFIG_ARCH_HAVE_TASK_FORK) - list(APPEND SRCS task_fork.c) endif() if(CONFIG_ARCH_HAVE_VFORK) list(APPEND SRCS vfork.c) endif() - if(CONFIG_ARCH_HAVE_FORK AND CONFIG_ARCH_HAVE_VFORK) + if(CONFIG_ARCH_HAVE_FORK) list(APPEND SRCS fork.c) endif() diff --git a/testing/ostest/Makefile b/testing/ostest/Makefile index ff89753f3..b35a3bbfb 100644 --- a/testing/ostest/Makefile +++ b/testing/ostest/Makefile @@ -144,17 +144,10 @@ CSRCS += sigev_thread.c endif endif -# Each test is built where the primitive it tests exists. See ostest.h for the -# one transitional exception. +# Each test is built where the primitive it tests exists. ifeq ($(CONFIG_TASK_FORK),y) CSRCS += task_fork.c -else ifeq ($(CONFIG_ARCH_HAVE_TASK_FORK),) -# A nuttx with no ARCH_HAVE_TASK_FORK at all is the pre-split one, where -# fork() is task_fork(). This branch comes out with the split. -ifeq ($(CONFIG_ARCH_HAVE_FORK),y) -CSRCS += task_fork.c -endif endif ifeq ($(CONFIG_ARCH_HAVE_VFORK),y) @@ -162,10 +155,8 @@ CSRCS += vfork.c endif ifeq ($(CONFIG_ARCH_HAVE_FORK),y) -ifeq ($(CONFIG_ARCH_HAVE_VFORK),y) CSRCS += fork.c endif -endif ifeq ($(CONFIG_ARCH_SETJMP_H),y) CSRCS += setjmp.c diff --git a/testing/ostest/ostest.h b/testing/ostest/ostest.h index 77bf5e9f3..c8f41832a 100644 --- a/testing/ostest/ostest.h +++ b/testing/ostest/ostest.h @@ -282,55 +282,21 @@ void priority_inheritance(void); void sched_lock_test(void); -/* The fork family **********************************************************/ - -/* Until nuttx has the three separate primitives, ARCH_HAVE_FORK stands in - * for task_fork(): today's fork() *is* task_fork(), so the test that has - * always covered that primitive keeps running under its own name. A nuttx - * without ARCH_HAVE_TASK_FORK is the pre-split one, and only there does the - * substitution apply -- once the split has landed, TASK_FORK says whether - * task_fork() was built, and nothing stands in for it. - * - * vfork_test() and fork_test() deliberately have no such mapping. They - * check semantics a pre-split nuttx does not describe -- the parent - * suspension and the private copy -- and ARCH_HAVE_VFORK is the evidence - * that the split has landed. - * - * This block comes out with the split. - */ - -#if defined(CONFIG_TASK_FORK) || \ - (defined(CONFIG_ARCH_HAVE_FORK) && !defined(CONFIG_ARCH_HAVE_TASK_FORK)) -# define OSTEST_HAVE_TASK_FORK 1 -#endif - -#ifdef CONFIG_ARCH_HAVE_VFORK -# define OSTEST_HAVE_VFORK 1 -#endif - -#if defined(CONFIG_ARCH_HAVE_FORK) && defined(CONFIG_ARCH_HAVE_VFORK) -# define OSTEST_HAVE_FORK 1 -#endif - -#if defined(OSTEST_HAVE_TASK_FORK) && !defined(CONFIG_TASK_FORK) -# define task_fork() fork() -#endif - /* task_fork.c **************************************************************/ -#ifdef OSTEST_HAVE_TASK_FORK +#ifdef CONFIG_TASK_FORK int task_fork_test(void); #endif /* vfork.c ******************************************************************/ -#ifdef OSTEST_HAVE_VFORK +#ifdef CONFIG_ARCH_HAVE_VFORK int vfork_test(void); #endif /* fork.c *******************************************************************/ -#ifdef OSTEST_HAVE_FORK +#ifdef CONFIG_ARCH_HAVE_FORK int fork_test(void); #endif diff --git a/testing/ostest/ostest_main.c b/testing/ostest/ostest_main.c index e717b291d..20aeba668 100644 --- a/testing/ostest/ostest_main.c +++ b/testing/ostest/ostest_main.c @@ -229,19 +229,19 @@ static int user_main(int argc, char *argv[]) * reporting a failure -- better to learn that in seconds. */ -#ifdef OSTEST_HAVE_TASK_FORK +#ifdef CONFIG_TASK_FORK printf("\nuser_main: task_fork() test\n"); task_fork_test(); check_test_memory_usage(); #endif -#ifdef OSTEST_HAVE_VFORK +#ifdef CONFIG_ARCH_HAVE_VFORK printf("\nuser_main: vfork() test\n"); vfork_test(); check_test_memory_usage(); #endif -#ifdef OSTEST_HAVE_FORK +#ifdef CONFIG_ARCH_HAVE_FORK printf("\nuser_main: fork() test\n"); fork_test(); check_test_memory_usage(); diff --git a/testing/ostest/task_fork.c b/testing/ostest/task_fork.c index 2bd00ee76..2a66e289c 100644 --- a/testing/ostest/task_fork.c +++ b/testing/ostest/task_fork.c @@ -36,8 +36,6 @@ #include "ostest.h" -#ifdef OSTEST_HAVE_TASK_FORK - /**************************************************************************** * Private Data ****************************************************************************/ @@ -94,5 +92,3 @@ int task_fork_test(void) printf("task_fork_test: Child %d ran successfully\n", pid); return 0; } - -#endif /* OSTEST_HAVE_TASK_FORK */