testing/ostest: exercise custom work queues

Add a focused wqueue entry that exercises predefined and dynamically
created work queues without changing the no-argument ostest flow.

Share the semaphore wait and basic worker helpers across configurations.
Flat builds exercise scheduler queues, Protected builds exercise USRWORK,
and pthread-enabled builds additionally cover configurable custom worker
pools. When pthread support is disabled, only predefined USRWORK cases are
compiled.

Cover invalid arguments, priority lookup, immediate and delayed work,
pending replacement and cancellation, periodic requeue, synchronous and
parallel cancellation, concurrent queues, callback self-destruction, and
queue teardown.

Assisted-by: Codex:GPT-5
Signed-off-by: DuoYuWang <thirteenking.wang@gmail.com>
This commit is contained in:
DuoYuWang 2026-09-07 16:54:52 +08:00 • committed by GUIDINGLI
parent 61143782d4
commit 1c0a812377
6 changed files with 1056 additions and 132 deletions

View file

@ -126,15 +126,15 @@ if(CONFIG_TESTING_OSTEST)
list(APPEND SRCS sporadic.c sporadic2.c)
endif()
if(CONFIG_SCHED_WORKQUEUE)
list(APPEND SRCS wqueue.c)
endif()
if(CONFIG_PRIORITY_INHERITANCE)
list(APPEND SRCS prioinherit.c)
endif() # CONFIG_PRIORITY_INHERITANCE
endif() # CONFIG_DISABLE_PTHREAD
if(CONFIG_TESTING_OSTEST_WQUEUE)
list(APPEND SRCS wqueue.c)
endif()
if(NOT CONFIG_DISABLE_MQUEUE)
if(NOT CONFIG_DISABLE_PTHREAD)
list(APPEND SRCS timedmqueue.c)

View file

@ -51,6 +51,16 @@ config TESTING_OSTEST_AIOPATH
endif
config TESTING_OSTEST_WQUEUE
bool "Work queue tests"
default y
depends on (BUILD_FLAT && !DISABLE_PTHREAD && SCHED_WORKQUEUE) || LIBC_USRWORK
---help---
Enables the work queue tests. In non-flat builds, the tests run in
user space and require the libc user work queue implementation. If
pthread support is disabled, only the predefined USRWORK queue is
tested because dynamically allocated queues require pthread support.
config TESTING_OSTEST_RR_RANGE
int "Round-robin test - end of search range"
default 30000

View file

@ -127,15 +127,15 @@ ifeq ($(CONFIG_SCHED_SPORADIC),y)
CSRCS += sporadic.c sporadic2.c
endif
ifeq ($(CONFIG_SCHED_WORKQUEUE),y)
CSRCS += wqueue.c
endif
ifeq ($(CONFIG_PRIORITY_INHERITANCE),y)
CSRCS += prioinherit.c
endif
endif # CONFIG_DISABLE_PTHREAD
ifeq ($(CONFIG_TESTING_OSTEST_WQUEUE),y)
CSRCS += wqueue.c
endif
ifneq ($(CONFIG_DISABLE_MQUEUE),y)
ifneq ($(CONFIG_DISABLE_PTHREAD),y)
CSRCS += timedmqueue.c

View file

@ -146,7 +146,7 @@ int chroot_test(void);
/* wqueue.c *****************************************************************/
#if defined(CONFIG_SCHED_LPWORK) || defined(CONFIG_SCHED_HPWORK)
#ifdef CONFIG_TESTING_OSTEST_WQUEUE
void wqueue_test(void);
#endif

View file

@ -155,6 +155,7 @@ static void show_variable(const char *var_name, const char *exptd_value,
bool var_valid)
{
char *actual_value = getenv(var_name);
if (actual_value)
{
if (var_valid)
@ -302,19 +303,19 @@ static int user_main(int argc, char *argv[])
#if defined(CONFIG_SCHED_HAVE_PARENT) && defined(CONFIG_SCHED_CHILD_STATUS) && \
defined(CONFIG_ENABLE_ALL_SIGNALS)
{
struct sigaction sa;
int ret;
{
struct sigaction sa;
int ret;
sa.sa_handler = SIG_IGN;
sa.sa_flags = SA_NOCLDWAIT;
ret = sigaction(SIGCHLD, &sa, NULL);
if (ret < 0)
{
printf("user_main: ERROR: sigaction failed: %d\n", errno);
ASSERT(false);
}
}
sa.sa_handler = SIG_IGN;
sa.sa_flags = SA_NOCLDWAIT;
ret = sigaction(SIGCHLD, &sa, NULL);
if (ret < 0)
{
printf("user_main: ERROR: sigaction failed: %d\n", errno);
ASSERT(false);
}
}
#endif
#ifndef CONFIG_DISABLE_ENVIRON
@ -430,8 +431,7 @@ static int user_main(int argc, char *argv[])
check_test_memory_usage();
#endif
#if !defined(CONFIG_DISABLE_PTHREAD) && defined(CONFIG_BUILD_FLAT) && \
defined(CONFIG_SCHED_WORKQUEUE)
#if defined(CONFIG_TESTING_OSTEST_WQUEUE) && defined(CONFIG_BUILD_FLAT)
/* Check work queues */
printf("\nuser_main: wqueue test\n");
@ -770,6 +770,14 @@ int main(int argc, FAR char **argv)
}
#endif
#ifdef CONFIG_TESTING_OSTEST_WQUEUE
if (argc == 2 && strcmp(argv[1], "wqueue") == 0)
{
wqueue_test();
return EXIT_SUCCESS;
}
#endif
/* Verify that stdio works first */
stdio_test();

File diff suppressed because it is too large Load diff