[PATCH] SPCONTEXT01: checks correct switching on and off of the Floating Point Unit

Alexander Krutwig alexander.krutwig at embedded-brains.de
Wed May 6 10:01:56 UTC 2015


---
 testsuites/sptests/spcontext01/init.c | 55 +++++++++++++++++++++++++----------
 1 file changed, 40 insertions(+), 15 deletions(-)

diff --git a/testsuites/sptests/spcontext01/init.c b/testsuites/sptests/spcontext01/init.c
index 039dd63..702b734 100644
--- a/testsuites/sptests/spcontext01/init.c
+++ b/testsuites/sptests/spcontext01/init.c
@@ -37,6 +37,8 @@ typedef struct {
 
 static test_context test_instance;
 
+static rtems_id timer;
+
 static void validate_task(rtems_task_argument arg)
 {
   _CPU_Context_validate(arg);
@@ -46,19 +48,34 @@ static void validate_task(rtems_task_argument arg)
 static void start_validate_task(
   rtems_id *id,
   uintptr_t pattern,
-  rtems_task_priority priority
+  rtems_task_priority priority,
+  bool fp_unit
 )
 {
   rtems_status_code sc;
 
-  sc = rtems_task_create(
-    rtems_build_name('V', 'A', 'L', 'I'),
-    priority,
-    RTEMS_MINIMUM_STACK_SIZE,
-    RTEMS_DEFAULT_MODES,
-    RTEMS_DEFAULT_ATTRIBUTES,
-    id
-  );
+  if (fp_unit)
+  {
+    sc = rtems_task_create(
+      rtems_build_name('V', 'A', 'L', 'I'),
+      priority,
+      RTEMS_MINIMUM_STACK_SIZE,
+      RTEMS_DEFAULT_MODES,
+      RTEMS_FLOATING_POINT,
+      id
+    );
+  }
+  else
+  {
+    sc = rtems_task_create(
+      rtems_build_name('V', 'A', 'L', 'I'),
+      priority,
+      RTEMS_MINIMUM_STACK_SIZE,
+      RTEMS_DEFAULT_MODES,
+      RTEMS_DEFAULT_ATTRIBUTES,
+      id
+    );
+  }
   rtems_test_assert(sc == RTEMS_SUCCESSFUL);
 
   sc = rtems_task_start(*id, validate_task, pattern);
@@ -121,7 +138,6 @@ static void clobber_and_switch_timer(rtems_id timer, void *arg)
 static void start_timer(test_context *self)
 {
   rtems_status_code sc;
-  rtems_id timer;
 
   sc = rtems_timer_create(rtems_build_name('C', 'L', 'S', 'W'), &timer);
   rtems_test_assert(sc == RTEMS_SUCCESSFUL);
@@ -145,7 +161,7 @@ static void wait_for_finish(void)
   rtems_test_assert(out == FINISH_EVENT);
 }
 
-static void test(test_context *self)
+static void test(test_context *self, bool task_0_fpu, bool task_1_fpu)
 {
   uintptr_t pattern_0 = (uintptr_t) 0xaaaaaaaaaaaaaaaaU;
   uintptr_t pattern_1 = (uintptr_t) 0x5555555555555555U;
@@ -153,11 +169,15 @@ static void test(test_context *self)
   memset(self, 0, sizeof(*self));
 
   self->control_task = rtems_task_self();
-
-  start_validate_task(&self->validate_tasks[0], pattern_0, PRIORITY_LOW);
-  start_validate_task(&self->validate_tasks[1], pattern_1, PRIORITY_HIGH);
+  start_validate_task(&self->validate_tasks[0], pattern_0, PRIORITY_LOW,
+                     task_0_fpu);
+  start_validate_task(&self->validate_tasks[1], pattern_1, PRIORITY_HIGH,
+                     task_1_fpu);
   start_timer(self);
   wait_for_finish();
+  rtems_task_delete(self->validate_tasks[0]);
+  rtems_task_delete(self->validate_tasks[1]);
+  rtems_timer_delete(timer);
 }
 
 static void test_context_is_executing(void)
@@ -207,7 +227,12 @@ static void Init(rtems_task_argument arg)
   TEST_BEGIN();
 
   test_context_is_executing();
-  test(self);
+  test(self, 0, 0);
+  printf("Both tasks did not use FPU: done\n");
+  test(self, 0, 1);
+  printf("One task used the FPU: done\n");
+  test(self, 1, 1);
+  printf("Both tasks used the FPU: done\n");
 
   TEST_END();
 
-- 
1.8.4.5



More information about the devel mailing list