aboutsummaryrefslogtreecommitdiffstats
path: root/test/nasa_osal
diff options
context:
space:
mode:
authorGiovanni Di Sirio <gdisirio@gmail.com>2016-03-06 12:12:41 +0000
committerGiovanni Di Sirio <gdisirio@gmail.com>2016-03-06 12:12:41 +0000
commit867f0576194c8cb09a8ce8e8eafe9690e7fedaec (patch)
tree46c3803ec766c78197ab937efed5b5c74a95ecb2 /test/nasa_osal
parentfcbab787e69a4dec8285df9dbdc83bc876d0b141 (diff)
downloadChibiOS-867f0576194c8cb09a8ce8e8eafe9690e7fedaec.tar.gz
ChibiOS-867f0576194c8cb09a8ce8e8eafe9690e7fedaec.tar.bz2
ChibiOS-867f0576194c8cb09a8ce8e8eafe9690e7fedaec.zip
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@9036 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'test/nasa_osal')
-rw-r--r--test/nasa_osal/configuration.xml204
-rw-r--r--test/nasa_osal/source/test/test_sequence_001.c188
2 files changed, 391 insertions, 1 deletions
diff --git a/test/nasa_osal/configuration.xml b/test/nasa_osal/configuration.xml
index 4f89b0e1b..8d236c555 100644
--- a/test/nasa_osal/configuration.xml
+++ b/test/nasa_osal/configuration.xml
@@ -286,6 +286,210 @@ test_assert_sequence("A", "task not executed");]]></value>
</step>
</steps>
</case>
+ <case>
+ <brief>
+ <value>OS_TaskCreate() priority ordering</value>
+ </brief>
+ <description>
+ <value>Four tasks are created at different priorities and in different order. The execution order must happen in order of priority regardless the creation order.</value>
+ </description>
+ <condition>
+ <value />
+ </condition>
+ <various_code>
+ <setup_code>
+ <value />
+ </setup_code>
+ <teardown_code>
+ <value />
+ </teardown_code>
+ <local_variables>
+ <value />
+ </local_variables>
+ </various_code>
+ <steps>
+ <step>
+ <description>
+ <value>Four tasks are created in priority order from low to high.</value>
+ </description>
+ <tags>
+ <value />
+ </tags>
+ <code>
+ <value><![CDATA[int32 err;
+uint32 tid1, tid2, tid3, tid4;
+
+err = OS_TaskCreate(&tid4,
+ "running thread 4",
+ test_thread4,
+ (uint32 *)wa_test4,
+ sizeof wa_test4,
+ TASKS_BASE_PRIORITY - 0,
+ 0);
+test_assert(err == OS_SUCCESS, "task 4 creation failed");
+
+err = OS_TaskCreate(&tid3,
+ "running thread 3",
+ test_thread3,
+ (uint32 *)wa_test3,
+ sizeof wa_test3,
+ TASKS_BASE_PRIORITY - 1,
+ 0);
+test_assert(err == OS_SUCCESS, "task 3 creation failed");
+
+err = OS_TaskCreate(&tid2,
+ "running thread 2",
+ test_thread2,
+ (uint32 *)wa_test2,
+ sizeof wa_test2,
+ TASKS_BASE_PRIORITY - 2,
+ 0);
+test_assert(err == OS_SUCCESS, "task 2 creation failed");
+
+err = OS_TaskCreate(&tid1,
+ "running thread 1",
+ test_thread1,
+ (uint32 *)wa_test1,
+ sizeof wa_test1,
+ TASKS_BASE_PRIORITY - 3,
+ 0);
+test_assert(err == OS_SUCCESS, "task 1 creation failed");]]></value>
+ </code>
+ </step>
+ <step>
+ <description>
+ <value>Tasks are made runnable atomically and their execution order tested.</value>
+ </description>
+ <tags>
+ <value />
+ </tags>
+ <code>
+ <value><![CDATA[OS_TaskDelay(5);
+test_assert_sequence("ABCD", "task order violation");]]></value>
+ </code>
+ </step>
+ <step>
+ <description>
+ <value>Four tasks are created in priority order from high to low.</value>
+ </description>
+ <tags>
+ <value />
+ </tags>
+ <code>
+ <value><![CDATA[int32 err;
+uint32 tid1, tid2, tid3, tid4;
+
+err = OS_TaskCreate(&tid1,
+ "running thread 1",
+ test_thread1,
+ (uint32 *)wa_test1,
+ sizeof wa_test1,
+ TASKS_BASE_PRIORITY - 3,
+ 0);
+test_assert(err == OS_SUCCESS, "task 1 creation failed");
+
+err = OS_TaskCreate(&tid2,
+ "running thread 2",
+ test_thread2,
+ (uint32 *)wa_test2,
+ sizeof wa_test2,
+ TASKS_BASE_PRIORITY - 2,
+ 0);
+test_assert(err == OS_SUCCESS, "task 2 creation failed");
+
+err = OS_TaskCreate(&tid3,
+ "running thread 3",
+ test_thread3,
+ (uint32 *)wa_test3,
+ sizeof wa_test3,
+ TASKS_BASE_PRIORITY - 1,
+ 0);
+test_assert(err == OS_SUCCESS, "task 3 creation failed");
+
+err = OS_TaskCreate(&tid4,
+ "running thread 4",
+ test_thread4,
+ (uint32 *)wa_test4,
+ sizeof wa_test4,
+ TASKS_BASE_PRIORITY - 0,
+ 0);
+test_assert(err == OS_SUCCESS, "task 4 creation failed");]]></value>
+ </code>
+ </step>
+ <step>
+ <description>
+ <value>Tasks are made runnable atomically and their execution order tested.</value>
+ </description>
+ <tags>
+ <value />
+ </tags>
+ <code>
+ <value><![CDATA[OS_TaskDelay(5);
+test_assert_sequence("ABCD", "task order violation");]]></value>
+ </code>
+ </step>
+ <step>
+ <description>
+ <value>Four tasks are created in an not ordered way.</value>
+ </description>
+ <tags>
+ <value />
+ </tags>
+ <code>
+ <value><![CDATA[int32 err;
+uint32 tid1, tid2, tid3, tid4;
+
+err = OS_TaskCreate(&tid2,
+ "running thread 2",
+ test_thread2,
+ (uint32 *)wa_test2,
+ sizeof wa_test2,
+ TASKS_BASE_PRIORITY - 2,
+ 0);
+test_assert(err == OS_SUCCESS, "task 2 creation failed");
+
+err = OS_TaskCreate(&tid1,
+ "running thread 1",
+ test_thread1,
+ (uint32 *)wa_test1,
+ sizeof wa_test1,
+ TASKS_BASE_PRIORITY - 3,
+ 0);
+test_assert(err == OS_SUCCESS, "task 1 creation failed");
+
+err = OS_TaskCreate(&tid4,
+ "running thread 4",
+ test_thread4,
+ (uint32 *)wa_test4,
+ sizeof wa_test4,
+ TASKS_BASE_PRIORITY - 0,
+ 0);
+test_assert(err == OS_SUCCESS, "task 4 creation failed");
+
+err = OS_TaskCreate(&tid3,
+ "running thread 3",
+ test_thread3,
+ (uint32 *)wa_test3,
+ sizeof wa_test3,
+ TASKS_BASE_PRIORITY - 1,
+ 0);
+test_assert(err == OS_SUCCESS, "task 3 creation failed");]]></value>
+ </code>
+ </step>
+ <step>
+ <description>
+ <value>Tasks are made runnable atomically and their execution order tested.</value>
+ </description>
+ <tags>
+ <value />
+ </tags>
+ <code>
+ <value><![CDATA[OS_TaskDelay(5);
+test_assert_sequence("ABCD", "task order violation");]]></value>
+ </code>
+ </step>
+ </steps>
+ </case>
</cases>
</sequence>
</sequences>
diff --git a/test/nasa_osal/source/test/test_sequence_001.c b/test/nasa_osal/source/test/test_sequence_001.c
index 871a07f83..7c173021e 100644
--- a/test/nasa_osal/source/test/test_sequence_001.c
+++ b/test/nasa_osal/source/test/test_sequence_001.c
@@ -29,6 +29,7 @@
*
* <h2>Test Cases</h2>
* - @subpage test_001_001
+ * - @subpage test_001_002
* .
*/
@@ -36,7 +37,7 @@
* Shared code.
****************************************************************************/
-#include "osapi.H"
+#include "osapi.h"
static void test_thread1(void) {
@@ -263,6 +264,190 @@ static const testcase_t test_001_001 = {
test_001_001_execute
};
+/**
+ * @page test_001_002 OS_TaskCreate() priority ordering
+ *
+ * <h2>Description</h2>
+ * Four tasks are created at different priorities and in different
+ * order. The execution order must happen in order of priority
+ * regardless the creation order.
+ *
+ * <h2>Test Steps</h2>
+ * - Four tasks are created in priority order from low to high.
+ * - Tasks are made runnable atomically and their execution order
+ * tested.
+ * - Four tasks are created in priority order from high to low.
+ * - Tasks are made runnable atomically and their execution order
+ * tested.
+ * - Four tasks are created in an not ordered way.
+ * - Tasks are made runnable atomically and their execution order
+ * tested.
+ * .
+ */
+
+static void test_001_002_execute(void) {
+
+ /* Four tasks are created in priority order from low to high.*/
+ test_set_step(1);
+ {
+ int32 err;
+ uint32 tid1, tid2, tid3, tid4;
+
+ err = OS_TaskCreate(&tid4,
+ "running thread 4",
+ test_thread4,
+ (uint32 *)wa_test4,
+ sizeof wa_test4,
+ TASKS_BASE_PRIORITY - 0,
+ 0);
+ test_assert(err == OS_SUCCESS, "task 4 creation failed");
+
+ err = OS_TaskCreate(&tid3,
+ "running thread 3",
+ test_thread3,
+ (uint32 *)wa_test3,
+ sizeof wa_test3,
+ TASKS_BASE_PRIORITY - 1,
+ 0);
+ test_assert(err == OS_SUCCESS, "task 3 creation failed");
+
+ err = OS_TaskCreate(&tid2,
+ "running thread 2",
+ test_thread2,
+ (uint32 *)wa_test2,
+ sizeof wa_test2,
+ TASKS_BASE_PRIORITY - 2,
+ 0);
+ test_assert(err == OS_SUCCESS, "task 2 creation failed");
+
+ err = OS_TaskCreate(&tid1,
+ "running thread 1",
+ test_thread1,
+ (uint32 *)wa_test1,
+ sizeof wa_test1,
+ TASKS_BASE_PRIORITY - 3,
+ 0);
+ test_assert(err == OS_SUCCESS, "task 1 creation failed");
+ }
+
+ /* Tasks are made runnable atomically and their execution order
+ tested.*/
+ test_set_step(2);
+ {
+ OS_TaskDelay(5);
+ test_assert_sequence("ABCD", "task order violation");
+ }
+
+ /* Four tasks are created in priority order from high to low.*/
+ test_set_step(3);
+ {
+ int32 err;
+ uint32 tid1, tid2, tid3, tid4;
+
+ err = OS_TaskCreate(&tid1,
+ "running thread 1",
+ test_thread1,
+ (uint32 *)wa_test1,
+ sizeof wa_test1,
+ TASKS_BASE_PRIORITY - 3,
+ 0);
+ test_assert(err == OS_SUCCESS, "task 1 creation failed");
+
+ err = OS_TaskCreate(&tid2,
+ "running thread 2",
+ test_thread2,
+ (uint32 *)wa_test2,
+ sizeof wa_test2,
+ TASKS_BASE_PRIORITY - 2,
+ 0);
+ test_assert(err == OS_SUCCESS, "task 2 creation failed");
+
+ err = OS_TaskCreate(&tid3,
+ "running thread 3",
+ test_thread3,
+ (uint32 *)wa_test3,
+ sizeof wa_test3,
+ TASKS_BASE_PRIORITY - 1,
+ 0);
+ test_assert(err == OS_SUCCESS, "task 3 creation failed");
+
+ err = OS_TaskCreate(&tid4,
+ "running thread 4",
+ test_thread4,
+ (uint32 *)wa_test4,
+ sizeof wa_test4,
+ TASKS_BASE_PRIORITY - 0,
+ 0);
+ test_assert(err == OS_SUCCESS, "task 4 creation failed");
+ }
+
+ /* Tasks are made runnable atomically and their execution order
+ tested.*/
+ test_set_step(4);
+ {
+ OS_TaskDelay(5);
+ test_assert_sequence("ABCD", "task order violation");
+ }
+
+ /* Four tasks are created in an not ordered way.*/
+ test_set_step(5);
+ {
+ int32 err;
+ uint32 tid1, tid2, tid3, tid4;
+
+ err = OS_TaskCreate(&tid2,
+ "running thread 2",
+ test_thread2,
+ (uint32 *)wa_test2,
+ sizeof wa_test2,
+ TASKS_BASE_PRIORITY - 2,
+ 0);
+ test_assert(err == OS_SUCCESS, "task 2 creation failed");
+
+ err = OS_TaskCreate(&tid1,
+ "running thread 1",
+ test_thread1,
+ (uint32 *)wa_test1,
+ sizeof wa_test1,
+ TASKS_BASE_PRIORITY - 3,
+ 0);
+ test_assert(err == OS_SUCCESS, "task 1 creation failed");
+
+ err = OS_TaskCreate(&tid4,
+ "running thread 4",
+ test_thread4,
+ (uint32 *)wa_test4,
+ sizeof wa_test4,
+ TASKS_BASE_PRIORITY - 0,
+ 0);
+ test_assert(err == OS_SUCCESS, "task 4 creation failed");
+
+ err = OS_TaskCreate(&tid3,
+ "running thread 3",
+ test_thread3,
+ (uint32 *)wa_test3,
+ sizeof wa_test3,
+ TASKS_BASE_PRIORITY - 1,
+ 0);
+ test_assert(err == OS_SUCCESS, "task 3 creation failed");
+ }
+
+ /* Tasks are made runnable atomically and their execution order
+ tested.*/
+ test_set_step(6);
+ {
+ OS_TaskDelay(5);
+ test_assert_sequence("ABCD", "task order violation");
+ }
+}
+
+static const testcase_t test_001_002 = {
+ "OS_TaskCreate() priority ordering",
+ NULL,
+ NULL,
+ test_001_002_execute
+};
+
/****************************************************************************
* Exported data.
****************************************************************************/
@@ -272,5 +457,6 @@ static const testcase_t test_001_001 = {
*/
const testcase_t * const test_sequence_001[] = {
&test_001_001,
+ &test_001_002,
NULL
};