Swatantra-66 opened a new pull request, #3931:
URL: https://github.com/apache/nuttx-apps/pull/3931
## Summary
Fixes apache/nuttx-apps#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()`.
2. **Build System & Configuration Integration:**
- **Makefile & CMakeLists.txt Parity:** Registers `pthread_sigqueue.c` in
both GNU Make and CMake build systems.
- **Configuration Guarding:** Conditioned on `ifneq
($(CONFIG_DISABLE_PTHREAD),y)` and `ifeq ($(CONFIG_ENABLE_ALL_SIGNALS),y)` in
both build systems.
- **Header & Invocation Synchronization:** Declares
`pthread_sigqueue_test()` in `ostest.h` and invokes it in `ostest_main.c`
guarded by `#if defined(CONFIG_ENABLE_ALL_SIGNALS) &&
!defined(CONFIG_DISABLE_PTHREAD)`, preventing link-time undefined references on
minimal or pthread-disabled configurations.
## Impact
- **New feature added:** Yes, unit test coverage for `pthread_sigqueue()` in
`ostest`.
- **Existing behavior changed:** No, existing tests and build flows remain
100% untouched.
- **Build process:** Builds `pthread_sigqueue.c` into `libapps.a` when both
pthreads and full signal support are enabled.
- **Compatibility:** 100% nxstyle compliant across all modified and newly
created files.
## Testing
- **Host:** Windows 11 / WSL2
- **Target:** `sim:ostest`, `rv-virt:nsh`
### Test Flow / Execution Log:
```text
user_main: pthread_sigqueue test
pthread_sigqueue_test: Initializing semaphores
pthread_sigqueue_test: Creating target thread
pthread_sigqueue_test: Waiting for target thread to be ready
pthread_sigqueue_test: Sending signal 10 with value 42
pthread_sigqueue_test: Joining target thread
pthread_sigqueue_test: SUCCESS
```
### Style & Format Verification:
```text
Coding standard compliance check:
- 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/Makefile: 0 errors, 0 warnings
- apps/testing/ostest/CMakeLists.txt: 0 errors, 0 warnings
100% NXSTYLE & CMAKE-FORMAT COMPLIANT
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]