mirror of
https://github.com/apache/nuttx-apps.git
synced 2026-08-01 20:29:00 +00:00
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 <marco.casaroli@gmail.com> Assisted-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
7aac6c5cb8
commit
d3b7722b3d
10 changed files with 14 additions and 71 deletions
|
|
@ -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\"" >> $@
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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
|
||||
};
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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 */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue