2011-06-28 Joel Sherrill <joel.sherrill@oarcorp.com>

* configure.ac, support/include/test_support.h:
	* support/src/locked_print.c: New file.
This commit is contained in:
Joel Sherrill
2011-06-28 21:09:13 +00:00
parent e049eeae90
commit 152a284188
4 changed files with 106 additions and 1 deletions

View File

@@ -1,3 +1,8 @@
2011-06-28 Joel Sherrill <joel.sherrill@oarcorp.com>
* configure.ac, support/include/test_support.h:
* support/src/locked_print.c: New file.
2011-04-27 Jennifer Averett <Jennifer.Averett@OARcorp.com>
PR 1784

View File

@@ -25,6 +25,7 @@ RTEMS_PROG_CC
RTEMS_CHECK_CPUOPTS([RTEMS_POSIX_API])
RTEMS_CHECK_CPUOPTS([RTEMS_MULTIPROCESSING])
RTEMS_CHECK_CPUOPTS([RTEMS_NETWORKING])
RTEMS_CHECK_CPUOPTS([RTEMS_SMP])
case $enable_tests in
yes | samples )
@@ -38,6 +39,9 @@ if test "$enable_tests" = "yes"; then
if test "$rtems_cv_RTEMS_MULTIPROCESSING" = "yes"; then
AC_CONFIG_SUBDIRS(mptests)
fi
if test "$rtems_cv_RTEMS_SMP" = "yes"; then
AC_CONFIG_SUBDIRS(smptests)
fi
# Now do performance tests
AC_CONFIG_SUBDIRS(tmtests psxtmtests)
fi

View File

@@ -1,5 +1,5 @@
/*
* COPYRIGHT (c) 1989-2010.
* COPYRIGHT (c) 1989-2011.
* On-Line Applications Research Corporation (OAR).
*
* The license and distribution terms for this file may be
@@ -80,6 +80,15 @@ void rtems_time_test_measure_operation(
int overhead
);
/*********************************************************************/
/*********************************************************************/
/************** TEST SUPPORT **************/
/*********************************************************************/
/*********************************************************************/
extern void locked_print_init(void);
extern void locked_printf(const char *fmt, ...);
extern void locked_printk(const char *fmt, ...);
#ifdef __cplusplus
};
#endif

View File

@@ -0,0 +1,87 @@
/*
* COPYRIGHT (c) 1989-2011.
* On-Line Applications Research Corporation (OAR).
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rtems.com/license/LICENSE.
*
* $Id$
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <rtems.h>
#include <rtems/system.h>
#include <sys/types.h>
#include <string.h>
#include <stdarg.h>
#include "tmacros.h"
static rtems_id locked_print_semaphore; /* synchronisation semaphore */
void locked_print_initialize(void)
{
rtems_status_code sc;
static bool initted = false;
if ( initted )
return;
initted = true;
/* Create/verify synchronisation semaphore */
sc = rtems_semaphore_create(
rtems_build_name ('S', 'E', 'M', '1'),
1,
RTEMS_LOCAL |
RTEMS_SIMPLE_BINARY_SEMAPHORE |
RTEMS_PRIORITY,
1,
&locked_print_semaphore
);
directive_failed( sc, "rtems_semaphore_create" );
}
void locked_printf(const char *fmt, ...) {
va_list ap; /* points to each unnamed argument in turn */
rtems_status_code sc;
locked_print_initialize();
/* Lock semaphore without releasing the cpu */
do {
sc = rtems_semaphore_obtain( locked_print_semaphore, RTEMS_NO_WAIT, 0 );
} while (sc != RTEMS_SUCCESSFUL );
va_start(ap, fmt); /* make ap point to 1st unnamed arg */
vprintf(fmt, ap);
va_end(ap); /* clean up when done */
/* Release the semaphore */
sc = rtems_semaphore_release( locked_print_semaphore );
}
void locked_printk(const char *fmt, ...) {
va_list ap; /* points to each unnamed argument in turn */
rtems_status_code sc;
locked_print_initialize();
/* Lock semaphore without releasing the cpu */
do {
sc = rtems_semaphore_obtain( locked_print_semaphore, RTEMS_NO_WAIT, 0 );
} while (sc != RTEMS_SUCCESSFUL );
va_start(ap, fmt); /* make ap point to 1st unnamed arg */
vprintk(fmt, ap);
va_end(ap); /* clean up when done */
/* Release the semaphore */
sc = rtems_semaphore_release( locked_print_semaphore );
}