tests/samples: Use <rtems/test.h>

This commit is contained in:
Sebastian Huber
2014-03-10 16:31:43 +01:00
parent 840ae715a9
commit 9391f6d663
26 changed files with 95 additions and 25 deletions

View File

@@ -37,6 +37,6 @@ rtems_task Application_task(
status = rtems_task_ident( RTEMS_SELF, RTEMS_SEARCH_ALL_NODES, &tid ); status = rtems_task_ident( RTEMS_SELF, RTEMS_SEARCH_ALL_NODES, &tid );
printf( "This task was invoked with the node argument (%" PRIdrtems_task_argument ")\n", node ); printf( "This task was invoked with the node argument (%" PRIdrtems_task_argument ")\n", node );
printf( "This task has the id of 0x%" PRIxrtems_id "\n", tid ); printf( "This task has the id of 0x%" PRIxrtems_id "\n", tid );
printf( "*** END OF SAMPLE MULTIPROCESSOR APPLICATION ***\n" ); TEST_END();
exit( 0 ); exit( 0 );
} }

View File

@@ -18,6 +18,8 @@
/* forward declarations to avoid warnings */ /* forward declarations to avoid warnings */
rtems_task Init(rtems_task_argument argument); rtems_task Init(rtems_task_argument argument);
const char rtems_test_name[] = "SAMPLE MULTIPROCESSOR APPLICATION";
rtems_task Init( rtems_task Init(
rtems_task_argument argument rtems_task_argument argument
) )
@@ -26,7 +28,7 @@ rtems_task Init(
rtems_id tid; rtems_id tid;
rtems_status_code status; rtems_status_code status;
printf( "\n\n*** SAMPLE MULTIPROCESSOR APPLICATION ***\n" ); TEST_BEGIN();
printf( "Creating and starting an application task\n" ); printf( "Creating and starting an application task\n" );
task_name = rtems_build_name( 'T', 'A', '1', ' ' ); task_name = rtems_build_name( 'T', 'A', '1', ' ' );
status = rtems_task_create( task_name, 1, RTEMS_MINIMUM_STACK_SIZE, status = rtems_task_create( task_name, 1, RTEMS_MINIMUM_STACK_SIZE,

View File

@@ -12,6 +12,7 @@
*/ */
#include <rtems.h> #include <rtems.h>
#include <rtems/test.h>
/* functions */ /* functions */
@@ -36,6 +37,8 @@ rtems_task Application_task(
#define CONFIGURE_RTEMS_INIT_TASKS_TABLE #define CONFIGURE_RTEMS_INIT_TASKS_TABLE
#define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION
/* /*
* Put the overrides of default configuration parameters here. * Put the overrides of default configuration parameters here.
*/ */

View File

@@ -41,6 +41,6 @@ rtems_task Application_task(
"and has id of 0x%" PRIxrtems_id "\n", argument, tid "and has id of 0x%" PRIxrtems_id "\n", argument, tid
); );
printf( "*** END OF SAMPLE SINGLE PROCESSOR APPLICATION ***\n" ); TEST_END();
exit( 0 ); exit( 0 );
} }

View File

@@ -19,6 +19,8 @@
/* forward declarations to avoid warnings */ /* forward declarations to avoid warnings */
rtems_task Init(rtems_task_argument argument); rtems_task Init(rtems_task_argument argument);
const char rtems_test_name[] = "SAMPLE SINGLE PROCESSOR APPLICATION";
#define ARGUMENT 0 #define ARGUMENT 0
rtems_task Init( rtems_task Init(
@@ -29,7 +31,7 @@ rtems_task Init(
rtems_id tid; rtems_id tid;
rtems_status_code status; rtems_status_code status;
printf( "\n\n*** SAMPLE SINGLE PROCESSOR APPLICATION ***\n" ); TEST_BEGIN();
printf( "Creating and starting an application task\n" ); printf( "Creating and starting an application task\n" );
task_name = rtems_build_name( 'T', 'A', '1', ' ' ); task_name = rtems_build_name( 'T', 'A', '1', ' ' );

View File

@@ -12,6 +12,7 @@
*/ */
#include <rtems.h> #include <rtems.h>
#include <rtems/test.h>
/* functions */ /* functions */
@@ -33,6 +34,8 @@ rtems_task Application_task(
#define CONFIGURE_MAXIMUM_TASKS 2 #define CONFIGURE_MAXIMUM_TASKS 2
#define CONFIGURE_RTEMS_INIT_TASKS_TABLE #define CONFIGURE_RTEMS_INIT_TASKS_TABLE
#define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION
#include <rtems/confdefs.h> #include <rtems/confdefs.h>
/* end of include file */ /* end of include file */

View File

@@ -28,6 +28,8 @@ rtems_task Init(rtems_task_argument argument);
static void notification(int fd, int seconds_remaining, void *arg); static void notification(int fd, int seconds_remaining, void *arg);
#endif #endif
const char rtems_test_name[] = "CAPTURE ENGINE";
volatile int can_proceed = 1; volatile int can_proceed = 1;
#if !BSP_SMALL_MEMORY #if !BSP_SMALL_MEMORY
@@ -51,7 +53,7 @@ rtems_task Init(
rtems_task_priority old_priority; rtems_task_priority old_priority;
rtems_mode old_mode; rtems_mode old_mode;
puts( "\n\n*** TEST CAPTURE ENGINE ***" ); rtems_test_begin();
status = rtems_shell_wait_for_input( status = rtems_shell_wait_for_input(
STDIN_FILENO, STDIN_FILENO,
@@ -78,7 +80,7 @@ rtems_task Init(
rtems_task_delete (RTEMS_SELF); rtems_task_delete (RTEMS_SELF);
} else { } else {
puts( "*** END OF TEST CAPTURE ENGINE ***" ); rtems_test_end();
exit( 0 ); exit( 0 );
} }

View File

@@ -12,6 +12,7 @@
*/ */
#include <rtems.h> #include <rtems.h>
#include <rtems/test.h>
/* functions */ /* functions */
@@ -49,6 +50,8 @@ extern void setup_tasks_to_watch(void);
#define CONFIGURE_MAXIMUM_USER_EXTENSIONS (5) #define CONFIGURE_MAXIMUM_USER_EXTENSIONS (5)
#define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION
#include <rtems/confdefs.h> #include <rtems/confdefs.h>
/* /*

View File

@@ -23,6 +23,7 @@
*/ */
#include <rtems.h> #include <rtems.h>
#include <rtems/test.h>
#include <cstdio> #include <cstdio>
#include <cstdlib> #include <cstdlib>
@@ -31,6 +32,8 @@
#include <iostream> #include <iostream>
#endif #endif
const char rtems_test_name[] = "CONSTRUCTOR/DESTRUCTOR";
extern "C" extern "C"
{ {
#include <tmacros.h> #include <tmacros.h>
@@ -176,12 +179,11 @@ rtems_task main_task(
rtems_task_argument rtems_task_argument
) )
{ {
printf( "\n\n*** CONSTRUCTOR/DESTRUCTOR TEST ***\n" ); TEST_BEGIN();
cdtest(); cdtest();
printf( "*** END OF CONSTRUCTOR/DESTRUCTOR TEST ***\n\n\n" ); TEST_END();
printf( "*** TESTING C++ EXCEPTIONS ***\n\n" ); printf( "*** TESTING C++ EXCEPTIONS ***\n\n" );

View File

@@ -12,6 +12,7 @@
*/ */
#include <rtems.h> #include <rtems.h>
#include <rtems/test.h>
/* functions */ /* functions */
@@ -33,6 +34,8 @@ rtems_task main_task(
#define CONFIGURE_INIT_TASK_ENTRY_POINT main_task #define CONFIGURE_INIT_TASK_ENTRY_POINT main_task
#define CONFIGURE_INIT_TASK_NAME rtems_build_name( 'C', 'T', 'O', 'R' ) #define CONFIGURE_INIT_TASK_NAME rtems_build_name( 'C', 'T', 'O', 'R' )
#define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION
#include <rtems/confdefs.h> #include <rtems/confdefs.h>
/* end of include file */ /* end of include file */

View File

@@ -32,6 +32,8 @@
#include <rtems/nvdisk-sram.h> #include <rtems/nvdisk-sram.h>
#include <rtems/shell.h> #include <rtems/shell.h>
const char rtems_test_name[] = "FILE I/O";
#if FILEIO_BUILD #if FILEIO_BUILD
/** /**
@@ -1220,7 +1222,7 @@ Init (rtems_task_argument ignored)
rtems_id Task_id; rtems_id Task_id;
rtems_status_code status; rtems_status_code status;
puts( "\n\n*** TEST FILE I/O SAMPLE ***" ); TEST_BEGIN();
status = rtems_shell_wait_for_input( status = rtems_shell_wait_for_input(
STDIN_FILENO, STDIN_FILENO,
@@ -1244,7 +1246,7 @@ Init (rtems_task_argument ignored)
status = rtems_task_delete( RTEMS_SELF ); status = rtems_task_delete( RTEMS_SELF );
directive_failed( status, "delete" ); directive_failed( status, "delete" );
} else { } else {
puts( "*** END OF TEST FILE I/O SAMPLE ***" ); TEST_END();
rtems_test_exit( 0 ); rtems_test_exit( 0 );
} }

View File

@@ -12,6 +12,7 @@
*/ */
#include <rtems.h> #include <rtems.h>
#include <rtems/test.h>
#include "tmacros.h" #include "tmacros.h"
/* functions */ /* functions */
@@ -72,6 +73,9 @@ rtems_task Init(
#define CONFIGURE_MALLOC_STATISTICS #define CONFIGURE_MALLOC_STATISTICS
#define CONFIGURE_UNIFIED_WORK_AREAS #define CONFIGURE_UNIFIED_WORK_AREAS
#define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION
#include <rtems/confdefs.h> #include <rtems/confdefs.h>
/* end of include file */ /* end of include file */

View File

@@ -11,6 +11,8 @@
#include "config.h" #include "config.h"
#endif #endif
#include <rtems/test.h>
#include <bsp.h> /* for device driver prototypes */ #include <bsp.h> /* for device driver prototypes */
#include <stdio.h> #include <stdio.h>
@@ -19,13 +21,15 @@
/* forward declarations to avoid warnings */ /* forward declarations to avoid warnings */
rtems_task Init(rtems_task_argument argument); rtems_task Init(rtems_task_argument argument);
const char rtems_test_name[] = "HELLO WORLD";
rtems_task Init( rtems_task Init(
rtems_task_argument ignored rtems_task_argument ignored
) )
{ {
printf( "\n\n*** HELLO WORLD TEST ***\n" ); rtems_test_begin();
printf( "Hello World\n" ); printf( "Hello World\n" );
printf( "*** END OF HELLO WORLD TEST ***\n" ); rtems_test_end();
exit( 0 ); exit( 0 );
} }
@@ -39,5 +43,7 @@ rtems_task Init(
#define CONFIGURE_RTEMS_INIT_TASKS_TABLE #define CONFIGURE_RTEMS_INIT_TASKS_TABLE
#define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION
#define CONFIGURE_INIT #define CONFIGURE_INIT
#include <rtems/confdefs.h> #include <rtems/confdefs.h>

View File

@@ -29,6 +29,8 @@
#include <stdlib.h> #include <stdlib.h>
const char rtems_test_name[] = "HELLO WORLD";
rtems_task Init( rtems_task Init(
rtems_task_argument ignored rtems_task_argument ignored
) )
@@ -36,9 +38,9 @@ rtems_task Init(
#if BSP_SMALL_MEMORY #if BSP_SMALL_MEMORY
printf ("NO STDC++. MEMORY TOO SMALL"); printf ("NO STDC++. MEMORY TOO SMALL");
#else #else
std::cout << "\n\n*** HELLO WORLD TEST ***" << std::endl; std::cout << "\n\n*** " << rtems_test_name << " TEST ***" << std::endl;
std::cout << "Hello World" << std::endl; std::cout << "Hello World" << std::endl;
std::cout << "*** END OF HELLO WORLD TEST ***" << std::endl; std::cout << "*** END OF " << rtems_test_name << " TEST ***" << std::endl;
#endif #endif
exit( 0 ); exit( 0 );
} }

View File

@@ -12,6 +12,7 @@
*/ */
#include <rtems.h> #include <rtems.h>
#include <rtems/test.h>
/* configuration information */ /* configuration information */
@@ -33,6 +34,8 @@
/* Only remove when this macro is removed from confdefs.h. It tests it. */ /* Only remove when this macro is removed from confdefs.h. It tests it. */
#define CONFIGURE_USE_MINIIMFS_AS_BASE_FILESYSTEM #define CONFIGURE_USE_MINIIMFS_AS_BASE_FILESYSTEM
#define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION
#include <rtems/confdefs.h> #include <rtems/confdefs.h>
/* end of include file */ /* end of include file */

View File

@@ -8,8 +8,12 @@
#include "config.h" #include "config.h"
#endif #endif
#include <rtems/test.h>
#include <bsp.h> #include <bsp.h>
const char rtems_test_name[] = "LOOPBACK";
#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER #define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER #define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
#define CONFIGURE_RTEMS_INIT_TASKS_TABLE #define CONFIGURE_RTEMS_INIT_TASKS_TABLE
@@ -33,6 +37,8 @@
#define CONFIGURE_INIT #define CONFIGURE_INIT
rtems_task Init(rtems_task_argument argument); rtems_task Init(rtems_task_argument argument);
#define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION
#include <rtems/confdefs.h> #include <rtems/confdefs.h>
#if !BSP_SMALL_MEMORY #if !BSP_SMALL_MEMORY
@@ -241,6 +247,8 @@ Init (rtems_task_argument ignored)
{ {
rtems_status_code sc; rtems_status_code sc;
rtems_test_begin();
sc = rtems_semaphore_create(rtems_build_name('P','m','t','x'), sc = rtems_semaphore_create(rtems_build_name('P','m','t','x'),
1, 1,
RTEMS_PRIORITY|RTEMS_BINARY_SEMAPHORE|RTEMS_INHERIT_PRIORITY| RTEMS_PRIORITY|RTEMS_BINARY_SEMAPHORE|RTEMS_INHERIT_PRIORITY|
@@ -275,7 +283,7 @@ Init (rtems_task_argument ignored)
spawnTask(clientTask, 120, 6); spawnTask(clientTask, 120, 6);
rtems_task_wake_after(500); rtems_task_wake_after(500);
puts( "*** END OF LOOPBACK TEST ***" ); rtems_test_end();
exit( 0 ); exit( 0 );
} }
#else #else

View File

@@ -34,6 +34,8 @@
#include "tmacros.h" #include "tmacros.h"
#include "pritime.h" #include "pritime.h"
const char rtems_test_name[] = "NANOSECOND CLOCK";
static char *my_ctime( time_t t ) static char *my_ctime( time_t t )
{ {
static char b[32]; static char b[32];
@@ -62,7 +64,7 @@ rtems_task Init(
rtems_time_of_day time; rtems_time_of_day time;
int index; int index;
puts( "\n\n*** NANOSECOND CLOCK TEST ***" ); TEST_BEGIN();
time.year = 2007; time.year = 2007;
time.month = 03; time.month = 03;
@@ -137,7 +139,7 @@ rtems_task Init(
sleep(1); sleep(1);
puts( "*** END OF NANOSECOND CLOCK TEST ***" ); TEST_END();
exit(0); exit(0);
} }

View File

@@ -1,6 +1,8 @@
#ifndef SYSTEM_H #ifndef SYSTEM_H
#define SYSTEM_H #define SYSTEM_H
#include <rtems/test.h>
#include <bsp.h> /* for device driver prototypes */ #include <bsp.h> /* for device driver prototypes */
extern void dummy_function_empty_body_to_force_call(void); extern void dummy_function_empty_body_to_force_call(void);
@@ -12,5 +14,7 @@ extern void dummy_function_empty_body_to_force_call(void);
#define CONFIGURE_MAXIMUM_TASKS 1 #define CONFIGURE_MAXIMUM_TASKS 1
#define CONFIGURE_RTEMS_INIT_TASKS_TABLE #define CONFIGURE_RTEMS_INIT_TASKS_TABLE
#define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION
#include <rtems/confdefs.h> #include <rtems/confdefs.h>
#endif #endif

View File

@@ -18,6 +18,8 @@
extern int paranoia(int, char **); extern int paranoia(int, char **);
const char rtems_test_name[] = "PARANOIA";
char *args[2] = { "paranoia", 0 }; char *args[2] = { "paranoia", 0 };
rtems_task Init( rtems_task Init(
@@ -37,9 +39,9 @@ rtems_task Init(
M68KFPSPInstallExceptionHandlers (); M68KFPSPInstallExceptionHandlers ();
#endif #endif
printf( "\n\n*** PARANOIA TEST ***\n" ); rtems_test_begin();
paranoia(1, args); paranoia(1, args);
printf( "*** END OF PARANOIA TEST ***\n" ); rtems_test_end();
#endif /* BSP_SMALL_MEMORY */ #endif /* BSP_SMALL_MEMORY */
exit( 0 ); exit( 0 );
} }

View File

@@ -12,6 +12,7 @@
*/ */
#include <rtems.h> #include <rtems.h>
#include <rtems/test.h>
/* functions */ /* functions */
@@ -34,6 +35,8 @@ rtems_task Init(
#define CONFIGURE_EXTRA_TASK_STACKS (1 * RTEMS_MINIMUM_STACK_SIZE) #define CONFIGURE_EXTRA_TASK_STACKS (1 * RTEMS_MINIMUM_STACK_SIZE)
#define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION
#include <rtems/confdefs.h> #include <rtems/confdefs.h>
/* end of include file */ /* end of include file */

View File

@@ -24,11 +24,15 @@
#include "netconfig.h" #include "netconfig.h"
#endif #endif
const char rtems_test_name[] = "PPPD";
rtems_task Init(rtems_task_argument argument) rtems_task Init(rtems_task_argument argument)
{ {
#if BSP_SMALL_MEMORY #if BSP_SMALL_MEMORY
printf("NO NETWORKING. MEMORY TOO SMALL"); printf("NO NETWORKING. MEMORY TOO SMALL");
#else #else
rtems_test_begin();
/* initialize network */ /* initialize network */
rtems_bsdnet_initialize_network(); rtems_bsdnet_initialize_network();
rtems_pppd_initialize(); rtems_pppd_initialize();

View File

@@ -2,6 +2,7 @@
#define SYSTEM_H #define SYSTEM_H
#include <rtems.h> #include <rtems.h>
#include <rtems/test.h>
#include <rtems/console.h> #include <rtems/console.h>
#include <rtems/clockdrv.h> #include <rtems/clockdrv.h>
@@ -40,6 +41,8 @@ extern int pppdapp_initialize(void);
RTEMS_NO_ASR | \ RTEMS_NO_ASR | \
RTEMS_INTERRUPT_LEVEL(0)) RTEMS_INTERRUPT_LEVEL(0))
#define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION
#include <rtems/confdefs.h> #include <rtems/confdefs.h>
#endif #endif

View File

@@ -14,6 +14,8 @@
#define CONFIGURE_INIT #define CONFIGURE_INIT
#include "system.h" #include "system.h"
const char rtems_test_name[] = "CLOCK TICK";
/* /*
* Keep the names and IDs in global variables so another task can use them. * Keep the names and IDs in global variables so another task can use them.
*/ */
@@ -28,7 +30,7 @@ rtems_task Init(
rtems_status_code status; rtems_status_code status;
rtems_time_of_day time; rtems_time_of_day time;
puts( "\n\n*** CLOCK TICK TEST ***" ); TEST_BEGIN();
time.year = 1988; time.year = 1988;
time.month = 12; time.month = 12;

View File

@@ -12,6 +12,7 @@
*/ */
#include <rtems.h> #include <rtems.h>
#include <rtems/test.h>
#include <inttypes.h> #include <inttypes.h>
#include "tmacros.h" #include "tmacros.h"
@@ -48,6 +49,8 @@ extern rtems_name Task_name[ 4 ]; /* array of task names */
#define CONFIGURE_EXTRA_TASK_STACKS (3 * RTEMS_MINIMUM_STACK_SIZE) #define CONFIGURE_EXTRA_TASK_STACKS (3 * RTEMS_MINIMUM_STACK_SIZE)
#define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION
#include <rtems/confdefs.h> #include <rtems/confdefs.h>
/* /*

View File

@@ -37,7 +37,7 @@ rtems_task Test_task(
for ( ; ; ) { for ( ; ; ) {
status = rtems_clock_get_tod( &time ); status = rtems_clock_get_tod( &time );
if ( time.second >= 35 ) { if ( time.second >= 35 ) {
puts( "*** END OF CLOCK TICK TEST ***" ); TEST_END();
rtems_test_exit( 0 ); rtems_test_exit( 0 );
} }
put_name( Task_name[ task_index ], FALSE ); put_name( Task_name[ task_index ], FALSE );

View File

@@ -18,6 +18,8 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
const char rtems_test_name[] = "UNLIMITED TASK";
rtems_id task_id[MAX_TASKS]; rtems_id task_id[MAX_TASKS];
rtems_task Init( rtems_task Init(
@@ -28,14 +30,14 @@ rtems_task Init(
rtems_mode old_mode; rtems_mode old_mode;
uint32_t task; uint32_t task;
TEST_BEGIN();
/* lower the task priority to allow created tasks to execute */ /* lower the task priority to allow created tasks to execute */
rtems_task_set_priority( rtems_task_set_priority(
RTEMS_SELF, RTEMS_MAXIMUM_PRIORITY - 1, &old_priority); RTEMS_SELF, RTEMS_MAXIMUM_PRIORITY - 1, &old_priority);
rtems_task_mode(RTEMS_PREEMPT, RTEMS_PREEMPT_MASK, &old_mode); rtems_task_mode(RTEMS_PREEMPT, RTEMS_PREEMPT_MASK, &old_mode);
printf( "\n*** UNLIMITED TASK TEST ***\n" );
/* /*
* Invalid state if the task id is 0 * Invalid state if the task id is 0
*/ */
@@ -47,7 +49,7 @@ rtems_task Init(
test2(); test2();
test3(); test3();
printf( "\n*** END OF UNLIMITED TASK TEST ***\n" ); TEST_END();
exit( 0 ); exit( 0 );
} }