aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGiovanni Di Sirio <gdisirio@gmail.com>2016-03-18 09:21:32 +0000
committerGiovanni Di Sirio <gdisirio@gmail.com>2016-03-18 09:21:32 +0000
commit3a48ef2df6ad7864e55c6b32f5450ea3d28d0943 (patch)
tree49609d37d07545655ceb6962456b5deeaa0e9870
parentcc04b48370602f941a752308bf3a6819170292cc (diff)
downloadChibiOS-3a48ef2df6ad7864e55c6b32f5450ea3d28d0943.tar.gz
ChibiOS-3a48ef2df6ad7864e55c6b32f5450ea3d28d0943.tar.bz2
ChibiOS-3a48ef2df6ad7864e55c6b32f5450ea3d28d0943.zip
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@9133 35acf78f-673a-0410-8e92-d51de3d6d3f4
-rw-r--r--demos/STM32/NIL-STM32F746G-DISCOVERY/debug/NIL-STM32F746G-DISCOVERY (OpenOCD, Flash and Run).launch2
-rw-r--r--test/nil/configuration.xml132
-rw-r--r--test/nil/source/test/test_root.c2
-rw-r--r--test/nil/source/test/test_root.h1
-rw-r--r--test/nil/source/test/test_sequence_005.c147
-rw-r--r--test/nil/source/test/test_sequence_005.h17
-rw-r--r--test/nil/test.mk3
7 files changed, 302 insertions, 2 deletions
diff --git a/demos/STM32/NIL-STM32F746G-DISCOVERY/debug/NIL-STM32F746G-DISCOVERY (OpenOCD, Flash and Run).launch b/demos/STM32/NIL-STM32F746G-DISCOVERY/debug/NIL-STM32F746G-DISCOVERY (OpenOCD, Flash and Run).launch
index a3e804ff4..6068cf8e3 100644
--- a/demos/STM32/NIL-STM32F746G-DISCOVERY/debug/NIL-STM32F746G-DISCOVERY (OpenOCD, Flash and Run).launch
+++ b/demos/STM32/NIL-STM32F746G-DISCOVERY/debug/NIL-STM32F746G-DISCOVERY (OpenOCD, Flash and Run).launch
@@ -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="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&lt;contentList&gt;&lt;content id=&quot;r0-(format)&quot; val=&quot;4&quot;/&gt;&lt;content id=&quot;r1-(format)&quot; val=&quot;4&quot;/&gt;&lt;/contentList&gt;"/>
+<stringAttribute key="org.eclipse.cdt.launch.FORMAT" value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&lt;contentList&gt;&lt;content id=&quot;r1-(format)&quot; val=&quot;4&quot;/&gt;&lt;content id=&quot;r0-(format)&quot; val=&quot;4&quot;/&gt;&lt;/contentList&gt;"/>
<stringAttribute key="org.eclipse.cdt.launch.GLOBAL_VARIABLES" value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;globalVariableList/&gt;&#13;&#10;"/>
<stringAttribute key="org.eclipse.cdt.launch.MEMORY_BLOCKS" value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;memoryBlockExpressionList/&gt;&#13;&#10;"/>
<stringAttribute key="org.eclipse.cdt.launch.PROGRAM_NAME" value="./build/ch.elf"/>
diff --git a/test/nil/configuration.xml b/test/nil/configuration.xml
index e5a2fd8b6..7488bf61f 100644
--- a/test/nil/configuration.xml
+++ b/test/nil/configuration.xml
@@ -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>
diff --git a/test/nil/source/test/test_root.c b/test/nil/source/test/test_root.c
index 1d42a6d44..1516898c5 100644
--- a/test/nil/source/test/test_root.c
+++ b/test/nil/source/test/test_root.c
@@ -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
};
diff --git a/test/nil/source/test/test_root.h b/test/nil/source/test/test_root.h
index 10daddeef..ee0c42d0b 100644
--- a/test/nil/source/test/test_root.h
+++ b/test/nil/source/test/test_root.h
@@ -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. */
diff --git a/test/nil/source/test/test_sequence_005.c b/test/nil/source/test/test_sequence_005.c
new file mode 100644
index 000000000..546cc9664
--- /dev/null
+++ b/test/nil/source/test/test_sequence_005.c
@@ -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
+};
diff --git a/test/nil/source/test/test_sequence_005.h b/test/nil/source/test/test_sequence_005.h
new file mode 100644
index 000000000..4cb8e1db0
--- /dev/null
+++ b/test/nil/source/test/test_sequence_005.h
@@ -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[];
diff --git a/test/nil/test.mk b/test/nil/test.mk
index 2fc7b8b9e..04890b633 100644
--- a/test/nil/test.mk
+++ b/test/nil/test.mk
@@ -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 \