git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@9133 35acf78f-673a-0410-8e92-d51de3d6d3f4
This commit is contained in:
parent
cc04b48370
commit
3a48ef2df6
|
@ -33,7 +33,7 @@
|
|||
<intAttribute key="org.eclipse.cdt.launch.ATTR_BUILD_BEFORE_LAUNCH_ATTR" value="2"/>
|
||||
<stringAttribute key="org.eclipse.cdt.launch.COREFILE_PATH" value=""/>
|
||||
<stringAttribute key="org.eclipse.cdt.launch.DEBUGGER_REGISTER_GROUPS" value=""/>
|
||||
<stringAttribute key="org.eclipse.cdt.launch.FORMAT" value="<?xml version="1.0" encoding="UTF-8" standalone="no"?><contentList><content id="r0-(format)" val="4"/><content id="r1-(format)" val="4"/></contentList>"/>
|
||||
<stringAttribute key="org.eclipse.cdt.launch.FORMAT" value="<?xml version="1.0" encoding="UTF-8" standalone="no"?><contentList><content id="r1-(format)" val="4"/><content id="r0-(format)" val="4"/></contentList>"/>
|
||||
<stringAttribute key="org.eclipse.cdt.launch.GLOBAL_VARIABLES" value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <globalVariableList/> "/>
|
||||
<stringAttribute key="org.eclipse.cdt.launch.MEMORY_BLOCKS" value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <memoryBlockExpressionList/> "/>
|
||||
<stringAttribute key="org.eclipse.cdt.launch.PROGRAM_NAME" value="./build/ch.elf"/>
|
||||
|
|
|
@ -916,6 +916,138 @@ test_assert(msg1 == MSG_TIMEOUT, "wrong wake-up message");]]></value>
|
|||
</case>
|
||||
</cases>
|
||||
</sequence>
|
||||
<sequence>
|
||||
<type index="0">
|
||||
<value>Internal Tests</value>
|
||||
</type>
|
||||
<brief>
|
||||
<value>Memory Pools.</value>
|
||||
</brief>
|
||||
<description>
|
||||
<value>This sequence tests the ChibiOS/NIL functionalities related to memory pools.</value>
|
||||
</description>
|
||||
<shared_code>
|
||||
<value><![CDATA[#define MEMORY_POOL_SIZE 4
|
||||
|
||||
static uint32_t objects[MEMORY_POOL_SIZE];
|
||||
static MEMORYPOOL_DECL(mp1, sizeof (uint32_t), NULL);
|
||||
|
||||
static void *null_provider(size_t size, unsigned align) {
|
||||
|
||||
(void)size;
|
||||
(void)align;
|
||||
|
||||
return NULL;
|
||||
}]]></value>
|
||||
</shared_code>
|
||||
<cases>
|
||||
<case>
|
||||
<brief>
|
||||
<value>Loading and empting the memory pool.</value>
|
||||
</brief>
|
||||
<description>
|
||||
<value>The memory pool functionality is tested by loading and empting it, all conditions are tested.</value>
|
||||
</description>
|
||||
<condition>
|
||||
<value />
|
||||
</condition>
|
||||
<various_code>
|
||||
<setup_code>
|
||||
<value><![CDATA[chPoolObjectInit(&mp1, sizeof (uint32_t), NULL);]]></value>
|
||||
</setup_code>
|
||||
<teardown_code>
|
||||
<value />
|
||||
</teardown_code>
|
||||
<local_variables>
|
||||
<value><![CDATA[unsigned i;]]></value>
|
||||
</local_variables>
|
||||
</various_code>
|
||||
<steps>
|
||||
<step>
|
||||
<description>
|
||||
<value>Adding the objects to the pool using chPoolLoadArray().</value>
|
||||
</description>
|
||||
<tags>
|
||||
<value />
|
||||
</tags>
|
||||
<code>
|
||||
<value><![CDATA[chPoolLoadArray(&mp1, objects, MEMORY_POOL_SIZE);]]></value>
|
||||
</code>
|
||||
</step>
|
||||
<step>
|
||||
<description>
|
||||
<value>Emptying the pool using chPoolAlloc().</value>
|
||||
</description>
|
||||
<tags>
|
||||
<value />
|
||||
</tags>
|
||||
<code>
|
||||
<value><![CDATA[for (i = 0; i < MEMORY_POOL_SIZE; i++)
|
||||
test_assert(chPoolAlloc(&mp1) != NULL, "list empty");]]></value>
|
||||
</code>
|
||||
</step>
|
||||
<step>
|
||||
<description>
|
||||
<value>Now must be empty.</value>
|
||||
</description>
|
||||
<tags>
|
||||
<value />
|
||||
</tags>
|
||||
<code>
|
||||
<value><![CDATA[test_assert(chPoolAlloc(&mp1) == NULL, "list not empty");]]></value>
|
||||
</code>
|
||||
</step>
|
||||
<step>
|
||||
<description>
|
||||
<value>Adding the objects to the pool using chPoolFree().</value>
|
||||
</description>
|
||||
<tags>
|
||||
<value />
|
||||
</tags>
|
||||
<code>
|
||||
<value><![CDATA[for (i = 0; i < MEMORY_POOL_SIZE; i++)
|
||||
chPoolFree(&mp1, &objects[i]);]]></value>
|
||||
</code>
|
||||
</step>
|
||||
<step>
|
||||
<description>
|
||||
<value>Emptying the pool using chPoolAlloc() again.</value>
|
||||
</description>
|
||||
<tags>
|
||||
<value />
|
||||
</tags>
|
||||
<code>
|
||||
<value><![CDATA[for (i = 0; i < MEMORY_POOL_SIZE; i++)
|
||||
test_assert(chPoolAlloc(&mp1) != NULL, "list empty");]]></value>
|
||||
</code>
|
||||
</step>
|
||||
<step>
|
||||
<description>
|
||||
<value>Now must be empty again.</value>
|
||||
</description>
|
||||
<tags>
|
||||
<value />
|
||||
</tags>
|
||||
<code>
|
||||
<value><![CDATA[test_assert(chPoolAlloc(&mp1) == NULL, "list not empty");]]></value>
|
||||
</code>
|
||||
</step>
|
||||
<step>
|
||||
<description>
|
||||
<value>Covering the case where a provider is unable to return more memory.</value>
|
||||
</description>
|
||||
<tags>
|
||||
<value />
|
||||
</tags>
|
||||
<code>
|
||||
<value><![CDATA[chPoolObjectInit(&mp1, sizeof (uint32_t), null_provider);
|
||||
test_assert(chPoolAlloc(&mp1) == NULL, "provider returned memory");]]></value>
|
||||
</code>
|
||||
</step>
|
||||
</steps>
|
||||
</case>
|
||||
</cases>
|
||||
</sequence>
|
||||
</sequences>
|
||||
</instance>
|
||||
</instances>
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
* - @subpage test_sequence_002
|
||||
* - @subpage test_sequence_003
|
||||
* - @subpage test_sequence_004
|
||||
* - @subpage test_sequence_005
|
||||
* .
|
||||
*/
|
||||
|
||||
|
@ -52,6 +53,7 @@ const testcase_t * const *test_suite[] = {
|
|||
test_sequence_002,
|
||||
test_sequence_003,
|
||||
test_sequence_004,
|
||||
test_sequence_005,
|
||||
NULL
|
||||
};
|
||||
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
#include "test_sequence_002.h"
|
||||
#include "test_sequence_003.h"
|
||||
#include "test_sequence_004.h"
|
||||
#include "test_sequence_005.h"
|
||||
|
||||
/*===========================================================================*/
|
||||
/* External declarations. */
|
||||
|
|
|
@ -0,0 +1,147 @@
|
|||
/*
|
||||
ChibiOS - Copyright (C) 2006..2015 Giovanni Di Sirio
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
#include "hal.h"
|
||||
#include "ch_test.h"
|
||||
#include "test_root.h"
|
||||
|
||||
/**
|
||||
* @page test_sequence_005 Memory Pools
|
||||
*
|
||||
* File: @ref test_sequence_005.c
|
||||
*
|
||||
* <h2>Description</h2>
|
||||
* This sequence tests the ChibiOS/NIL functionalities related to
|
||||
* memory pools.
|
||||
*
|
||||
* <h2>Test Cases</h2>
|
||||
* - @subpage test_005_001
|
||||
* .
|
||||
*/
|
||||
|
||||
/****************************************************************************
|
||||
* Shared code.
|
||||
****************************************************************************/
|
||||
|
||||
#define MEMORY_POOL_SIZE 4
|
||||
|
||||
static uint32_t objects[MEMORY_POOL_SIZE];
|
||||
static MEMORYPOOL_DECL(mp1, sizeof (uint32_t), NULL);
|
||||
|
||||
static void *null_provider(size_t size, unsigned align) {
|
||||
|
||||
(void)size;
|
||||
(void)align;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Test cases.
|
||||
****************************************************************************/
|
||||
|
||||
/**
|
||||
* @page test_005_001 Loading and empting the memory pool
|
||||
*
|
||||
* <h2>Description</h2>
|
||||
* The memory pool functionality is tested by loading and empting it,
|
||||
* all conditions are tested.
|
||||
*
|
||||
* <h2>Test Steps</h2>
|
||||
* - Adding the objects to the pool using chPoolLoadArray().
|
||||
* - Emptying the pool using chPoolAlloc().
|
||||
* - Now must be empty.
|
||||
* - Adding the objects to the pool using chPoolFree().
|
||||
* - Emptying the pool using chPoolAlloc() again.
|
||||
* - Now must be empty again.
|
||||
* - Covering the case where a provider is unable to return more
|
||||
* memory.
|
||||
* .
|
||||
*/
|
||||
|
||||
static void test_005_001_setup(void) {
|
||||
chPoolObjectInit(&mp1, sizeof (uint32_t), NULL);
|
||||
}
|
||||
|
||||
static void test_005_001_execute(void) {
|
||||
unsigned i;
|
||||
|
||||
/* Adding the objects to the pool using chPoolLoadArray().*/
|
||||
test_set_step(1);
|
||||
{
|
||||
chPoolLoadArray(&mp1, objects, MEMORY_POOL_SIZE);
|
||||
}
|
||||
|
||||
/* Emptying the pool using chPoolAlloc().*/
|
||||
test_set_step(2);
|
||||
{
|
||||
for (i = 0; i < MEMORY_POOL_SIZE; i++)
|
||||
test_assert(chPoolAlloc(&mp1) != NULL, "list empty");
|
||||
}
|
||||
|
||||
/* Now must be empty.*/
|
||||
test_set_step(3);
|
||||
{
|
||||
test_assert(chPoolAlloc(&mp1) == NULL, "list not empty");
|
||||
}
|
||||
|
||||
/* Adding the objects to the pool using chPoolFree().*/
|
||||
test_set_step(4);
|
||||
{
|
||||
for (i = 0; i < MEMORY_POOL_SIZE; i++)
|
||||
chPoolFree(&mp1, &objects[i]);
|
||||
}
|
||||
|
||||
/* Emptying the pool using chPoolAlloc() again.*/
|
||||
test_set_step(5);
|
||||
{
|
||||
for (i = 0; i < MEMORY_POOL_SIZE; i++)
|
||||
test_assert(chPoolAlloc(&mp1) != NULL, "list empty");
|
||||
}
|
||||
|
||||
/* Now must be empty again.*/
|
||||
test_set_step(6);
|
||||
{
|
||||
test_assert(chPoolAlloc(&mp1) == NULL, "list not empty");
|
||||
}
|
||||
|
||||
/* Covering the case where a provider is unable to return more
|
||||
memory.*/
|
||||
test_set_step(7);
|
||||
{
|
||||
chPoolObjectInit(&mp1, sizeof (uint32_t), null_provider);
|
||||
test_assert(chPoolAlloc(&mp1) == NULL, "provider returned memory");
|
||||
}
|
||||
}
|
||||
|
||||
static const testcase_t test_005_001 = {
|
||||
"Loading and empting the memory pool",
|
||||
test_005_001_setup,
|
||||
NULL,
|
||||
test_005_001_execute
|
||||
};
|
||||
|
||||
/****************************************************************************
|
||||
* Exported data.
|
||||
****************************************************************************/
|
||||
|
||||
/**
|
||||
* @brief Memory Pools.
|
||||
*/
|
||||
const testcase_t * const test_sequence_005[] = {
|
||||
&test_005_001,
|
||||
NULL
|
||||
};
|
|
@ -0,0 +1,17 @@
|
|||
/*
|
||||
ChibiOS - Copyright (C) 2006..2015 Giovanni Di Sirio
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
extern const testcase_t * const test_sequence_005[];
|
|
@ -4,7 +4,8 @@ TESTSRC = ${CHIBIOS}/test/lib/ch_test.c \
|
|||
${CHIBIOS}/test/nil/source/test/test_sequence_001.c \
|
||||
${CHIBIOS}/test/nil/source/test/test_sequence_002.c \
|
||||
${CHIBIOS}/test/nil/source/test/test_sequence_003.c \
|
||||
${CHIBIOS}/test/nil/source/test/test_sequence_004.c
|
||||
${CHIBIOS}/test/nil/source/test/test_sequence_004.c \
|
||||
${CHIBIOS}/test/nil/source/test/test_sequence_005.c
|
||||
|
||||
# Required include directories
|
||||
TESTINC = ${CHIBIOS}/test/lib \
|
||||
|
|
Loading…
Reference in New Issue