File tree Expand file tree Collapse file tree 1 file changed +28
-0
lines changed
tests/kernel/mem_heap/k_heap_api/src Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Original file line number Diff line number Diff line change @@ -291,3 +291,31 @@ ZTEST(k_heap_api, test_k_heap_calloc)
291291
292292 k_heap_free (& k_heap_test , p );
293293}
294+
295+ /**
296+ * @brief Test to demonstrate k_heap_array_get()
297+ *
298+ * @ingroup kernel_kheap_api_tests
299+ *
300+ * @details The test ensures that valid values are returned
301+ *
302+ * @see k_heap_array_get()
303+ */
304+ ZTEST (k_heap_api , test_k_heap_array_get )
305+ {
306+ struct k_heap * ha = NULL ;
307+ bool test_heap_found = false;
308+ int n ;
309+
310+ n = k_heap_array_get (& ha );
311+ zassert_not_equal (0 , n , "No heaps returned" );
312+ zassert_not_null (ha , "Heap array pointer not populated" );
313+
314+ /* Ensure that k_heap_test exists in the array */
315+ for (int i = 0 ; i < n ; i ++ ) {
316+ if (& k_heap_test == & ha [i ]) {
317+ test_heap_found = true;
318+ }
319+ }
320+ zassert_true (test_heap_found );
321+ }
You can’t perform that action at this time.
0 commit comments