Skip to content

testing/ostest: Add pthread_sigqueue test - #3931

Merged
xiaoxiang781216 merged 1 commit into
apache:masterfrom
Swatantra-66:testing/pthread-sigqueue
Nov 3, 2026
Merged

xiaoxiang781216 merged 1 commit into
apache:masterfrom
Swatantra-66:testing/pthread-sigqueue

Conversation

@Swatantra-66

@Swatantra-66 Swatantra-66 commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Fixes #3796 by adding automated unit test coverage for the POSIX pthread_sigqueue() interface in apps/testing/ostest.

  1. testing/ostest/pthread_sigqueue.c:

    • Error Handling (Invalid Signal): Verifies that calling pthread_sigqueue() with an invalid signal number fails with EINVAL.
    • Error Handling (Invalid Thread ID): Verifies that calling pthread_sigqueue() with a non-existent thread ID fails with ESRCH.
    • Asynchronous Delivery: Spawns a dedicated receiver thread that registers an asynchronous signal handler via sigaction with SA_SIGINFO and unblocks SIGUSR1.
    • Payload Integrity: Queues a real-time signal and integer payload (sival_int = 42) via pthread_sigqueue(), and asserts that the signal handler receives:
      • info->si_signo == SIGUSR1
      • info->si_code == SI_QUEUE
      • info->si_value.sival_int == 42
    • Clean Teardown: Synchronizes delivery via semaphores and harvests the thread cleanly with pthread_join().
    • Streamlined Footprint: Intermediate progress prints were removed to minimize flash overhead on constrained targets.
  2. Kconfig & Build System Integration:

    • Kconfig Option: Adds CONFIG_TESTING_OSTEST_PTHREAD_SIGQUEUE in testing/ostest/Kconfig, enabled by default for non-small builds (default !DEFAULT_SMALL) and dependent on ENABLE_ALL_SIGNALS && !DISABLE_PTHREAD.
    • Makefile & CMakeLists.txt Parity: Conditionally compiles pthread_sigqueue.c on CONFIG_TESTING_OSTEST_PTHREAD_SIGQUEUE across both build systems.
    • Header & Invocation Synchronization: Declares pthread_sigqueue_test() in ostest.h and invokes it in ostest_main.c guarded by #ifdef CONFIG_TESTING_OSTEST_PTHREAD_SIGQUEUE.

Impact

  • New feature added: Unit test coverage for pthread_sigqueue() in ostest.
  • System Call Integration: Since pthread_sigqueue() is a system call (syscall: Add pthread_sigqueue() to the system call table. nuttx#21070), the test validates signal and payload dispatch across FLAT, PROTECTED, and KERNEL builds.
  • Build Compatibility: 100% nxstyle and cmake-format compliant.

Testing

  • Host: Ubuntu Linux / WSL2
  • Flat Targets: sim:ostest, rv-virt:nsh
  • Kernel / Protected Target: qemu-armv8a:knsh (Validates user-space to kernel-space syscall dispatch and signal return).

Test Flow / Execution Log:

NuttShell (NSH) NuttX-12.14.0
nsh> ostest
...
user_main: pthread_sigqueue test
pthread_sigqueue_test: SUCCESS
...
ostest_main: Exiting with status 0

Style & Format Verification:

  • apps/testing/ostest/pthread_sigqueue.c: 0 errors, 0 warnings
  • apps/testing/ostest/ostest_main.c: 0 errors, 0 warnings
  • apps/testing/ostest/ostest.h: 0 errors, 0 warnings
  • apps/testing/ostest/Kconfig: 0 errors, 0 warnings
  • apps/testing/ostest/Makefile: 0 errors, 0 warnings
  • apps/testing/ostest/CMakeLists.txt: 0 errors, 0 warnings

@xiaoxiang781216

Copy link
Copy Markdown
Contributor

@Swatantra-66 need reduce the size of eic7700-evb/nsh to pass ci.

@Swatantra-66

Copy link
Copy Markdown
Contributor Author

@xiaoxiang781216 I have guarded pthread_sigqueue with !CONFIG_BUILD_KERNEL across Makefile, CMakeLists.txt, ostest.h, and ostest_main
This excludes pthread_sigqueue from kernel-mode builds, reducing the binary footprint of ostest on eic7700-evb/nsh

Comment thread testing/ostest/Makefile Resolved
Comment thread testing/ostest/pthread_sigqueue.c Resolved
casaroli
casaroli previously approved these changes Oct 28, 2026
@Swatantra-66

Copy link
Copy Markdown
Contributor Author

@casaroli @xiaoxiang781216

CI failed on lm3s6965-ek:qemu-flat due to flash overflow by 1276 bytes in Build / Linux (arm-ti).
To resolve this while preserving existing test coverage, I have added CONFIG_TESTING_OSTEST_PTHREAD_SIGQUEUE defaulting to y if !DEFAULT_SMALL && !ARCH_CHIP_LM3S6965. This retains automatic unit test execution across all standard flat ostest configurations while excluding flash-constrained targets like LM3S6965.

@casaroli

Copy link
Copy Markdown
Contributor

@casaroli @xiaoxiang781216

CI failed on lm3s6965-ek:qemu-flat due to flash overflow by 1276 bytes in Build / Linux (arm-ti). To resolve this while preserving existing test coverage, I have added CONFIG_TESTING_OSTEST_PTHREAD_SIGQUEUE defaulting to y if !DEFAULT_SMALL && !ARCH_CHIP_LM3S6965. This retains automatic unit test execution across all standard flat ostest configurations while excluding flash-constrained targets like LM3S6965.

I don't think it is good to disable tests selectively.

Either disable all SIGQUEUE from this board or try to trim it even further.

And have the test gates by sigqueue.

Comment thread testing/ostest/Kconfig Resolved
@Swatantra-66
Swatantra-66 force-pushed the testing/pthread-sigqueue branch from fd3692e to ff04e58 Compare October 29, 2026 19:28
@Swatantra-66

Copy link
Copy Markdown
Contributor Author

I have updated the commit:

  1. Removed BUILD_FLAT: With pthread_sigqueue() implemented as a system call in syscall: Add pthread_sigqueue() to the system call table. nuttx#21070, the test is no longer restricted to flat builds and runs on protected/kernel builds as well.
  2. Removed selective board blacklist: Completely removed !ARCH_CHIP_LM3S6965 from Kconfig. The test is now cleanly gated by feature dependencies:
    config TESTING_OSTEST_PTHREAD_SIGQUEUE
    	bool "pthread_sigqueue test"
    	default !DEFAULT_SMALL
    	depends on ENABLE_ALL_SIGNALS && !DISABLE_PTHREAD
    
  3. Trimmed flash footprint: Removed non-essential verbose progress printf statements and shortened error format strings in pthread_sigqueue.c to strip >700 bytes of .rodata and instruction overhead.

@Swatantra-66
Swatantra-66 requested a review from casaroli October 29, 2026 19:36
Comment thread testing/ostest/Kconfig Resolved
@Swatantra-66

Copy link
Copy Markdown
Contributor Author

As requested, I have separated the TEST_LOOP_SCALE -> TESTING_LOOP_SCALE rename into a dedicated standalone PR: #3941 (along with resolving pre-existing nxstyle issues in spinlock.c).

Also, the arm-ti failure on launchxl-tms57004/nsh appears to be an upstream CI environment issue (arm-nuttx-eabi-gcc: command not found) unrelated to pthread_sigqueue.

Comment thread testing/ostest/pthread_sigqueue.c Resolved
@github-actions

Copy link
Copy Markdown

🔗 Cross-repo PR dependencies

The read-only Build run reported the following dependent PR(s) and fetched head SHA(s):

CI run: https://github.com/apache/nuttx-apps/actions/runs/41196748986

@github-actions

Copy link
Copy Markdown

🔗 Cross-repo PR dependencies

The read-only Build run reported the following dependent PR(s) and fetched head SHA(s):

CI run: https://github.com/apache/nuttx-apps/actions/runs/41227034522

casaroli
casaroli previously approved these changes Nov 1, 2026
@casaroli

casaroli commented Nov 1, 2026

Copy link
Copy Markdown
Contributor

Please rebase

Add automated unit test for pthread_sigqueue() in ostest to verify
signal and payload delivery to a target pthread. Tests error handling
for invalid signal numbers and non-existent thread IDs, as well as
successful signal dispatch and reception with SA_SIGINFO and SI_QUEUE.

Now that pthread_sigqueue() is implemented as a system call
(apache/nuttx#21070), the test runs across flat, protected, and
kernel builds.

Configurable via CONFIG_TESTING_OSTEST_PTHREAD_SIGQUEUE, enabled by
default for non-small builds (!DEFAULT_SMALL) and gated by
ENABLE_ALL_SIGNALS and !DISABLE_PTHREAD. Progress output and error
messages are streamlined to minimize the flash footprint.

Signed-off-by: Swatantra Yadav <[email protected]>
@Swatantra-66
Swatantra-66 dismissed stale reviews from casaroli and xiaoxiang781216 via 8d4acc5 November 1, 2026 11:26
@Swatantra-66
Swatantra-66 force-pushed the testing/pthread-sigqueue branch from 24e70c1 to 8d4acc5 Compare November 1, 2026 11:26
@Swatantra-66

Copy link
Copy Markdown
Contributor Author

Please rebase

rebased onto latest master and resolved the Kconfig conflict

@github-actions

github-actions Bot commented Nov 1, 2026

Copy link
Copy Markdown

🔗 Cross-repo PR dependencies

The read-only Build run reported the following dependent PR(s) and fetched head SHA(s):

CI run: https://github.com/apache/nuttx-apps/actions/runs/41301894032

@Swatantra-66 Swatantra-66 reopened this Nov 1, 2026

@casaroli casaroli left a comment

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.

The PR body does not match the code. Summary item 2 says the build files and ostest_main.c test CONFIG_DISABLE_PTHREAD and CONFIG_ENABLE_ALL_SIGNALS, but they test CONFIG_TESTING_OSTEST_PTHREAD_SIGQUEUE. The test log shows progress lines that the test no longer prints, and Testing lists only flat builds.

Fix: describe the new Kconfig option, replace the log with one from the current code, and add a protected or kernel build run (for example qemu-armv8a:knsh).

@Swatantra-66

Copy link
Copy Markdown
Contributor Author

Re-triggered to pick up the fix from apache/nuttx#21335 for arm-ti.

@Swatantra-66

Copy link
Copy Markdown
Contributor Author

@casaroli updated the PR body to document CONFIG_TESTING_OSTEST_PTHREAD_SIGQUEUE, replaced the test log with the streamlined output, and added the protected/kernel verification target (qemu-armv8a:knsh).

@github-actions

github-actions Bot commented Nov 1, 2026

Copy link
Copy Markdown

🔗 Cross-repo PR dependencies

The read-only Build run reported the following dependent PR(s) and fetched head SHA(s):

CI run: https://github.com/apache/nuttx-apps/actions/runs/41340902824

@xiaoxiang781216

Copy link
Copy Markdown
Contributor

another board flash overflow

@Swatantra-66

Swatantra-66 commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor Author

@xiaoxiang781216 opened apache/nuttx#21370 to shrink nucleo-l432kc:wgen (dropping unused C++ and unused NSH commands to free ~6 KiB flash)

@xiaoxiang781216

Copy link
Copy Markdown
Contributor

@xiaoxiang781216 opened apache/nuttx#21370 to shrink nucleo-l432kc:wgen (dropping unused C++ and unused NSH commands to free ~6 KiB flash)

@jerpelea please approve apache/nuttx#21370.

@xiaoxiang781216
xiaoxiang781216 merged commit 09a59b9 into apache:master Nov 3, 2026
103 of 119 checks passed
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.

[FEATURE] pthread_sigqueue testing implementation

4 participants