summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--testsuites/ChangeLog5
-rw-r--r--testsuites/configure.ac4
-rw-r--r--testsuites/support/include/test_support.h11
-rw-r--r--testsuites/support/src/locked_print.c87
4 files changed, 106 insertions, 1 deletions
diff --git a/testsuites/ChangeLog b/testsuites/ChangeLog
index 5ed16e6ea5..72a3d9d5da 100644
--- a/testsuites/ChangeLog
+++ b/testsuites/ChangeLog
@@ -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
diff --git a/testsuites/configure.ac b/testsuites/configure.ac
index 001aab1691..2e0d3e1fa9 100644
--- a/testsuites/configure.ac
+++ b/testsuites/configure.ac
@@ -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
diff --git a/testsuites/support/include/test_support.h b/testsuites/support/include/test_support.h
index 412226c9fe..8329f7f803 100644
--- a/testsuites/support/include/test_support.h
+++ b/testsuites/support/include/test_support.h
@@ -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
diff --git a/testsuites/support/src/locked_print.c b/testsuites/support/src/locked_print.c
new file mode 100644
index 0000000000..52e6729509
--- /dev/null
+++ b/testsuites/support/src/locked_print.c
@@ -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 );
+}