[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:30:06 UTC 2015


---
 testsuites/sptests/spcontext01/init.c          | 37 ++++++++++++++++++++------
 testsuites/sptests/spcontext01/spcontext01.scn |  5 +++-
 2 files changed, 33 insertions(+), 9 deletions(-)

diff --git a/testsuites/sptests/spcontext01/init.c b/testsuites/sptests/spcontext01/init.c
index 039dd63..ca07ce6 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,17 +48,21 @@ 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;
+  rtems_attribute FPU_state;
+
+  FPU_state = fp_unit ? RTEMS_FLOATING_POINT : RTEMS_DEFAULT_ATTRIBUTES;
 
   sc = rtems_task_create(
     rtems_build_name('V', 'A', 'L', 'I'),
     priority,
     RTEMS_MINIMUM_STACK_SIZE,
     RTEMS_DEFAULT_MODES,
-    RTEMS_DEFAULT_ATTRIBUTES,
+    FPU_state,
     id
   );
   rtems_test_assert(sc == RTEMS_SUCCESSFUL);
@@ -121,7 +127,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,19 +150,30 @@ 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)
 {
+  rtems_status_code sc;
   uintptr_t pattern_0 = (uintptr_t) 0xaaaaaaaaaaaaaaaaU;
   uintptr_t pattern_1 = (uintptr_t) 0x5555555555555555U;
 
   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();
+
+  sc = rtems_task_delete(self->validate_tasks[0]);
+  rtems_test_assert(sc == RTEMS_SUCCESSFUL);
+
+  sc = rtems_task_delete(self->validate_tasks[1]);
+  rtems_test_assert(sc == RTEMS_SUCCESSFUL);
+
+  sc = rtems_timer_delete(timer);
+  rtems_test_assert(sc == RTEMS_SUCCESSFUL);
 }
 
 static void test_context_is_executing(void)
@@ -207,7 +223,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();
 
diff --git a/testsuites/sptests/spcontext01/spcontext01.scn b/testsuites/sptests/spcontext01/spcontext01.scn
index b7b823b..a76e00b 100644
--- a/testsuites/sptests/spcontext01/spcontext01.scn
+++ b/testsuites/sptests/spcontext01/spcontext01.scn
@@ -1,2 +1,5 @@
-*** TEST SPCONTEXT 1 ***
+*** BEGIN OF TEST SPCONTEXT 1 ***
+Both tasks did not use FPU: done
+One task used the FPU: done
+Both tasks used the FPU: done
 *** END OF TEST SPCONTEXT 1 ***
-- 
1.8.4.5




More information about the devel mailing list