summaryrefslogtreecommitdiffstats
path: root/testsuites/support
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@OARcorp.com>2011-06-28 21:09:13 +0000
committerJoel Sherrill <joel.sherrill@OARcorp.com>2011-06-28 21:09:13 +0000
commit152a28418871061a20dabfc4c73990b96cf18e93 (patch)
tree1f5a2c1add0875a0631adc68fe19d5e83255e15e /testsuites/support
parent2011-06-28 Joel Sherrill <joel.sherrill@oarcorp.com> (diff)
downloadrtems-152a28418871061a20dabfc4c73990b96cf18e93.tar.bz2
2011-06-28 Joel Sherrill <joel.sherrill@oarcorp.com>
* configure.ac, support/include/test_support.h: * support/src/locked_print.c: New file.
Diffstat (limited to 'testsuites/support')
-rw-r--r--testsuites/support/include/test_support.h11
-rw-r--r--testsuites/support/src/locked_print.c87
2 files changed, 97 insertions, 1 deletions
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 );
+}