summaryrefslogtreecommitdiffstats
path: root/testsuites/tmtests/tm26
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@OARcorp.com>1995-05-11 17:39:37 +0000
committerJoel Sherrill <joel.sherrill@OARcorp.com>1995-05-11 17:39:37 +0000
commitac7d5ef06a6d6e8d84abbd1f0b82162725f98326 (patch)
tree9304cf759a73f2a1c6fd3191948f00e870af3787 /testsuites/tmtests/tm26
downloadrtems-ac7d5ef06a6d6e8d84abbd1f0b82162725f98326.tar.bz2
Initial revision
Diffstat (limited to 'testsuites/tmtests/tm26')
-rw-r--r--testsuites/tmtests/tm26/fptest.h165
-rw-r--r--testsuites/tmtests/tm26/system.h23
-rw-r--r--testsuites/tmtests/tm26/task1.c470
-rw-r--r--testsuites/tmtests/tm26/tm26.doc13
4 files changed, 671 insertions, 0 deletions
diff --git a/testsuites/tmtests/tm26/fptest.h b/testsuites/tmtests/tm26/fptest.h
new file mode 100644
index 0000000000..39b8438ef9
--- /dev/null
+++ b/testsuites/tmtests/tm26/fptest.h
@@ -0,0 +1,165 @@
+/* fptest.h
+ *
+ * This include file contains the CPU dependent implementation
+ * of the following routines needed to test RTEMS floating
+ * point support:
+ * FP_load( &context )
+ * FP_check( &context )
+ *
+ * FP_load - loads the specified floating point context
+ * FP_check - checks the specified floating point context
+ *
+ * NOTE: These routines are VERY CPU dependent and are thus
+ * located in in the CPU dependent include file
+ * fptest.h. These routines form the core of the
+ * floating point context switch test.
+ *
+ * COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994.
+ * On-Line Applications Research Corporation (OAR).
+ * All rights assigned to U.S. Government, 1994.
+ *
+ * This material may be reproduced by or for the U.S. Government pursuant
+ * to the copyright license under the clause at DFARS 252.227-7013. This
+ * notice must appear in all copies of this file and its derivatives.
+ *
+ * $Id$
+ */
+
+
+#ifndef __FPTEST_h
+#define __FPTEST_h
+
+#include <stdio.h>
+
+#ifndef CPU_HARDWARE_FP
+#error "This CPU does not have CPU_HARDWARE_FP defined"
+#endif
+
+#if ( CPU_HARDWARE_FP == FALSE )
+
+#define FP_DECLARE
+#define FP_LOAD( _factor )
+#define FP_CHECK( _factor ) 0
+
+#else
+
+#define FP_DECLARE \
+ double fp01 = 1.0; \
+ double fp02 = 2.0; \
+ double fp03 = 3.0; \
+ double fp04 = 4.0; \
+ double fp05 = 5.0; \
+ double fp06 = 6.0; \
+ double fp07 = 7.0; \
+ double fp08 = 8.0; \
+ double fp09 = 9.0; \
+ double fp10 = 10.0; \
+ double fp11 = 11.0; \
+ double fp12 = 12.0; \
+ double fp13 = 13.0; \
+ double fp14 = 14.0; \
+ double fp15 = 15.0; \
+ double fp16 = 16.0; \
+ double fp17 = 17.0; \
+ double fp18 = 18.0; \
+ double fp19 = 19.0; \
+ double fp20 = 20.0; \
+ double fp21 = 21.0; \
+ double fp22 = 22.0; \
+ double fp23 = 23.0; \
+ double fp24 = 24.0; \
+ double fp25 = 25.0; \
+ double fp26 = 26.0; \
+ double fp27 = 27.0; \
+ double fp28 = 28.0; \
+ double fp29 = 29.0; \
+ double fp30 = 30.0; \
+ double fp31 = 31.0; \
+ double fp32 = 32.0
+
+#define FP_LOAD( _factor ) \
+ do { \
+ fp01 += _factor; \
+ fp02 += _factor; \
+ fp03 += _factor; \
+ fp04 += _factor; \
+ fp05 += _factor; \
+ fp06 += _factor; \
+ fp07 += _factor; \
+ fp08 += _factor; \
+ fp09 += _factor; \
+ fp10 += _factor; \
+ fp11 += _factor; \
+ fp12 += _factor; \
+ fp13 += _factor; \
+ fp14 += _factor; \
+ fp15 += _factor; \
+ fp16 += _factor; \
+ fp17 += _factor; \
+ fp18 += _factor; \
+ fp19 += _factor; \
+ fp20 += _factor; \
+ fp21 += _factor; \
+ fp22 += _factor; \
+ fp23 += _factor; \
+ fp24 += _factor; \
+ fp25 += _factor; \
+ fp26 += _factor; \
+ fp27 += _factor; \
+ fp28 += _factor; \
+ fp29 += _factor; \
+ fp30 += _factor; \
+ fp31 += _factor; \
+ fp32 += _factor; \
+ } while (0)
+
+#define EPSILON (0.0005)
+#define FPABS(d) (((d) < 0.0) ? -(d) : (d))
+#define FPNEQ(a,b) (FPABS((a)-(b)) > EPSILON)
+
+#define FP_CHECK_ONE( _v, _base, _factor ) \
+ if ( FPNEQ( (_v), ((_base) + (_factor)) ) ) { \
+ printf("%d: " #_v " wrong -- (%g not %g)\n", \
+ task_index, (_v), (_base + _factor)); \
+ }
+
+
+#define FP_CHECK( _factor ) \
+ do { \
+ FP_CHECK_ONE( fp01, 1.0, (_factor) ); \
+ FP_CHECK_ONE( fp02, 2.0, (_factor) ); \
+ FP_CHECK_ONE( fp03, 3.0, (_factor) ); \
+ FP_CHECK_ONE( fp04, 4.0, (_factor) ); \
+ FP_CHECK_ONE( fp05, 5.0, (_factor) ); \
+ FP_CHECK_ONE( fp06, 6.0, (_factor) ); \
+ FP_CHECK_ONE( fp07, 7.0, (_factor) ); \
+ FP_CHECK_ONE( fp08, 8.0, (_factor) ); \
+ FP_CHECK_ONE( fp09, 9.0, (_factor) ); \
+ FP_CHECK_ONE( fp10, 10.0, (_factor) ); \
+ FP_CHECK_ONE( fp11, 11.0, (_factor) ); \
+ FP_CHECK_ONE( fp12, 12.0, (_factor) ); \
+ FP_CHECK_ONE( fp13, 13.0, (_factor) ); \
+ FP_CHECK_ONE( fp14, 14.0, (_factor) ); \
+ FP_CHECK_ONE( fp15, 15.0, (_factor) ); \
+ FP_CHECK_ONE( fp16, 16.0, (_factor) ); \
+ FP_CHECK_ONE( fp17, 17.0, (_factor) ); \
+ FP_CHECK_ONE( fp18, 18.0, (_factor) ); \
+ FP_CHECK_ONE( fp19, 19.0, (_factor) ); \
+ FP_CHECK_ONE( fp20, 20.0, (_factor) ); \
+ FP_CHECK_ONE( fp21, 21.0, (_factor) ); \
+ FP_CHECK_ONE( fp22, 22.0, (_factor) ); \
+ FP_CHECK_ONE( fp23, 23.0, (_factor) ); \
+ FP_CHECK_ONE( fp24, 24.0, (_factor) ); \
+ FP_CHECK_ONE( fp25, 25.0, (_factor) ); \
+ FP_CHECK_ONE( fp26, 26.0, (_factor) ); \
+ FP_CHECK_ONE( fp27, 27.0, (_factor) ); \
+ FP_CHECK_ONE( fp28, 28.0, (_factor) ); \
+ FP_CHECK_ONE( fp29, 29.0, (_factor) ); \
+ FP_CHECK_ONE( fp30, 30.0, (_factor) ); \
+ FP_CHECK_ONE( fp31, 31.0, (_factor) ); \
+ FP_CHECK_ONE( fp32, 32.0, (_factor) ); \
+ } while (0)
+
+#endif
+
+#endif
diff --git a/testsuites/tmtests/tm26/system.h b/testsuites/tmtests/tm26/system.h
new file mode 100644
index 0000000000..9133506e7f
--- /dev/null
+++ b/testsuites/tmtests/tm26/system.h
@@ -0,0 +1,23 @@
+/* system.h
+ *
+ * This include file is used by all tests in the Time Suite.
+ *
+ * COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994.
+ * On-Line Applications Research Corporation (OAR).
+ * All rights assigned to U.S. Government, 1994.
+ *
+ * This material may be reproduced by or for the U.S. Government pursuant
+ * to the copyright license under the clause at DFARS 252.227-7013. This
+ * notice must appear in all copies of this file and its derivatives.
+ *
+ * $Id$
+ */
+
+
+#include <rtems.h>
+
+#include "coverhd.h"
+#include "tmacros.h"
+
+#include "timesys.h"
+#include "timegvar.h"
diff --git a/testsuites/tmtests/tm26/task1.c b/testsuites/tmtests/tm26/task1.c
new file mode 100644
index 0000000000..b3544741bc
--- /dev/null
+++ b/testsuites/tmtests/tm26/task1.c
@@ -0,0 +1,470 @@
+/*
+ *
+ * COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994.
+ * On-Line Applications Research Corporation (OAR).
+ * All rights assigned to U.S. Government, 1994.
+ *
+ * This material may be reproduced by or for the U.S. Government pursuant
+ * to the copyright license under the clause at DFARS 252.227-7013. This
+ * notice must appear in all copies of this file and its derivatives.
+ *
+ * $Id$
+ */
+
+#include <rtems.h>
+#include "system.h"
+#include "fptest.h"
+#include "coverhd.h"
+#include "tmacros.h"
+#include "timesys.h"
+
+#undef EXTERN
+#define EXTERN
+#include "gvar.h"
+#include "conftbl.h"
+#undef EXTERN
+#define EXTERN extern
+
+/* TEST DATA */
+rtems_id Semaphore_id;
+
+Objects_Locations location; /* uses internal RTEMS type */
+
+Thread_Control *Middle_tcb; /* uses internal RTEMS type */
+
+rtems_task High_task(
+ rtems_task_argument argument
+);
+
+rtems_task Middle_task(
+ rtems_task_argument argument
+);
+
+rtems_task Low_task(
+ rtems_task_argument argument
+);
+
+rtems_task Floating_point_task_1(
+ rtems_task_argument argument
+);
+
+rtems_task Floating_point_task_2(
+ rtems_task_argument argument
+);
+
+void complete_test( void );
+
+rtems_task null_task(
+ rtems_task_argument argument
+)
+{
+}
+
+rtems_task Init(
+ rtems_task_argument argument
+)
+{
+ rtems_unsigned32 index;
+ rtems_id task_id;
+ rtems_status_code status;
+
+ puts( "\n\n*** TIME TEST 26 ***" );
+
+ status = rtems_task_create(
+ rtems_build_name( 'F', 'P', '1', ' ' ),
+ 201,
+ 2048,
+ RTEMS_DEFAULT_MODES,
+ RTEMS_FLOATING_POINT,
+ &task_id
+ );
+ directive_failed( status, "rtems_task_create of FP1" );
+
+ status = rtems_task_start( task_id, Floating_point_task_1, 0 );
+ directive_failed( status, "rtems_task_start of FP1" );
+
+ status = rtems_task_create(
+ rtems_build_name( 'F', 'P', '2', ' ' ),
+ 202,
+ 2048,
+ RTEMS_DEFAULT_MODES,
+ RTEMS_FLOATING_POINT,
+ &task_id
+ );
+ directive_failed( status, "rtems_task_create of FP2" );
+
+ status = rtems_task_start( task_id, Floating_point_task_2, 0 );
+ directive_failed( status, "rtems_task_start of FP2" );
+
+ status = rtems_task_create(
+ rtems_build_name( 'L', 'O', 'W', ' ' ),
+ 200,
+ 2048,
+ RTEMS_DEFAULT_MODES,
+ RTEMS_DEFAULT_ATTRIBUTES,
+ &task_id
+ );
+ directive_failed( status, "rtems_task_create of LOW" );
+
+ status = rtems_task_start( task_id, Low_task, 0 );
+ directive_failed( status, "rtems_task_start of LOW" );
+
+ status = rtems_task_create(
+ rtems_build_name( 'M', 'I', 'D', ' ' ),
+ 128,
+ 2048,
+ RTEMS_DEFAULT_MODES,
+ RTEMS_DEFAULT_ATTRIBUTES,
+ &task_id
+ );
+ directive_failed( status, "rtems_task_create of MIDDLE" );
+
+ status = rtems_task_start( task_id, Middle_task, 0 );
+ directive_failed( status, "rtems_task_start of MIDDLE" );
+
+ status = rtems_task_create(
+ rtems_build_name( 'H', 'I', 'G', 'H' ),
+ 5,
+ 2048,
+ RTEMS_DEFAULT_MODES,
+ RTEMS_DEFAULT_ATTRIBUTES,
+ &task_id
+ );
+ directive_failed( status, "rtems_task_create of HIGH" );
+
+ status = rtems_task_start( task_id, High_task, 0 );
+ directive_failed( status, "rtems_task_start of HIGH" );
+
+ status = rtems_semaphore_create(
+ rtems_build_name( 'S', 'E', 'M', '1' ),
+ OPERATION_COUNT,
+ RTEMS_DEFAULT_ATTRIBUTES,
+ &Semaphore_id
+ );
+ directive_failed( status, "rtems_semaphore_create" );
+
+ for ( index = 1 ; index <= OPERATION_COUNT ; index++ ) {
+ status = rtems_task_create(
+ rtems_build_name( 'N', 'U', 'L', 'L' ),
+ 254,
+ 1024,
+ RTEMS_DEFAULT_MODES,
+ RTEMS_DEFAULT_ATTRIBUTES,
+ &task_id
+ );
+ directive_failed( status, "rtems_task_create LOOP" );
+
+ status = rtems_task_start( task_id, null_task, 0 );
+ directive_failed( status, "rtems_task_start LOOP" );
+ }
+
+ status = rtems_task_delete( RTEMS_SELF );
+ directive_failed( status, "rtems_task_delete of RTEMS_SELF" );
+}
+
+rtems_task High_task(
+ rtems_task_argument argument
+)
+{
+ Timer_initialize();
+ _Thread_Disable_dispatch();
+ end_time = Read_timer();
+
+ put_time(
+ "THREAD_DISABLE_DISPATCH",
+ end_time,
+ 1,
+ 0,
+ 0
+ );
+
+
+ Timer_initialize();
+ _Thread_Enable_dispatch();
+ end_time = Read_timer();
+
+ put_time(
+ "THREAD_ENABLE_DISPATCH",
+ end_time,
+ 1,
+ 0,
+ 0
+ );
+
+ Timer_initialize();
+ _Thread_Set_state( _Thread_Executing, STATES_SUSPENDED );
+ end_time = Read_timer();
+
+ put_time(
+ "THREAD_SET_STATE",
+ end_time,
+ 1,
+ 0,
+ 0
+ );
+
+ _Context_Switch_necessary = TRUE;
+
+ Timer_initialize();
+ _Thread_Dispatch(); /* dispatches Middle_task */
+}
+
+rtems_task Middle_task(
+ rtems_task_argument argument
+)
+{
+ end_time = Read_timer();
+
+ put_time(
+ "THREAD_DISPATCH (NO FP)",
+ end_time,
+ 1,
+ 0,
+ 0
+ );
+
+ _Thread_Set_state( _Thread_Executing, STATES_SUSPENDED );
+
+ Middle_tcb = _Thread_Executing;
+
+ _Thread_Executing =
+ (Thread_Control *) _Thread_Ready_chain[200].first;
+
+ /* do not force context switch */
+
+ _Context_Switch_necessary = FALSE;
+
+ Timer_initialize();
+ _Context_Switch( &Middle_tcb->Registers, &_Thread_Executing->Registers );
+}
+
+rtems_task Low_task(
+ rtems_task_argument argument
+)
+{
+ Thread_Control *executing;
+
+ end_time = Read_timer();
+
+ put_time(
+ "CONTEXT_SWITCH (NO FP)",
+ end_time,
+ 1,
+ 0,
+ 0
+ );
+
+ executing = _Thread_Executing;
+
+ _Thread_Executing =
+ (Thread_Control *) _Thread_Ready_chain[201].first;
+
+ /* do not force context switch */
+
+ _Context_Switch_necessary = FALSE;
+
+ Timer_initialize();
+ _Context_Restore_fp( &_Thread_Executing->fp_context );
+ _Context_Switch( &executing->Registers, &_Thread_Executing->Registers );
+}
+
+rtems_task Floating_point_task_1(
+ rtems_task_argument argument
+)
+{
+ Thread_Control *executing;
+ FP_DECLARE;
+
+ end_time = Read_timer();
+
+ put_time(
+ "CONTEXT_SWITCH (restore 1st FP)",
+ end_time,
+ 1,
+ 0,
+ 0
+ );
+
+ executing = _Thread_Executing;
+
+ _Thread_Executing =
+ (Thread_Control *) _Thread_Ready_chain[202].first;
+
+ /* do not force context switch */
+
+ _Context_Switch_necessary = FALSE;
+
+ Timer_initialize();
+ _Context_Save_fp( &executing->fp_context );
+ _Context_Restore_fp( &_Thread_Executing->fp_context );
+ _Context_Switch( &executing->Registers, &_Thread_Executing->Registers );
+ /* switch to Floating_point_task_2 */
+
+ end_time = Read_timer();
+
+ put_time(
+ "CONTEXT_SWITCH (used->init FP)",
+ end_time,
+ 1,
+ 0,
+ 0
+ );
+
+ FP_LOAD( 1.0 );
+
+ executing = _Thread_Executing;
+
+ _Thread_Executing =
+ (Thread_Control *) _Thread_Ready_chain[202].first;
+
+ /* do not force context switch */
+
+ _Context_Switch_necessary = FALSE;
+
+ Timer_initialize();
+ _Context_Save_fp( &executing->fp_context );
+ _Context_Restore_fp( &_Thread_Executing->fp_context );
+ _Context_Switch( &executing->Registers, &_Thread_Executing->Registers );
+ /* switch to Floating_point_task_2 */
+}
+
+rtems_task Floating_point_task_2(
+ rtems_task_argument argument
+)
+{
+ Thread_Control *executing;
+ FP_DECLARE;
+
+ end_time = Read_timer();
+
+ put_time(
+ "CONTEXT_SWITCH (init->init FP)",
+ end_time,
+ 1,
+ 0,
+ 0
+ );
+
+ executing = _Thread_Executing;
+
+ _Thread_Executing =
+ (Thread_Control *) _Thread_Ready_chain[201].first;
+
+ FP_LOAD( 1.0 );
+
+ /* do not force context switch */
+
+ _Context_Switch_necessary = FALSE;
+
+ Timer_initialize();
+ _Context_Save_fp( &executing->fp_context );
+ _Context_Restore_fp( &_Thread_Executing->fp_context );
+ _Context_Switch( &executing->Registers, &_Thread_Executing->Registers );
+ /* switch to Floating_point_task_1 */
+
+ end_time = Read_timer();
+
+ put_time(
+ "CONTEXT_SWITCH (used->used FP)",
+ end_time,
+ 1,
+ 0,
+ 0
+ );
+
+ complete_test();
+}
+
+void complete_test( void )
+{
+ rtems_unsigned32 index;
+ rtems_id task_id;
+
+ Timer_initialize();
+ _Thread_Resume( Middle_tcb );
+ end_time = Read_timer();
+
+ put_time(
+ "THREAD_RESUME",
+ end_time,
+ 1,
+ 0,
+ 0
+ );
+
+ _Thread_Set_state( Middle_tcb, STATES_WAITING_FOR_MESSAGE );
+
+ Timer_initialize();
+ _Thread_Unblock( Middle_tcb );
+ end_time = Read_timer();
+
+ put_time(
+ "THREAD_UNBLOCK",
+ end_time,
+ 1,
+ 0,
+ 0
+ );
+
+ _Thread_Set_state( Middle_tcb, STATES_WAITING_FOR_MESSAGE );
+
+ Timer_initialize();
+ _Thread_Ready( Middle_tcb );
+ end_time = Read_timer();
+
+ put_time(
+ "THREAD_READY",
+ end_time,
+ 1,
+ 0,
+ 0
+ );
+
+ Timer_initialize();
+ for ( index=1 ; index <= OPERATION_COUNT ; index++ )
+ (void) Empty_function();
+ overhead = Read_timer();
+
+ task_id = Middle_tcb->Object.id;
+
+ Timer_initialize();
+ for ( index=1 ; index <= OPERATION_COUNT ; index++ )
+ (void) _Thread_Get( task_id, &location );
+ end_time = Read_timer();
+
+ put_time(
+ "THREAD_GET",
+ end_time,
+ OPERATION_COUNT,
+ 0,
+ 0
+ );
+
+ Timer_initialize();
+ for ( index=1 ; index <= OPERATION_COUNT ; index++ )
+ (void) _Semaphore_Get( Semaphore_id, &location );
+ end_time = Read_timer();
+
+ put_time(
+ "SEMAPHORE_GET",
+ end_time,
+ OPERATION_COUNT,
+ 0,
+ 0
+ );
+
+ Timer_initialize();
+ for ( index=1 ; index <= OPERATION_COUNT ; index++ )
+ (void) _Thread_Get( 0x3, &location );
+ end_time = Read_timer();
+
+ put_time(
+ "THREAD_GET invalid id",
+ end_time,
+ OPERATION_COUNT,
+ 0,
+ 0
+ );
+ exit( 0 );
+}
+
diff --git a/testsuites/tmtests/tm26/tm26.doc b/testsuites/tmtests/tm26/tm26.doc
new file mode 100644
index 0000000000..0de40191c6
--- /dev/null
+++ b/testsuites/tmtests/tm26/tm26.doc
@@ -0,0 +1,13 @@
+#
+# $Id$
+#
+# COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994.
+# On-Line Applications Research Corporation (OAR).
+# All rights assigned to U.S. Government, 1994.
+#
+# This material may be reproduced by or for the U.S. Government pursuant
+# to the copyright license under the clause at DFARS 252.227-7013. This
+# notice must appear in all copies of this file and its derivatives.
+#
+
+