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

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

commit b16e2f1e2b987a5a24ed8857c32116b3d6d9ec8b
Author: huojianchao <[email protected]>
AuthorDate: Mon Nov 30 11:23:32 2026 +0800

    testing/mm/iob: skip Test 10 when the pool is too small
    
    test_iob_pointer_flags() holds 9 IOBs at the same time.  With fewer free
    IOBs (sim:nsh has 8) it failed, and because main() stops at the first
    failure, the tests after it never ran.  Check iob_navail() first and
    skip the test with a message instead.
    
    Also check the queue entry count and size that the test printed without
    checking, and free a dequeued chain that is not the expected one instead
    of leaking it.
    
    Assisted-by: Kiro:claude-opus-5-5
    Signed-off-by: huojianchao <[email protected]>
---
 testing/mm/iob/iob_main.c | 46 ++++++++++++++++++++++++++++++++++++++++++----
 1 file changed, 42 insertions(+), 4 deletions(-)

diff --git a/testing/mm/iob/iob_main.c b/testing/mm/iob/iob_main.c
index 2b4f87e10..2a730ce42 100644
--- a/testing/mm/iob/iob_main.c
+++ b/testing/mm/iob/iob_main.c
@@ -53,6 +53,15 @@
 #define TEST_PATTERN_1 0xAA
 #define TEST_PATTERN_2 0x55
 
+/* create_iob_chain() puts CHAIN_IOB_NBYTES bytes in each IOB of a chain */
+
+#define CHAIN_IOB_NBYTES 16
+
+/* Test 10 builds four chains of 3, 2, 3 and 1 IOBs */
+
+#define POINTER_FLAGS_NIOBS 9
+#define POINTER_FLAGS_NBYTES (POINTER_FLAGS_NIOBS * CHAIN_IOB_NBYTES)
+
 /****************************************************************************
  * Private Data
  ****************************************************************************/
@@ -209,7 +218,7 @@ static FAR struct iob_s *create_iob_chain(int length, 
uint8_t pattern)
 {
   FAR struct iob_s *head = NULL;
   FAR struct iob_s *iob;
-  uint8_t data[16];
+  uint8_t data[CHAIN_IOB_NBYTES];
   int i;
 
   if (length <= 0)
@@ -1371,8 +1380,25 @@ static int test_iob_pointer_flags(void)
   FAR struct iob_s *chain3;
   FAR struct iob_s *chain4;
   FAR struct iob_s *removed;
+  unsigned int count;
+  unsigned int size;
+  int navail;
 
   printf("\n=== Test 10: IOB Pointer Low-Bit Flags (Enhanced) ===\n");
+
+  /* The chains below need POINTER_FLAGS_NIOBS free IOBs at the same time.
+   * Smaller pools (sim:nsh has 8) cannot run this test, which is not a
+   * failure of the IOB code.
+   */
+
+  navail = iob_navail(false);
+  if (navail < POINTER_FLAGS_NIOBS)
+    {
+      printf("Test 10 SKIPPED: needs %d free IOBs, %d available\n",
+             POINTER_FLAGS_NIOBS, navail);
+      return 0;
+    }
+
   printf("This test verifies the key feature of commit 9a4364d3ce5b2fd:\n");
   printf("Using pointer low-bit flags for queue management\n");
   printf("Testing with multi-IOB chains to fully validate the design\n\n");
@@ -1460,9 +1486,17 @@ static int test_iob_pointer_flags(void)
   /* Verify queue statistics */
 
   printf("\n--- Verifying queue statistics ---\n");
-  printf("Queue entry count: %u (expected 4)\n",
-         iob_get_queue_entry_count(&queue));
-  printf("Queue size: %u bytes\n", iob_get_queue_size(&queue));
+  count = iob_get_queue_entry_count(&queue);
+  size = iob_get_queue_size(&queue);
+  printf("Queue entry count: %u (expected 4)\n", count);
+  printf("Queue size: %u bytes (expected %d)\n", size,
+         POINTER_FLAGS_NBYTES);
+
+  if (count != 4 || size != POINTER_FLAGS_NBYTES)
+    {
+      printf("ERROR: Wrong queue entry count or size\n");
+      goto cleanup;
+    }
 
   /* Remove chains one by one and verify */
 
@@ -1472,6 +1506,7 @@ static int test_iob_pointer_flags(void)
   if (removed == NULL || removed != chain1)
     {
       printf("ERROR: Expected to remove chain1, got %p\n", removed);
+      iob_free_chain(removed);
       goto cleanup;
     }
 
@@ -1483,6 +1518,7 @@ static int test_iob_pointer_flags(void)
   if (removed == NULL || removed != chain2)
     {
       printf("ERROR: Expected to remove chain2, got %p\n", removed);
+      iob_free_chain(removed);
       goto cleanup;
     }
 
@@ -1494,6 +1530,7 @@ static int test_iob_pointer_flags(void)
   if (removed == NULL || removed != chain3)
     {
       printf("ERROR: Expected to remove chain3, got %p\n", removed);
+      iob_free_chain(removed);
       goto cleanup;
     }
 
@@ -1505,6 +1542,7 @@ static int test_iob_pointer_flags(void)
   if (removed == NULL || removed != chain4)
     {
       printf("ERROR: Expected to remove chain4, got %p\n", removed);
+      iob_free_chain(removed);
       goto cleanup;
     }
 

Reply via email to