casaroli opened a new pull request, #3969:
URL: https://github.com/apache/nuttx-apps/pull/3969

   ## Summary
   
   No test in nuttx-apps covers System V message queues (`msgget()`, 
`msgsnd()`, `msgrcv()`, `msgctl()`). This PR adds the cmocka test 
`cmocka_msg_test` to `testing/testsuites` (`CONFIG_CM_MSG_TEST`), next to the 
other kernel suites.
   
   The 25 cases check the POSIX behaviour, including the NuttX fixes of 
apache/nuttx#21211 and apache/nuttx#21421:
   
   - `msgget(IPC_PRIVATE)` with and without `IPC_CREAT`: two different queues. 
`msgget()` of a key: the same identifier again, `EEXIST` with `IPC_CREAT | 
IPC_EXCL`. 260 queues at the same time (the case skips when the kernel heap 
cannot hold them).
   - `msgrcv()` with `msgtyp` 0 (order of `msgsnd()`), greater than 0 (first 
message of that type) and less than 0 (lowest type, `ENOMSG` when no type is <= 
|msgtyp|).
   - `MSG_NOERROR` truncation; `E2BIG` without it (the message stays in the 
queue); `ENOMSG` and `EAGAIN` with `IPC_NOWAIT`; `EINVAL` for a type less than 
1, a message that is too long and a bad identifier.
   - `msgctl()` `IPC_STAT` (`msg_perm.mode`, `msg_qnum`, `msg_qbytes`, the PIDs 
and times), `IPC_SET` (`msg_qbytes` in bytes), `IPC_RMID` (the identifier is 
then not valid).
   - A thread blocked in `msgrcv()` or `msgsnd()`: it returns when another 
thread sends a message of its type or makes room, it fails with `EIDRM` when 
the queue is removed, and it fails with `EINTR` when a signal interrupts it. 
Two receivers of different types: the message goes to the right one.
   - `msgsnd()` with an empty message pool (`CONFIG_PREALLOC_MQ_MSGS`): 
`EAGAIN` with `IPC_NOWAIT`, it blocks until `msgrcv()` frees a message, 
`EINTR`, `EIDRM`.
   
   The option depends on `!DISABLE_MQUEUE_SYSV && !DISABLE_PTHREAD`, and on 
`PREALLOC_MQ_MSGS >= 4 && MQ_MAXMSGSIZE >= 8`. The teardown of each case 
removes its queues, which also wakes up a thread that is still blocked in a 
failed case. The commit message has `[skip-cmake-parity]` because the CMake 
rules of the suites are in `testing/testsuites/kernel/CMakeLists.txt`, which 
the commit updates, and not in `testing/testsuites/CMakeLists.txt`.
   
   depends-on: apache/nuttx/pull/21436
   
   ## Impact
   
   New test only, `default n`. No defconfig enables it, so no CI build changes. 
No change to other suites.
   
   ## Testing
   
   `cmocka_msg_test` and ostest, QEMU with HVF, 1 CPU unless noted (the 
protected build under TCG), before and with apache/nuttx#21421:
   
   | Configuration | before #21421 (6569424cfa6) | with #21421 | ostest before 
/ with |
   |---|---|---|---|
   | qemu-armv8a:nsh (flat) | 15 PASS, 10 FAIL | 25/25 PASS | status 0 / 0 |
   | qemu-armv8a:knsh (kernel, the test as an ELF in /system/bin) | 15 PASS, 10 
FAIL | 25/25 PASS | status 0 / 0 |
   | mps2-an500:knsh (protected, Cortex-M7) | 15 PASS, 10 FAIL | 25/25 PASS 
(the 260 queues fit) | status 0 / 0 |
   | qemu-armv8a:nsh_smp (flat, SMP, 2 CPUs) | 15 PASS, 10 FAIL | 25/25 PASS | 
see below |
   
   On SMP, ostest stopped in its spinlock test on both, the master hang that 
apache/nuttx#21393 fixes; with the commits of #21393 ostest gives status 0 on 
both.
   
   The kernel and protected runs set `CONFIG_TESTS_TESTSUITES_STACKSIZE=8192`: 
with `CONFIG_TLS_ALIGNED` (`TLS_LOG2_MAXSTACK=13`) the default 16384 is larger 
than the stack limit, and the program does not start (`EINVAL`). The same 
default applies to every suite of `testing/testsuites`.
   
   Builds with `CONFIG_CM_MSG_TEST=y` and `EXTRAFLAGS="-Wno-cpp -Werror"`, each 
OK, no warning: rv-virt:citest (make), qemu-armv8a:citest + cmocka suites 
(CMake), mps2-an500:knsh (protected). qemu-armv8a:nsh with 
`CONFIG_DISABLE_MQUEUE_SYSV=y`: the option is off and nothing of the test is 
built.
   
   `tools/checkpatch.sh -c -u -m -g` passes. No Documentation page covers 
`testing/testsuites`.
   


-- 
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]

Reply via email to