aboutsummaryrefslogtreecommitdiffstats
path: root/test/rt
diff options
context:
space:
mode:
authorGiovanni Di Sirio <gdisirio@gmail.com>2016-04-17 14:47:52 +0000
committerGiovanni Di Sirio <gdisirio@gmail.com>2016-04-17 14:47:52 +0000
commitf7ef558614b90137f78dd1ddfeb0638bdd04dd32 (patch)
treeeb7b305a0658d5d56d71ac69a1e242f78ab9aa29 /test/rt
parent30f7b5e8681da7b2ea8fb03209b7cb6cdad24f4b (diff)
downloadChibiOS-f7ef558614b90137f78dd1ddfeb0638bdd04dd32.tar.gz
ChibiOS-f7ef558614b90137f78dd1ddfeb0638bdd04dd32.tar.bz2
ChibiOS-f7ef558614b90137f78dd1ddfeb0638bdd04dd32.zip
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@9309 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'test/rt')
-rw-r--r--test/rt/configuration.xml40
-rw-r--r--test/rt/source/test/test_root.c12
-rw-r--r--test/rt/source/test/test_root.h19
-rw-r--r--test/rt/source/test/test_sequence_010.c7
-rw-r--r--test/rt/source/test/test_sequence_011.c2
5 files changed, 28 insertions, 52 deletions
diff --git a/test/rt/configuration.xml b/test/rt/configuration.xml
index f934d120d..4289ef051 100644
--- a/test/rt/configuration.xml
+++ b/test/rt/configuration.xml
@@ -60,23 +60,10 @@
/*
* Working Area size of test threads.
*/
-#define WA_SIZE THD_WORKING_AREA_SIZE(THREADS_STACK_SIZE)
+#define WA_SIZE MEM_ALIGN_NEXT(THD_WORKING_AREA_SIZE(THREADS_STACK_SIZE), \
+ PORT_WORKING_AREA_ALIGN)
-/*
- * Union of all Working Areas, usable as a single large buffer if required.
- */
-union test_buffers {
- struct {
- THD_WORKING_AREA(T0, THREADS_STACK_SIZE);
- THD_WORKING_AREA(T1, THREADS_STACK_SIZE);
- THD_WORKING_AREA(T2, THREADS_STACK_SIZE);
- THD_WORKING_AREA(T3, THREADS_STACK_SIZE);
- THD_WORKING_AREA(T4, THREADS_STACK_SIZE);
- } wa;
- uint8_t buffer[WA_SIZE * 5];
-};
-
-extern union test_buffers test;
+extern uint8_t test_buffer[WA_SIZE * 5];
extern thread_t *threads[MAX_THREADS];
extern void * ROMCONST wa[5];
@@ -86,10 +73,9 @@ systime_t test_wait_tick(void);]]></value>
</global_definitions>
<global_code>
<value><![CDATA[/*
- * Static working areas, the following areas can be used for threads or
- * used as temporary buffers.
+ * Global test buffer holding 5 working areas.
*/
-union test_buffers test;
+ALIGNED_VAR(PORT_WORKING_AREA_ALIGN) uint8_t test_buffer[WA_SIZE * 5];
/*
* Pointers to the spawned threads.
@@ -99,8 +85,11 @@ thread_t *threads[MAX_THREADS];
/*
* Pointers to the working areas.
*/
-void * ROMCONST wa[5] = {test.wa.T0, test.wa.T1, test.wa.T2,
- test.wa.T3, test.wa.T4};
+void * ROMCONST wa[5] = {test_buffer + (WA_SIZE * 0),
+ test_buffer + (WA_SIZE * 1),
+ test_buffer + (WA_SIZE * 2),
+ test_buffer + (WA_SIZE * 3),
+ test_buffer + (WA_SIZE * 4)};
/*
* Sets a termination request in all the test-spawned threads.
@@ -3575,8 +3564,7 @@ test_assert(chPoolAlloc(&mp1) == NULL, "provider returned memory");]]></value>
<value><![CDATA[#define ALLOC_SIZE 16
#define HEAP_SIZE (ALLOC_SIZE * 8)
-static memory_heap_t test_heap;
-static CH_HEAP_AREA(myheap, HEAP_SIZE);]]></value>
+memory_heap_t test_heap;]]></value>
</shared_code>
<cases>
<case>
@@ -3591,7 +3579,7 @@ static CH_HEAP_AREA(myheap, HEAP_SIZE);]]></value>
</condition>
<various_code>
<setup_code>
- <value><![CDATA[chHeapObjectInit(&test_heap, myheap, sizeof(myheap));]]></value>
+ <value><![CDATA[chHeapObjectInit(&test_heap, test_buffer, sizeof(test_buffer));]]></value>
</setup_code>
<teardown_code>
<value />
@@ -3621,7 +3609,7 @@ size_t n, sz;]]></value>
<value />
</tags>
<code>
- <value><![CDATA[p1 = chHeapAlloc(&test_heap, HEAP_SIZE * 2);
+ <value><![CDATA[p1 = chHeapAlloc(&test_heap, sizeof test_buffer * 2);
test_assert(p1 == NULL, "allocation not failed");]]></value>
</code>
</step>
@@ -3850,7 +3838,7 @@ The test expects the first two threads to successfully start and the third one t
</condition>
<various_code>
<setup_code>
- <value><![CDATA[chHeapObjectInit(&heap1, test.buffer, sizeof(union test_buffers));]]></value>
+ <value><![CDATA[chHeapObjectInit(&heap1, test_buffer, sizeof test_buffer);]]></value>
</setup_code>
<teardown_code>
<value />
diff --git a/test/rt/source/test/test_root.c b/test/rt/source/test/test_root.c
index 76aeb05ec..5754813ac 100644
--- a/test/rt/source/test/test_root.c
+++ b/test/rt/source/test/test_root.c
@@ -91,10 +91,9 @@ const testcase_t * const *test_suite[] = {
/*===========================================================================*/
/*
- * Static working areas, the following areas can be used for threads or
- * used as temporary buffers.
+ * Global test buffer holding 5 working areas.
*/
-union test_buffers test;
+ALIGNED_VAR(PORT_WORKING_AREA_ALIGN) uint8_t test_buffer[WA_SIZE * 5];
/*
* Pointers to the spawned threads.
@@ -104,8 +103,11 @@ thread_t *threads[MAX_THREADS];
/*
* Pointers to the working areas.
*/
-void * ROMCONST wa[5] = {test.wa.T0, test.wa.T1, test.wa.T2,
- test.wa.T3, test.wa.T4};
+void * ROMCONST wa[5] = {test_buffer + (WA_SIZE * 0),
+ test_buffer + (WA_SIZE * 1),
+ test_buffer + (WA_SIZE * 2),
+ test_buffer + (WA_SIZE * 3),
+ test_buffer + (WA_SIZE * 4)};
/*
* Sets a termination request in all the test-spawned threads.
diff --git a/test/rt/source/test/test_root.h b/test/rt/source/test/test_root.h
index e2fdb37f3..4fdc5ec57 100644
--- a/test/rt/source/test/test_root.h
+++ b/test/rt/source/test/test_root.h
@@ -82,23 +82,10 @@ extern "C" {
/*
* Working Area size of test threads.
*/
-#define WA_SIZE THD_WORKING_AREA_SIZE(THREADS_STACK_SIZE)
+#define WA_SIZE MEM_ALIGN_NEXT(THD_WORKING_AREA_SIZE(THREADS_STACK_SIZE), \
+ PORT_WORKING_AREA_ALIGN)
-/*
- * Union of all Working Areas, usable as a single large buffer if required.
- */
-union test_buffers {
- struct {
- THD_WORKING_AREA(T0, THREADS_STACK_SIZE);
- THD_WORKING_AREA(T1, THREADS_STACK_SIZE);
- THD_WORKING_AREA(T2, THREADS_STACK_SIZE);
- THD_WORKING_AREA(T3, THREADS_STACK_SIZE);
- THD_WORKING_AREA(T4, THREADS_STACK_SIZE);
- } wa;
- uint8_t buffer[WA_SIZE * 5];
-};
-
-extern union test_buffers test;
+extern uint8_t test_buffer[WA_SIZE * 5];
extern thread_t *threads[MAX_THREADS];
extern void * ROMCONST wa[5];
diff --git a/test/rt/source/test/test_sequence_010.c b/test/rt/source/test/test_sequence_010.c
index c4328f7f1..480021eb6 100644
--- a/test/rt/source/test/test_sequence_010.c
+++ b/test/rt/source/test/test_sequence_010.c
@@ -51,8 +51,7 @@
#define ALLOC_SIZE 16
#define HEAP_SIZE (ALLOC_SIZE * 8)
-static memory_heap_t test_heap;
-static CH_HEAP_AREA(myheap, HEAP_SIZE);
+memory_heap_t test_heap;
/****************************************************************************
* Test cases.
@@ -89,7 +88,7 @@ static CH_HEAP_AREA(myheap, HEAP_SIZE);
*/
static void test_010_001_setup(void) {
- chHeapObjectInit(&test_heap, myheap, sizeof(myheap));
+ chHeapObjectInit(&test_heap, test_buffer, sizeof(test_buffer));
}
static void test_010_001_execute(void) {
@@ -107,7 +106,7 @@ static void test_010_001_execute(void) {
an error is expected.*/
test_set_step(2);
{
- p1 = chHeapAlloc(&test_heap, HEAP_SIZE * 2);
+ p1 = chHeapAlloc(&test_heap, sizeof test_buffer * 2);
test_assert(p1 == NULL, "allocation not failed");
}
diff --git a/test/rt/source/test/test_sequence_011.c b/test/rt/source/test/test_sequence_011.c
index 71d27433b..14ac5c051 100644
--- a/test/rt/source/test/test_sequence_011.c
+++ b/test/rt/source/test/test_sequence_011.c
@@ -93,7 +93,7 @@ static THD_FUNCTION(dyn_thread1, p) {
*/
static void test_011_001_setup(void) {
- chHeapObjectInit(&heap1, test.buffer, sizeof(union test_buffers));
+ chHeapObjectInit(&heap1, test_buffer, sizeof test_buffer);
}
static void test_011_001_execute(void) {