Skip to content

testing/ostest: Exercise custom work queues. - #3759

Open
13022591351 wants to merge 2 commits into
apache:masterfrom
13022591351:testing/custom-work-queues
Open

testing/ostest: Exercise custom work queues.#3759
13022591351 wants to merge 2 commits into
apache:masterfrom
13022591351:testing/custom-work-queues

Conversation

@13022591351

Copy link
Copy Markdown

Summary

  • Extend the existing ostest work queue coverage to dynamically created
    queues with one and two workers.
  • Run scheduler queues and custom queues in Flat builds, and libc custom user
    queues in non-Flat builds.
  • Add ostest wqueue as a focused entry without changing the original
    no-argument ostest flow.
  • Cover explicit caller priorities, invalid arguments, periodic requeue,
    pending replacement, synchronous and parallel cancellation, multiple
    simultaneous queues, self-destruction rejection, and teardown.
  • Check work queue and semaphore API results and release all local test
    resources.
  • Depends on wqueue: Support custom user work queues. nuttx#19982.

Impact

  • New feature: YES, test coverage for custom scheduler and libc user work
    queues.
  • User adaptation: NO. The no-argument ostest sequence remains unchanged
    in non-Flat builds; the focused test is selected with ostest wqueue.
  • Build process: NO. CONFIG_TESTING_OSTEST_WQUEUE defaults to enabled
    only when its pthread and work queue dependencies are available.
  • Hardware: NO production hardware behavior is changed.
  • Documentation: NO separate application documentation is required; the
    Kconfig help describes backend selection.
  • Security: NO impact.
  • Compatibility: Existing Flat ostest work queue coverage is retained and
    expanded.

Testing

Build host:

  • Linux 6.8.0-60-generic, x86_64
  • GNU Arm Embedded Toolchain 10.3.1 20210824

Target:

Before change:

The ostest work queue source is selected only with CONFIG_SCHED_WORKQUEUE.
It has no focused command entry and cannot exercise libc custom user queues
in a Protected user process.

Build output after change:

master_flat:
  FLASH     1470396 B / 1920 KB (74.79%)
  AXI_SRAM    63380 B / 512 KB  (12.09%)

master_protected user:
  uflash      751000 B / 1 MB   (71.62%)
  usram         8192 B / 384 KB (2.08%)

Runtime output summary:

nsh> time "ostest wqueue"

Flat runs:
  30.1490 / 30.1490 / 30.1480 s

Protected libc user runs:
  15.6540 / 15.6540 / 15.6540 s

Every run:
  API validation done
  periodic calls = 3, expect = 3
  replacement total = 2, expect = 2
  sync cancel finished = 1, expect = 1
  parallel callbacks = 2, expect = 2
  multiple queues loop 1/4 through 4/4 done
  self free result = -35, expect = -35
  pending callback = 0, expect = 0
  running callback = 1, expect = 1
  teardown requeue rejected
  teardown done

All three runs for each backend completed without assertion. Current heap
usage did not increase after the first run, and all custom workers exited.

Validation:

checkpatch commit messages: pass
checkpatch complete patch range: pass
full-file nxstyle for wqueue.c and ostest_main.c: pass
cmake-format: pass
git diff --check: pass

PR verification Self-Check

  • This PR introduces only one functional change.
  • I have updated all required description fields above.
  • My PR adheres to the contributing guidelines and coding standard.
  • My PR is still work in progress.
  • My PR is ready for review and can be safely merged.

Add an ostest wqueue entry that runs against scheduler queues in Flat builds
and libc user queues in non-Flat builds without changing the original
no-argument ostest flow.

Cover custom worker pools, explicit caller priorities, invalid arguments,
periodic and pending replacement, synchronous and parallel cancellation,
multiple concurrent queues, self-destruction rejection, and teardown.  Check
API results, release local semaphores, and fix pre-existing style findings in
the touched ostest_main.c file.

Tested on an STM32H7 PX4 FMUv6C in Flat and Protected user configurations.

Assisted-by: Codex:GPT-5
Signed-off-by: DuoYuWang <thirteenking.wang@gmail.com>
Allow CONFIG_TESTING_OSTEST_WQUEUE to build when LIBC_USRWORK is
enabled and pthread support is disabled. In that configuration, exercise
the predefined USRWORK queue while leaving the existing pthread-backed
custom queue tests unchanged.

Collect failures across the no-pthread test cases, use bounded waits,
clean up queued work and semaphores, and report one final result.

Tested on an STM32H7 PX4 FMUv6C in a Protected build with pthread
support disabled.

Signed-off-by: DuoYuWang <thirteenking.wang@gmail.com>
@13022591351
13022591351 force-pushed the testing/custom-work-queues branch from 8d35b54 to e6b1b16 Compare August 29, 2026 12:38
@13022591351

Copy link
Copy Markdown
Author

Thanks for the earlier review. I force-pushed the branch to rebase and
organize the follow-up work into two focused commits:

  1. testing/ostest: exercise custom work queues

    • Exercises dynamically created queues with one and two workers.
    • Covers invalid arguments, periodic requeue, pending replacement,
      synchronous and parallel cancellation, multiple simultaneous queues,
      self-destruction rejection, and teardown.
    • Replaces unbounded semaphore waits with bounded waits and verifies
      exactly 100 callback executions.
  2. testing/ostest: test USRWORK without pthreads

    • Allows the focused WQ test to build with CONFIG_LIBC_USRWORK=y and
      CONFIG_DISABLE_PTHREAD=y.
    • Exercises real work on the predefined USRWORK queue, including
      immediate and delayed work, replacement, cancellation, synchronous
      cancellation, and callback-driven periodic requeue.

The Protected kernel harness is intentionally not included in this apps PR.
The existing non-Flat no-argument ostest flow remains unchanged.

The final two-commit version was validated on an STM32H7 PX4 FMUv6C:

  • Flat ostest wqueue: 30.1490 / 30.1480 / 30.1480 s
  • Protected libc user WQ: 15.6540 / 15.6540 / 15.6540 s
  • Protected USRWORK without pthreads: 0.2290 / 0.2290 / 0.2290 s

All runs completed successfully, and repeated runs showed no cumulative
Kmem or Umem growth. The force-push also normalizes the commit subjects to
the current NuttX style.

@github-actions github-actions Bot added Size: XL and removed Size: L labels Aug 30, 2026
Comment thread testing/ostest/wqueue.c Outdated

static int wait_sem(FAR sem_t *sem)
{
#ifdef __KERNEL__

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why need check __KERNEL__

Comment thread testing/ostest/wqueue.c

#include "ostest.h"

#ifdef CONFIG_DISABLE_PTHREAD

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove the check

Comment thread testing/ostest/Kconfig
default y
depends on !DISABLE_PTHREAD
depends on (BUILD_FLAT && SCHED_WORKQUEUE) || LIBC_USRWORK
depends on (BUILD_FLAT && !DISABLE_PTHREAD && SCHED_WORKQUEUE) || LIBC_USRWORK

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sqaush into the first patch

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants