From 7abee7168a90b07f3746779e338b4523d48724b0 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Mon, 9 Apr 2012 13:13:25 +0000 Subject: Added new function chPoolLoadArray(). git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@4088 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- test/testpools.c | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) (limited to 'test/testpools.c') diff --git a/test/testpools.c b/test/testpools.c index 1c864d973..2583170fd 100644 --- a/test/testpools.c +++ b/test/testpools.c @@ -75,20 +75,30 @@ static void pools1_setup(void) { static void pools1_execute(void) { int i; - /* Adding the WAs to the pool. */ - for (i = 0; i < MAX_THREADS; i++) - chPoolFree(&mp1, wa[i]); + /* Adding the WAs to the pool.*/ + chPoolLoadArray(&mp1, wa[0], MAX_THREADS); - /* Empting the pool again. */ + /* Emptying the pool.*/ for (i = 0; i < MAX_THREADS; i++) test_assert(1, chPoolAlloc(&mp1) != NULL, "list empty"); - /* Now must be empty. */ + /* Now must be empty.*/ test_assert(2, chPoolAlloc(&mp1) == NULL, "list not empty"); + /* Adding the WAs to the pool, one by one this time.*/ + for (i = 0; i < MAX_THREADS; i++) + chPoolFree(&mp1, wa[i]); + + /* Emptying the pool again.*/ + for (i = 0; i < MAX_THREADS; i++) + test_assert(3, chPoolAlloc(&mp1) != NULL, "list empty"); + + /* Now must be empty again.*/ + test_assert(4, chPoolAlloc(&mp1) == NULL, "list not empty"); + /* Covering the case where a provider is unable to return more memory.*/ chPoolInit(&mp1, 16, null_provider); - test_assert(3, chPoolAlloc(&mp1) == NULL, "provider returned memory"); + test_assert(5, chPoolAlloc(&mp1) == NULL, "provider returned memory"); } ROMCONST struct testcase testpools1 = { -- cgit v1.2.3