This is an automated email from the ASF dual-hosted git repository.

GUIDINGLI pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx-apps.git


The following commit(s) were added to refs/heads/master by this push:
     new d539e3982 testing/nettest: Poll the configured number of pipe waiters.
d539e3982 is described below

commit d539e3982c184cf399a1e934a24017b6936c6111
Author: Marco Casaroli <[email protected]>
AuthorDate: Sun Nov 29 22:25:09 2026 +0100

    testing/nettest: Poll the configured number of pipe waiters.
    
    test_local_dgram_poll_slots polled 4 entries of one datagram socket and
    accepted only success or EBUSY.  Since the default of
    CONFIG_DEV_PIPE_NPOLLWAITERS is 2, the case fails: the FIFO of the socket
    has no slot for the third entry, and poll() does not fail with EBUSY.  It
    returns 1 and sets POLLERR in that entry.  With 4 slots the case passed,
    but it did not reach the slot limit.
    
    The case now uses CONFIG_DEV_PIPE_NPOLLWAITERS (NET_LOCAL selects PIPES,
    so it is always defined).  In each round, a poll() of all slots gives no
    event.  This also shows that the round before kept no slot.  Then a
    poll() of one entry more than the slots returns 1, with POLLERR only in
    the last entry.  At the end, one waiter still wakes up for a datagram.
    
    Assisted-by: Claude Code:claude-opus-5-5
    Signed-off-by: Marco Casaroli <[email protected]>
---
 testing/nettest/local/test_local_dgram_pollext.c | 32 ++++++++++++++++--------
 1 file changed, 22 insertions(+), 10 deletions(-)

diff --git a/testing/nettest/local/test_local_dgram_pollext.c 
b/testing/nettest/local/test_local_dgram_pollext.c
index 7f0dd998e..edcf566f3 100644
--- a/testing/nettest/local/test_local_dgram_pollext.c
+++ b/testing/nettest/local/test_local_dgram_pollext.c
@@ -24,6 +24,8 @@
  * Included Files
  ****************************************************************************/
 
+#include <nuttx/config.h>
+
 #include <errno.h>
 #include <fcntl.h>
 #include <poll.h>
@@ -987,8 +989,8 @@ void test_local_dgram_poll_threads(FAR void **state)
  * Name: test_local_dgram_poll_slots
  *
  * Description:
- *   More waiters than the FIFO may have slots for: the call may fail with
- *   EBUSY, but no slot stays taken after it.
+ *   All poll slots of the FIFO work.  One waiter more than the slots gets
+ *   POLLERR, and no slot stays taken after the call.
  *
  ****************************************************************************/
 
@@ -996,25 +998,35 @@ void test_local_dgram_poll_slots(FAR void **state)
 {
   FAR struct nettest_local_dgram_state_s *st = *state;
   struct local_dgram_job_s job;
-  struct pollfd pfd[4];
+  struct pollfd pfd[CONFIG_DEV_PIPE_NPOLLWAITERS + 1];
   int revents;
-  int ret;
   int i;
+  int j;
 
   for (i = 0; i < 20; i++)
     {
-      int j;
-
-      for (j = 0; j < 4; j++)
+      for (j = 0; j <= CONFIG_DEV_PIPE_NPOLLWAITERS; j++)
         {
           pfd[j].fd      = st->r1;
           pfd[j].events  = POLLIN;
           pfd[j].revents = 0;
         }
 
-      errno = 0;
-      ret = poll(pfd, 4, 0);
-      assert_true(ret == 0 || (ret == -1 && errno == EBUSY));
+      /* A slot that an earlier call kept gives POLLERR here */
+
+      assert_int_equal(poll(pfd, CONFIG_DEV_PIPE_NPOLLWAITERS, 0), 0);
+      for (j = 0; j < CONFIG_DEV_PIPE_NPOLLWAITERS; j++)
+        {
+          assert_int_equal(pfd[j].revents, 0);
+        }
+
+      assert_int_equal(poll(pfd, CONFIG_DEV_PIPE_NPOLLWAITERS + 1, 0), 1);
+      for (j = 0; j < CONFIG_DEV_PIPE_NPOLLWAITERS; j++)
+        {
+          assert_int_equal(pfd[j].revents, 0);
+        }
+
+      assert_int_equal(pfd[CONFIG_DEV_PIPE_NPOLLWAITERS].revents, POLLERR);
     }
 
   local_dgram_job_start(&job, local_dgram_do_send, st->s, NULL, 100);

Reply via email to