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 78da15c463b2a19a821322ed6091fea2c417c948
Author: huojianchao <[email protected]>
AuthorDate: Mon Nov 30 11:23:06 2026 +0800

    testing/mm/iob: check the results with ASSERT()
    
    Several tests check their results only with DEBUGASSERT(), which does
    nothing without CONFIG_DEBUG_ASSERTIONS, so in those builds the tests
    pass whatever the result.  Use ASSERT(), as the rest of this file does.
    
    Assisted-by: Kiro:claude-opus-5-5
    Signed-off-by: huojianchao <[email protected]>
---
 testing/mm/iob/iob_main.c | 68 +++++++++++++++++++++++------------------------
 1 file changed, 34 insertions(+), 34 deletions(-)

diff --git a/testing/mm/iob/iob_main.c b/testing/mm/iob/iob_main.c
index 3690a2c22..2b4f87e10 100644
--- a/testing/mm/iob/iob_main.c
+++ b/testing/mm/iob/iob_main.c
@@ -387,7 +387,7 @@ static int test_iob_alloc_free(void)
   printf("iob_tryalloc success, iob=%p\n", iob1);
   count = iob_navail(false);
   printf("Available IOBs after tryalloc: %d\n", count);
-  DEBUGASSERT(count == initial_count - 1);
+  ASSERT(count == initial_count - 1);
 
   /* Test alloc */
 
@@ -402,20 +402,20 @@ static int test_iob_alloc_free(void)
   printf("iob_alloc success, iob=%p\n", iob2);
   count = iob_navail(false);
   printf("Available IOBs after alloc: %d\n", count);
-  DEBUGASSERT(count == initial_count - 2);
+  ASSERT(count == initial_count - 2);
 
   /* Test free single buffer */
 
   iob3 = iob_free(iob1);
-  DEBUGASSERT(iob3 == NULL);  /* Should be NULL since iob1 has no chain */
+  ASSERT(iob3 == NULL);  /* Should be NULL since iob1 has no chain */
   count = iob_navail(false);
   printf("Available IOBs after free: %d\n", count);
-  DEBUGASSERT(count == initial_count - 1);
+  ASSERT(count == initial_count - 1);
 
   iob_free(iob2);
   count = iob_navail(false);
   printf("Available IOBs after second free: %d\n", count);
-  DEBUGASSERT(count == initial_count);
+  ASSERT(count == initial_count);
 
   printf("Test 1 PASSED\n");
   return 0;
@@ -467,7 +467,7 @@ static int test_iob_copyin_copyout(void)
 
   printf("iob_copyin success, copied %d bytes\n", ret);
   printf("IOB packet length: %u\n", iob->io_pktlen);
-  DEBUGASSERT(iob->io_pktlen == TEST_DATA_SIZE);
+  ASSERT(iob->io_pktlen == TEST_DATA_SIZE);
 
   /* Test copyout */
 
@@ -525,7 +525,7 @@ static int test_iob_queue_operations(void)
   /* Initialize queue */
 
   IOB_QINIT(&queue);
-  DEBUGASSERT(IOB_QEMPTY(&queue));
+  ASSERT(IOB_QEMPTY(&queue));
   printf("Queue initialized\n");
 
   /* Allocate and prepare IOBs */
@@ -585,8 +585,8 @@ static int test_iob_queue_operations(void)
   size = iob_get_queue_size(&queue);
   count = iob_get_queue_entry_count(&queue);
   printf("Queue size: %u bytes, entry count: %u\n", size, count);
-  DEBUGASSERT(count == 3);
-  DEBUGASSERT(size == sizeof(data) * 3);
+  ASSERT(count == 3);
+  ASSERT(size == sizeof(data) * 3);
 
   /* Test peek_queue */
 
@@ -599,12 +599,12 @@ static int test_iob_queue_operations(void)
     }
 
   printf("Peeked queue, iob=%p (should be iob1=%p)\n", peeked, iob1);
-  DEBUGASSERT(peeked == iob1);
+  ASSERT(peeked == iob1);
 
   /* Queue should still have same size after peek */
 
   count = iob_get_queue_entry_count(&queue);
-  DEBUGASSERT(count == 3);
+  ASSERT(count == 3);
 
   /* Test remove_queue */
 
@@ -617,34 +617,34 @@ static int test_iob_queue_operations(void)
     }
 
   printf("Removed from queue, iob=%p\n", removed);
-  DEBUGASSERT(removed == iob1);
+  ASSERT(removed == iob1);
   iob_free_chain(removed);
 
   count = iob_get_queue_entry_count(&queue);
   printf("Queue entry count after removal: %u\n", count);
-  DEBUGASSERT(count == 2);
+  ASSERT(count == 2);
 
   /* Remove second element */
 
   removed = iob_remove_queue(&queue);
-  DEBUGASSERT(removed == iob2);
+  ASSERT(removed == iob2);
   iob_free_chain(removed);
 
   count = iob_get_queue_entry_count(&queue);
-  DEBUGASSERT(count == 1);
+  ASSERT(count == 1);
 
   /* Remove last element */
 
   removed = iob_remove_queue(&queue);
-  DEBUGASSERT(removed == iob3);
+  ASSERT(removed == iob3);
   iob_free_chain(removed);
 
   /* Queue should be empty now */
 
-  DEBUGASSERT(IOB_QEMPTY(&queue));
+  ASSERT(IOB_QEMPTY(&queue));
   count = iob_get_queue_entry_count(&queue);
   printf("Queue is empty, entry count: %u\n", count);
-  DEBUGASSERT(count == 0);
+  ASSERT(count == 0);
 
   printf("Test 3 PASSED\n");
   return 0;
@@ -716,7 +716,7 @@ static int test_iob_chain_operations(void)
 
   printf("After concat: io_pktlen=%u (expected %u)\n",
          iob1->io_pktlen, pktlen);
-  DEBUGASSERT(iob1->io_pktlen == pktlen);
+  ASSERT(iob1->io_pktlen == pktlen);
 
   chain_count = iob_count(iob1);
   printf("Chain count: %d\n", chain_count);
@@ -750,16 +750,16 @@ static int test_iob_chain_operations(void)
 
   printf("Testing trimhead (remove 32 bytes)...\n");
   result = iob_trimhead(iob1, 32);
-  DEBUGASSERT(result != NULL);
+  ASSERT(result != NULL);
   printf("After trimhead: io_pktlen=%u\n", result->io_pktlen);
-  DEBUGASSERT(result->io_pktlen == pktlen - 32);
+  ASSERT(result->io_pktlen == pktlen - 32);
 
   /* Test trimtail */
 
   printf("Testing trimtail (remove 32 bytes)...\n");
   result = iob_trimtail(result, 32);
   printf("After trimtail: io_pktlen=%u\n", result->io_pktlen);
-  DEBUGASSERT(result->io_pktlen == pktlen - 64);
+  ASSERT(result->io_pktlen == pktlen - 64);
 
   /* Clean up */
 
@@ -836,7 +836,7 @@ static int test_iob_clone(void)
   printf("Clone success\n");
   printf("Original io_pktlen=%u, Clone io_pktlen=%u\n",
          iob1->io_pktlen, iob2->io_pktlen);
-  DEBUGASSERT(iob1->io_pktlen == iob2->io_pktlen);
+  ASSERT(iob1->io_pktlen == iob2->io_pktlen);
 
   /* Verify cloned data */
 
@@ -993,7 +993,7 @@ static int test_iob_update_pktlen(void)
     }
 
   printf("After expand: io_pktlen=%u\n", iob->io_pktlen);
-  DEBUGASSERT(iob->io_pktlen == 150);
+  ASSERT(iob->io_pktlen == 150);
 
   /* Test shrinking packet length */
 
@@ -1007,7 +1007,7 @@ static int test_iob_update_pktlen(void)
     }
 
   printf("After shrink: io_pktlen=%u\n", iob->io_pktlen);
-  DEBUGASSERT(iob->io_pktlen == 50);
+  ASSERT(iob->io_pktlen == 50);
 
   /* Clean up */
 
@@ -1075,12 +1075,12 @@ static int test_iob_queue_concat(void)
   iob_add_queue(iob2, &queue1);
   count1 = iob_get_queue_entry_count(&queue1);
   printf("Queue1 entry count: %u\n", count1);
-  DEBUGASSERT(count1 == 2);
+  ASSERT(count1 == 2);
 
   iob_add_queue(iob3, &queue2);
   count2 = iob_get_queue_entry_count(&queue2);
   printf("Queue2 entry count: %u\n", count2);
-  DEBUGASSERT(count2 == 1);
+  ASSERT(count2 == 1);
 
   /* Test concat_queue */
 
@@ -1089,14 +1089,14 @@ static int test_iob_queue_concat(void)
 
   total_count = iob_get_queue_entry_count(&queue1);
   printf("After concat, queue1 entry count: %u\n", total_count);
-  DEBUGASSERT(total_count == 3);
+  ASSERT(total_count == 3);
 
   /* Queue2 should be empty */
 
   count2 = iob_get_queue_entry_count(&queue2);
   printf("After concat, queue2 entry count: %u\n", count2);
-  DEBUGASSERT(count2 == 0);
-  DEBUGASSERT(IOB_QEMPTY(&queue2));
+  ASSERT(count2 == 0);
+  ASSERT(IOB_QEMPTY(&queue2));
 
   /* Clean up */
 
@@ -1200,7 +1200,7 @@ static int test_iob_queue_extend_tail(void)
    */
 
   iob_add_queue(chain1, &queue);
-  DEBUGASSERT(iob_get_queue_entry_count(&queue) == 1);
+  ASSERT(iob_get_queue_entry_count(&queue) == 1);
 
   /* Extend chain1 past a single IOB's capacity so iob_copyin() must
    * allocate a second IOB, moving IOB_CHAIN_END to it and leaving qh_tail
@@ -1219,7 +1219,7 @@ static int test_iob_queue_extend_tail(void)
     }
 
   chain1_pktlen = chain1->io_pktlen;
-  DEBUGASSERT(chain1_pktlen == 5 + biglen);
+  ASSERT(chain1_pktlen == 5 + biglen);
 
   /* chain1 must now span more than one IOB. */
 
@@ -1296,7 +1296,7 @@ static int test_iob_queue_extend_tail(void)
 
   iob_free_chain(removed);
 
-  DEBUGASSERT(IOB_QEMPTY(&queue));
+  ASSERT(IOB_QEMPTY(&queue));
   printf("Test 12 PASSED\n");
   return 0;
 }
@@ -1782,7 +1782,7 @@ static int test_iob_thread(void)
           failed_count[0], success_count[0]);
   printf("throttled thread 1 statistic failed_count %d success_count %d\n",
           failed_count[1], success_count[1]);
-  DEBUGASSERT(failed_count[0] == 0 && failed_count[1] == 0);
+  ASSERT(failed_count[0] == 0 && failed_count[1] == 0);
 
   printf("Original IOB Test PASSED\n");
   return 0;

Reply via email to