forked from Imagelibrary/rtems
new test
This commit is contained in:
60
c/src/tests/libtests/cpuuse/Makefile.in
Normal file
60
c/src/tests/libtests/cpuuse/Makefile.in
Normal file
@@ -0,0 +1,60 @@
|
||||
#
|
||||
# $Id$
|
||||
#
|
||||
|
||||
@SET_MAKE@
|
||||
srcdir = @srcdir@
|
||||
top_srcdir = @top_srcdir@
|
||||
VPATH=@srcdir@
|
||||
|
||||
TEST=cpuuse
|
||||
|
||||
MANAGERS=io rate_monotonic
|
||||
|
||||
# C source names, if any, go here -- minus the .c
|
||||
C_PIECES=init task1 task2 task3 tswitch
|
||||
C_FILES=$(C_PIECES:%=%.c)
|
||||
C_O_FILES=$(C_PIECES:%=${ARCH}/%.o)
|
||||
|
||||
H_FILES=system.h
|
||||
|
||||
DOCTYPES=scn
|
||||
DOCS=$(DOCTYPES:%=$(TEST).%)
|
||||
|
||||
SRCS=$(DOCS) $(C_FILES) $(H_FILES)
|
||||
OBJS=$(C_O_FILES)
|
||||
|
||||
PRINT_SRCS=$(DOCS)
|
||||
|
||||
PGM=${ARCH}/$(TEST).exe
|
||||
|
||||
include $(RTEMS_CUSTOM)
|
||||
include $(PROJECT_ROOT)/make/leaf.cfg
|
||||
|
||||
#
|
||||
# (OPTIONAL) Add local stuff here using +=
|
||||
#
|
||||
|
||||
DEFINES +=
|
||||
CPPFLAGS +=
|
||||
CFLAGS +=
|
||||
|
||||
LD_PATHS +=
|
||||
LD_LIBS +=
|
||||
LDFLAGS +=
|
||||
|
||||
#
|
||||
# Add your list of files to delete here. The config files
|
||||
# already know how to delete some stuff, so you may want
|
||||
# to just run 'make clean' first to see what gets missed.
|
||||
# 'make clobber' already includes 'make clean'
|
||||
#
|
||||
|
||||
CLEAN_ADDITIONS +=
|
||||
CLOBBER_ADDITIONS +=
|
||||
|
||||
all: ${ARCH} $(SRCS) $(PGM)
|
||||
$(INSTALL_VARIANT) -m 555 ${PGM} ${PROJECT_RELEASE}/tests
|
||||
|
||||
${PGM}: $(OBJS) $(LINK_FILES)
|
||||
$(make-exe)
|
||||
24
c/src/tests/libtests/cpuuse/cpuuse.scn
Normal file
24
c/src/tests/libtests/cpuuse/cpuuse.scn
Normal file
@@ -0,0 +1,24 @@
|
||||
*** TEST 4 ***
|
||||
TA1 - 09:15:00 12/31/1988
|
||||
TA1 - rtems_task_suspend - on Task 2
|
||||
TA1 - rtems_task_suspend - on Task 3
|
||||
TA1 - killing time
|
||||
TA1 - rtems_task_resume - on Task 2
|
||||
TA1 - rtems_task_resume - on Task 3
|
||||
TA2 - 09:15:03 12/31/1988
|
||||
TA3 - 09:15:04 12/31/1988
|
||||
TA1 - 09:15:05 12/31/1988
|
||||
TA2 - 09:15:06 12/31/1988
|
||||
TA3 - 09:15:07 12/31/1988
|
||||
TA1 - 09:15:08 12/31/1988
|
||||
TA1 - rtems_task_mode - change mode to NO RTEMS_PREEMPT
|
||||
TA1 - 09:15:09 12/31/1988
|
||||
TA1 - 09:15:10 12/31/1988
|
||||
TA1 - 09:15:11 12/31/1988
|
||||
TA1 - 09:15:12 12/31/1988
|
||||
TA1 - 09:15:13 12/31/1988
|
||||
TA1 - 09:15:14 12/31/1988
|
||||
TA1 - rtems_task_mode - change mode to RTEMS_PREEMPT
|
||||
TA2 - 09:15:15 12/31/1988
|
||||
TA3 - 09:15:16 12/31/1988
|
||||
*** END OF TEST 4 ***
|
||||
106
c/src/tests/libtests/cpuuse/init.c
Normal file
106
c/src/tests/libtests/cpuuse/init.c
Normal file
@@ -0,0 +1,106 @@
|
||||
/*
|
||||
* This is a clone of sp04 which has been modified to use the cpu monitoring
|
||||
* library.
|
||||
*
|
||||
* Input parameters:
|
||||
* argument - task argument
|
||||
*
|
||||
* Output parameters: NONE
|
||||
*
|
||||
* COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994, 1997.
|
||||
* 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.
|
||||
*
|
||||
* init.c,v 1.6 1996/02/13 22:16:22 joel Exp
|
||||
*/
|
||||
|
||||
#define TEST_INIT
|
||||
#include "system.h"
|
||||
|
||||
rtems_extensions_table Extensions = {
|
||||
NULL, /* task create user extension */
|
||||
NULL, /* task start user extension */
|
||||
NULL, /* task restart user extension */
|
||||
NULL, /* task delete user extension */
|
||||
Task_switch, /* task switch user extension */
|
||||
NULL, /* task begin user extension */
|
||||
NULL, /* task exitted user extension */
|
||||
NULL /* fatal error user extension */
|
||||
};
|
||||
|
||||
rtems_task Init(
|
||||
rtems_task_argument argument
|
||||
)
|
||||
{
|
||||
rtems_status_code status;
|
||||
rtems_time_of_day time;
|
||||
|
||||
puts( "\n\n*** CPU USAGE LIBRARY TEST ***" );
|
||||
build_time( &time, 12, 31, 1988, 9, 15, 0, 0 );
|
||||
|
||||
status = rtems_clock_set( &time );
|
||||
directive_failed( status, "rtems_clock_set" );
|
||||
|
||||
Extension_name[ 1 ] = rtems_build_name( 'E', 'X', 'T', ' ' );
|
||||
|
||||
status = rtems_extension_create(
|
||||
Extension_name[ 1 ],
|
||||
&Extensions,
|
||||
&Extension_id[ 1 ]
|
||||
);
|
||||
directive_failed( status, "rtems_extension_create" );
|
||||
|
||||
Task_name[ 1 ] = rtems_build_name( 'T', 'A', '1', ' ' );
|
||||
Task_name[ 2 ] = rtems_build_name( 'T', 'A', '2', ' ' );
|
||||
Task_name[ 3 ] = rtems_build_name( 'T', 'A', '3', ' ' );
|
||||
|
||||
Run_count[ 1 ] = 0;
|
||||
Run_count[ 2 ] = 0;
|
||||
Run_count[ 3 ] = 0;
|
||||
|
||||
status = rtems_task_create(
|
||||
Task_name[ 1 ],
|
||||
1,
|
||||
RTEMS_MINIMUM_STACK_SIZE * 2,
|
||||
RTEMS_TIMESLICE,
|
||||
RTEMS_DEFAULT_ATTRIBUTES,
|
||||
&Task_id[ 1 ]
|
||||
);
|
||||
directive_failed( status, "rtems_task_create of TA1" );
|
||||
|
||||
status = rtems_task_create(
|
||||
Task_name[ 2 ],
|
||||
1,
|
||||
RTEMS_MINIMUM_STACK_SIZE * 2,
|
||||
RTEMS_TIMESLICE,
|
||||
RTEMS_DEFAULT_ATTRIBUTES,
|
||||
&Task_id[ 2 ]
|
||||
);
|
||||
directive_failed( status, "rtems_task_create of TA2" );
|
||||
|
||||
status = rtems_task_create(
|
||||
Task_name[ 3 ],
|
||||
1,
|
||||
RTEMS_MINIMUM_STACK_SIZE * 2,
|
||||
RTEMS_TIMESLICE,
|
||||
RTEMS_DEFAULT_ATTRIBUTES,
|
||||
&Task_id[ 3 ]
|
||||
);
|
||||
directive_failed( status, "rtems_task_create of TA3" );
|
||||
|
||||
status = rtems_task_start( Task_id[ 1 ], Task_1, 0 );
|
||||
directive_failed( status, "rtems_task_start of TA1" );
|
||||
|
||||
status = rtems_task_start( Task_id[ 2 ], Task_2, 0 );
|
||||
directive_failed( status, "rtems_task_start of TA2" );
|
||||
|
||||
status = rtems_task_start( Task_id[ 3 ], Task_3, 0 );
|
||||
directive_failed( status, "rtems_task_start of TA3" );
|
||||
|
||||
status = rtems_task_delete( RTEMS_SELF );
|
||||
directive_failed( status, "rtems_task_delete of RTEMS_SELF" );
|
||||
}
|
||||
65
c/src/tests/libtests/cpuuse/system.h
Normal file
65
c/src/tests/libtests/cpuuse/system.h
Normal file
@@ -0,0 +1,65 @@
|
||||
/* system.h
|
||||
*
|
||||
* This include file contains information that is included in every
|
||||
* function in the test set.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* system.h,v 1.6 1995/12/19 20:18:39 joel Exp
|
||||
*/
|
||||
|
||||
#include <tmacros.h>
|
||||
|
||||
/* functions */
|
||||
|
||||
rtems_task Init(
|
||||
rtems_task_argument argument
|
||||
);
|
||||
|
||||
rtems_task Task_1(
|
||||
rtems_task_argument argument
|
||||
);
|
||||
|
||||
rtems_task Task_2(
|
||||
rtems_task_argument argument
|
||||
);
|
||||
|
||||
rtems_task Task_3(
|
||||
rtems_task_argument argument
|
||||
);
|
||||
|
||||
void Task_switch(
|
||||
rtems_tcb *unused,
|
||||
rtems_tcb *heir
|
||||
);
|
||||
|
||||
/* configuration information */
|
||||
|
||||
#define CONFIGURE_SPTEST
|
||||
|
||||
#define CONFIGURE_TEST_NEEDS_CONSOLE_DRIVER
|
||||
#define CONFIGURE_TEST_NEEDS_CLOCK_DRIVER
|
||||
|
||||
#define CONFIGURE_MAXIMUM_USER_EXTENSIONS 1
|
||||
#define CONFIGURE_TICKS_PER_TIMESLICE 100
|
||||
|
||||
#include <confdefs.h>
|
||||
|
||||
/* global variables */
|
||||
|
||||
TEST_EXTERN rtems_id Task_id[ 4 ]; /* array of task ids */
|
||||
TEST_EXTERN rtems_name Task_name[ 4 ]; /* array of task names */
|
||||
|
||||
TEST_EXTERN rtems_id Extension_id[ 4 ];
|
||||
TEST_EXTERN rtems_name Extension_name[ 4 ]; /* array of task names */
|
||||
|
||||
/* array of task run counts */
|
||||
TEST_EXTERN volatile rtems_unsigned32 Run_count[ 4 ];
|
||||
|
||||
/* end of include file */
|
||||
103
c/src/tests/libtests/cpuuse/task1.c
Normal file
103
c/src/tests/libtests/cpuuse/task1.c
Normal file
@@ -0,0 +1,103 @@
|
||||
/* Task_1
|
||||
*
|
||||
* This test serves as a test task. It verifies timeslicing activities
|
||||
* and tswitch extension processing.
|
||||
*
|
||||
* Input parameters:
|
||||
* argument - task argument
|
||||
*
|
||||
* Output parameters: NONE
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* task1.c,v 1.6 1995/12/19 20:18:40 joel Exp
|
||||
*/
|
||||
|
||||
#include "system.h"
|
||||
|
||||
rtems_task Task_1(
|
||||
rtems_task_argument argument
|
||||
)
|
||||
{
|
||||
rtems_unsigned32 seconds;
|
||||
rtems_unsigned32 old_seconds;
|
||||
rtems_mode previous_mode;
|
||||
rtems_time_of_day time;
|
||||
rtems_status_code status;
|
||||
rtems_unsigned32 start_time;
|
||||
rtems_unsigned32 end_time;
|
||||
|
||||
puts( "TA1 - rtems_task_suspend - on Task 2" );
|
||||
status = rtems_task_suspend( Task_id[ 2 ] );
|
||||
directive_failed( status, "rtems_task_suspend of TA2" );
|
||||
|
||||
puts( "TA1 - rtems_task_suspend - on Task 3" );
|
||||
status = rtems_task_suspend( Task_id[ 3 ] );
|
||||
directive_failed( status, "rtems_task_suspend of TA3" );
|
||||
|
||||
status = rtems_clock_get( RTEMS_CLOCK_GET_SECONDS_SINCE_EPOCH, &start_time );
|
||||
directive_failed( status, "rtems_clock_get" );
|
||||
|
||||
puts( "TA1 - killing time" );
|
||||
|
||||
for ( ; ; ) {
|
||||
status = rtems_clock_get( RTEMS_CLOCK_GET_SECONDS_SINCE_EPOCH, &end_time );
|
||||
directive_failed( status, "rtems_clock_get" );
|
||||
|
||||
if ( end_time > (start_time + 2) )
|
||||
break;
|
||||
}
|
||||
|
||||
puts( "TA1 - rtems_task_resume - on Task 2" );
|
||||
status = rtems_task_resume( Task_id[ 2 ] );
|
||||
directive_failed( status, "rtems_task_resume of TA2" );
|
||||
|
||||
puts( "TA1 - rtems_task_resume - on Task 3" );
|
||||
status = rtems_task_resume( Task_id[ 3 ] );
|
||||
directive_failed( status, "rtems_task_resume of TA3" );
|
||||
|
||||
while ( FOREVER ) {
|
||||
if ( Run_count[ 1 ] == 3 ) {
|
||||
puts( "TA1 - rtems_task_mode - change mode to NO RTEMS_PREEMPT" );
|
||||
|
||||
status = rtems_task_mode(
|
||||
RTEMS_NO_PREEMPT,
|
||||
RTEMS_PREEMPT_MASK,
|
||||
&previous_mode
|
||||
);
|
||||
directive_failed( status, "rtems_task_mode" );
|
||||
|
||||
status = rtems_clock_get( RTEMS_CLOCK_GET_TOD, &time );
|
||||
directive_failed( status, "rtems_clock_get" );
|
||||
|
||||
old_seconds = time.second;
|
||||
|
||||
for ( seconds = 0 ; seconds < 6 ; ) {
|
||||
status = rtems_clock_get( RTEMS_CLOCK_GET_TOD, &time );
|
||||
directive_failed( status, "rtems_clock_get" );
|
||||
|
||||
if ( time.second != old_seconds ) {
|
||||
old_seconds = time.second;
|
||||
seconds++;
|
||||
print_time( "TA1 - ", &time, "\n" );
|
||||
}
|
||||
}
|
||||
|
||||
puts( "TA1 - rtems_task_mode - change mode to RTEMS_PREEMPT" );
|
||||
status = rtems_task_mode(
|
||||
RTEMS_PREEMPT,
|
||||
RTEMS_PREEMPT_MASK,
|
||||
&previous_mode
|
||||
);
|
||||
directive_failed( status, "rtems_task_mode" );
|
||||
|
||||
while ( FOREVER );
|
||||
}
|
||||
}
|
||||
}
|
||||
29
c/src/tests/libtests/cpuuse/task2.c
Normal file
29
c/src/tests/libtests/cpuuse/task2.c
Normal file
@@ -0,0 +1,29 @@
|
||||
/* Task_2
|
||||
*
|
||||
* This routine serves as a test task. It is just a CPU bound task
|
||||
* requiring timesliced operation.
|
||||
*
|
||||
* Input parameters:
|
||||
* argument - task argument
|
||||
*
|
||||
* Output parameters: NONE
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* task2.c,v 1.3 1995/12/19 20:18:42 joel Exp
|
||||
*/
|
||||
|
||||
#include "system.h"
|
||||
|
||||
rtems_task Task_2(
|
||||
rtems_task_argument argument
|
||||
)
|
||||
{
|
||||
while( FOREVER );
|
||||
}
|
||||
29
c/src/tests/libtests/cpuuse/task3.c
Normal file
29
c/src/tests/libtests/cpuuse/task3.c
Normal file
@@ -0,0 +1,29 @@
|
||||
/* Task_3
|
||||
*
|
||||
* This routine serves as a test task. It is just a CPU bound task
|
||||
* requiring timesliced operation.
|
||||
*
|
||||
* Input parameters:
|
||||
* argument - task argument
|
||||
*
|
||||
* Output parameters: NONE
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* task3.c,v 1.3 1995/12/19 20:18:43 joel Exp
|
||||
*/
|
||||
|
||||
#include "system.h"
|
||||
|
||||
rtems_task Task_3(
|
||||
rtems_task_argument argument
|
||||
)
|
||||
{
|
||||
while( FOREVER );
|
||||
}
|
||||
62
c/src/tests/libtests/cpuuse/tswitch.c
Normal file
62
c/src/tests/libtests/cpuuse/tswitch.c
Normal file
@@ -0,0 +1,62 @@
|
||||
/* Task_switch
|
||||
*
|
||||
* This routine is the tswitch user extension. It determines which
|
||||
* task is being switched to and displays a message indicating the
|
||||
* time and date that it gained control.
|
||||
*
|
||||
* Input parameters:
|
||||
* unused - pointer to currently running TCB
|
||||
* heir - pointer to heir TCB
|
||||
*
|
||||
* Output parameters: NONE
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* tswitch.c,v 1.4 1995/12/19 20:18:44 joel Exp
|
||||
*/
|
||||
|
||||
#include "system.h"
|
||||
|
||||
#include "cpuuse.h"
|
||||
|
||||
rtems_extension Task_switch(
|
||||
rtems_tcb *unused,
|
||||
rtems_tcb *heir
|
||||
)
|
||||
{
|
||||
rtems_unsigned32 index;
|
||||
rtems_time_of_day time;
|
||||
rtems_status_code status;
|
||||
|
||||
index = task_number( heir->Object.id );
|
||||
|
||||
switch( index ) {
|
||||
case 1:
|
||||
case 2:
|
||||
case 3:
|
||||
Run_count[ index ] += 1;
|
||||
|
||||
status = rtems_clock_get( RTEMS_CLOCK_GET_TOD, &time );
|
||||
directive_failed( status, "rtems_clock_get" );
|
||||
|
||||
put_name( Task_name[ index ], FALSE );
|
||||
print_time( "- ", &time, "\n" );
|
||||
|
||||
if ( time.second >= 16 ) {
|
||||
CPU_usage_Dump();
|
||||
puts( "*** END OF CPU USAGE LIBRARY TEST ***" );
|
||||
exit( 0 );
|
||||
}
|
||||
break;
|
||||
|
||||
case 0:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
60
c/src/tests/libtests/rtmonuse/Makefile.in
Normal file
60
c/src/tests/libtests/rtmonuse/Makefile.in
Normal file
@@ -0,0 +1,60 @@
|
||||
#
|
||||
# $Id$
|
||||
#
|
||||
|
||||
@SET_MAKE@
|
||||
srcdir = @srcdir@
|
||||
top_srcdir = @top_srcdir@
|
||||
VPATH=@srcdir@
|
||||
|
||||
TEST=rtmonuse
|
||||
|
||||
MANAGERS=io rate_monotonic
|
||||
|
||||
# C source names, if any, go here -- minus the .c
|
||||
C_PIECES=init getall task1
|
||||
C_FILES=$(C_PIECES:%=%.c)
|
||||
C_O_FILES=$(C_PIECES:%=${ARCH}/%.o)
|
||||
|
||||
H_FILES=system.h
|
||||
|
||||
DOCTYPES=scn
|
||||
DOCS=$(DOCTYPES:%=$(TEST).%)
|
||||
|
||||
SRCS=$(DOCS) $(C_FILES) $(H_FILES)
|
||||
OBJS=$(C_O_FILES)
|
||||
|
||||
PRINT_SRCS=$(DOCS)
|
||||
|
||||
PGM=${ARCH}/$(TEST).exe
|
||||
|
||||
include $(RTEMS_CUSTOM)
|
||||
include $(PROJECT_ROOT)/make/leaf.cfg
|
||||
|
||||
#
|
||||
# (OPTIONAL) Add local stuff here using +=
|
||||
#
|
||||
|
||||
DEFINES +=
|
||||
CPPFLAGS +=
|
||||
CFLAGS +=
|
||||
|
||||
LD_PATHS +=
|
||||
LD_LIBS +=
|
||||
LDFLAGS +=
|
||||
|
||||
#
|
||||
# Add your list of files to delete here. The config files
|
||||
# already know how to delete some stuff, so you may want
|
||||
# to just run 'make clean' first to see what gets missed.
|
||||
# 'make clobber' already includes 'make clean'
|
||||
#
|
||||
|
||||
CLEAN_ADDITIONS +=
|
||||
CLOBBER_ADDITIONS +=
|
||||
|
||||
all: ${ARCH} $(SRCS) $(PGM)
|
||||
$(INSTALL_VARIANT) -m 555 ${PGM} ${PROJECT_RELEASE}/tests
|
||||
|
||||
${PGM}: $(OBJS) $(LINK_FILES)
|
||||
$(make-exe)
|
||||
43
c/src/tests/libtests/rtmonuse/getall.c
Normal file
43
c/src/tests/libtests/rtmonuse/getall.c
Normal file
@@ -0,0 +1,43 @@
|
||||
/* Get_all_counters
|
||||
*
|
||||
* This routine allows TA5 to atomically obtain the iteration counters.
|
||||
*
|
||||
* Input parameters: NONE
|
||||
*
|
||||
* Output parameters: NONE
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* getall.c,v 1.3 1995/12/19 20:21:07 joel Exp
|
||||
*/
|
||||
|
||||
#include "system.h"
|
||||
|
||||
void Get_all_counters()
|
||||
{
|
||||
rtems_mode previous_mode;
|
||||
rtems_status_code status;
|
||||
|
||||
status = rtems_task_mode(
|
||||
RTEMS_NO_PREEMPT,
|
||||
RTEMS_PREEMPT_MASK,
|
||||
&previous_mode
|
||||
);
|
||||
directive_failed( status, "rtems_task_mode to RTEMS_NO_PREEMPT" );
|
||||
|
||||
Temporary_count = Count;
|
||||
Count.count[ 1 ] = 0;
|
||||
Count.count[ 2 ] = 0;
|
||||
Count.count[ 3 ] = 0;
|
||||
Count.count[ 4 ] = 0;
|
||||
Count.count[ 5 ] = 0;
|
||||
|
||||
status = rtems_task_mode( RTEMS_PREEMPT, RTEMS_PREEMPT_MASK, &previous_mode );
|
||||
directive_failed( status, "rtems_task_mode to RTEMS_PREEMPT" );
|
||||
}
|
||||
71
c/src/tests/libtests/rtmonuse/init.c
Normal file
71
c/src/tests/libtests/rtmonuse/init.c
Normal file
@@ -0,0 +1,71 @@
|
||||
/* Init
|
||||
*
|
||||
* This routine is the initialization task for this test program.
|
||||
* It is a user initialization task and has the responsibility for creating
|
||||
* and starting the tasks that make up the test. If the time of day
|
||||
* clock is required for the test, it should also be set to a known
|
||||
* value by this function.
|
||||
*
|
||||
* Input parameters:
|
||||
* argument - task argument
|
||||
*
|
||||
* Output parameters: NONE
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* init.c,v 1.6 1995/12/19 20:21:09 joel Exp
|
||||
*/
|
||||
|
||||
#define TEST_INIT
|
||||
#include "system.h"
|
||||
|
||||
#include "rtmonuse.h"
|
||||
|
||||
rtems_task Init(
|
||||
rtems_task_argument argument
|
||||
)
|
||||
{
|
||||
rtems_unsigned32 index;
|
||||
rtems_status_code status;
|
||||
|
||||
puts( "\n\n*** RATE MONOTONIC PERIOD STATISTICS TEST ***" );
|
||||
Period_usage_Initialize();
|
||||
|
||||
Task_name[ 1 ] = rtems_build_name( 'T', 'A', '1', ' ' );
|
||||
Task_name[ 2 ] = rtems_build_name( 'T', 'A', '2', ' ' );
|
||||
Task_name[ 3 ] = rtems_build_name( 'T', 'A', '3', ' ' );
|
||||
Task_name[ 4 ] = rtems_build_name( 'T', 'A', '4', ' ' );
|
||||
Task_name[ 5 ] = rtems_build_name( 'T', 'A', '5', ' ' );
|
||||
|
||||
for ( index = 1 ; index <= 5 ; index++ ) {
|
||||
status = rtems_task_create(
|
||||
Task_name[ index ],
|
||||
Priorities[ index ],
|
||||
RTEMS_MINIMUM_STACK_SIZE * 4,
|
||||
RTEMS_DEFAULT_MODES,
|
||||
RTEMS_DEFAULT_ATTRIBUTES,
|
||||
&Task_id[ index ]
|
||||
);
|
||||
directive_failed( status, "rtems_task_create loop" );
|
||||
}
|
||||
|
||||
for ( index = 1 ; index <= 5 ; index++ ) {
|
||||
status = rtems_task_start( Task_id[ index ], Task_1_through_5, index );
|
||||
directive_failed( status, "rtems_task_start loop" );
|
||||
}
|
||||
|
||||
Count.count[ 1 ] = 0;
|
||||
Count.count[ 2 ] = 0;
|
||||
Count.count[ 3 ] = 0;
|
||||
Count.count[ 4 ] = 0;
|
||||
Count.count[ 5 ] = 0;
|
||||
|
||||
status = rtems_task_delete( RTEMS_SELF );
|
||||
directive_failed( status, "rtems_task_delete of RTEMS_SELF" );
|
||||
}
|
||||
27
c/src/tests/libtests/rtmonuse/rtmonuse.scn
Normal file
27
c/src/tests/libtests/rtmonuse/rtmonuse.scn
Normal file
@@ -0,0 +1,27 @@
|
||||
*** TEST 20 ***
|
||||
TA1 - rtems_rate_monotonic_create id = 0x28010001
|
||||
TA1 - rtems_rate_monotonic_ident id = 0x28010001
|
||||
TA1 - (0x28010001) period 2
|
||||
TA2 - rtems_rate_monotonic_create id = 0x28010002
|
||||
TA2 - rtems_rate_monotonic_ident id = 0x28010002
|
||||
TA2 - (0x28010002) period 2
|
||||
TA3 - rtems_rate_monotonic_create id = 0x28010003
|
||||
TA3 - rtems_rate_monotonic_ident id = 0x28010003
|
||||
TA3 - (0x28010003) period 2
|
||||
TA4 - rtems_rate_monotonic_create id = 0x28010004
|
||||
TA4 - rtems_rate_monotonic_ident id = 0x28010004
|
||||
TA4 - (0x28010004) period 2
|
||||
TA5 - rtems_rate_monotonic_create id = 0x28010005
|
||||
TA5 - rtems_rate_monotonic_ident id = 0x28010005
|
||||
TA5 - (0x28010005) period 100
|
||||
TA5 - PERIODS CHECK OK (1)
|
||||
TA5 - PERIODS CHECK OK (2)
|
||||
TA5 - PERIODS CHECK OK (3)
|
||||
TA5 - PERIODS CHECK OK (4)
|
||||
TA5 - PERIODS CHECK OK (5)
|
||||
TA5 - PERIODS CHECK OK (6)
|
||||
TA5 - PERIODS CHECK OK (7)
|
||||
TA5 - PERIODS CHECK OK (8)
|
||||
TA5 - PERIODS CHECK OK (9)
|
||||
TA5 - PERIODS CHECK OK (10)
|
||||
*** END OF TEST 20 ***
|
||||
59
c/src/tests/libtests/rtmonuse/system.h
Normal file
59
c/src/tests/libtests/rtmonuse/system.h
Normal file
@@ -0,0 +1,59 @@
|
||||
/* system.h
|
||||
*
|
||||
* This include file contains information that is included in every
|
||||
* function in the test set.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* system.h,v 1.6 1995/12/19 20:21:12 joel Exp
|
||||
*/
|
||||
|
||||
#include <tmacros.h>
|
||||
|
||||
/* types */
|
||||
|
||||
struct counters {
|
||||
rtems_unsigned32 count[6];
|
||||
};
|
||||
|
||||
/* functions */
|
||||
|
||||
rtems_task Init(
|
||||
rtems_task_argument argument
|
||||
);
|
||||
|
||||
rtems_task Task_1_through_5(
|
||||
rtems_task_argument argument
|
||||
);
|
||||
|
||||
void Get_all_counters( void );
|
||||
|
||||
/* configuration information */
|
||||
|
||||
#define CONFIGURE_SPTEST
|
||||
|
||||
#define CONFIGURE_TEST_NEEDS_CONSOLE_DRIVER
|
||||
#define CONFIGURE_TEST_NEEDS_CLOCK_DRIVER
|
||||
|
||||
#define CONFIGURE_INIT_TASK_PRIORITY 10
|
||||
#define CONFIGURE_INIT_TASK_INITIAL_MODES RTEMS_DEFAULT_MODES
|
||||
#define CONFIGURE_MAXIMUM_PERIODS 10
|
||||
|
||||
#include <confdefs.h>
|
||||
|
||||
/* global variables */
|
||||
|
||||
TEST_EXTERN rtems_id Task_id[ 6 ]; /* array of task ids */
|
||||
TEST_EXTERN rtems_name Task_name[ 6 ]; /* array of task names */
|
||||
|
||||
TEST_EXTERN struct counters Count; /* iteration counters */
|
||||
TEST_EXTERN struct counters Temporary_count;
|
||||
extern rtems_task_priority Priorities[ 6 ];
|
||||
|
||||
/* end of include file */
|
||||
124
c/src/tests/libtests/rtmonuse/task1.c
Normal file
124
c/src/tests/libtests/rtmonuse/task1.c
Normal file
@@ -0,0 +1,124 @@
|
||||
/* Task_1_through_5
|
||||
*
|
||||
* This routine serves as a test task for the period capabilities of the
|
||||
* Rate Monotonic Manager.
|
||||
*
|
||||
* Input parameters:
|
||||
* argument - task argument
|
||||
*
|
||||
* Output parameters: NONE
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* task1.c,v 1.3 1995/12/19 20:21:14 joel Exp
|
||||
*/
|
||||
|
||||
#include "system.h"
|
||||
|
||||
#include <cpuuse.h>
|
||||
#include "rtmonuse.h"
|
||||
|
||||
rtems_unsigned32 Periods[6] = { 0, 2, 2, 2, 2, 100 };
|
||||
rtems_unsigned32 Iterations[6] = { 0, 50, 50, 50, 50, 1 };
|
||||
rtems_task_priority Priorities[6] = { 0, 1, 1, 3, 4, 5 };
|
||||
|
||||
rtems_task Task_1_through_5(
|
||||
rtems_unsigned32 argument
|
||||
)
|
||||
{
|
||||
rtems_id rmid;
|
||||
rtems_id test_rmid;
|
||||
rtems_unsigned32 index;
|
||||
rtems_unsigned32 pass;
|
||||
rtems_unsigned32 failed;
|
||||
rtems_status_code status;
|
||||
|
||||
status = rtems_rate_monotonic_create( argument, &rmid );
|
||||
directive_failed( status, "rtems_rate_monotonic_create" );
|
||||
put_name( Task_name[ argument ], FALSE );
|
||||
printf( "- rtems_rate_monotonic_create id = 0x%08x\n", rmid );
|
||||
|
||||
status = rtems_rate_monotonic_ident( argument, &test_rmid );
|
||||
directive_failed( status, "rtems_rate_monotonic_ident" );
|
||||
put_name( Task_name[ argument ], FALSE );
|
||||
printf( "- rtems_rate_monotonic_ident id = 0x%08x\n", test_rmid );
|
||||
|
||||
if ( rmid != test_rmid ) {
|
||||
printf( "RMID's DO NOT MATCH (0x%x and 0x%x)\n", rmid, test_rmid );
|
||||
exit( 0 );
|
||||
}
|
||||
|
||||
put_name( Task_name[ argument ], FALSE );
|
||||
printf( "- (0x%08x) period %d\n", rmid, Periods[ argument ] );
|
||||
|
||||
status = rtems_task_wake_after( 2 );
|
||||
directive_failed( status, "rtems_task_wake_after" );
|
||||
|
||||
switch ( argument ) {
|
||||
case 1:
|
||||
case 2:
|
||||
case 3:
|
||||
case 4:
|
||||
while ( FOREVER ) {
|
||||
Period_usage_Update( rmid );
|
||||
|
||||
status = rtems_rate_monotonic_period( rmid, Periods[ argument ] );
|
||||
directive_failed( status, "rtems_rate_monotonic_period" );
|
||||
Count.count[ argument ]++;
|
||||
}
|
||||
break;
|
||||
case 5:
|
||||
pass = 0;
|
||||
failed = 0;
|
||||
|
||||
status = rtems_rate_monotonic_period( rmid, Periods[ argument ] );
|
||||
directive_failed( status, "rtems_rate_monotonic_period 1 of TA5" );
|
||||
|
||||
Get_all_counters();
|
||||
|
||||
while ( FOREVER ) {
|
||||
Period_usage_Update( rmid );
|
||||
|
||||
status = rtems_rate_monotonic_period( rmid, Periods[ argument ] );
|
||||
directive_failed( status, "rtems_rate_monotonic_period 2 of TA5" );
|
||||
|
||||
Get_all_counters();
|
||||
|
||||
for( index = 1 ; index <= 4 ; index++ ) {
|
||||
if ( Temporary_count.count[ index ] != Iterations[ index ] ) {
|
||||
puts_nocr( "FAIL -- " );
|
||||
put_name ( Task_name[ index ], FALSE );
|
||||
printf ( " Actual=%d, Expected=%d\n",
|
||||
Temporary_count.count[ index ],
|
||||
Iterations[ index ]
|
||||
);
|
||||
failed += 1;
|
||||
}
|
||||
}
|
||||
|
||||
if ( failed == 5 )
|
||||
exit( 0 );
|
||||
|
||||
pass += 1;
|
||||
|
||||
printf( "TA5 - PERIODS CHECK OK (%d)\n", pass );
|
||||
|
||||
fflush( stdout );
|
||||
|
||||
if ( pass == 10 ) {
|
||||
puts( "*** END OF RATE MONOTONIC PERIOD STATISTICS TEST ***" );
|
||||
CPU_usage_Dump();
|
||||
Period_usage_Dump();
|
||||
exit( 0 );
|
||||
}
|
||||
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user