diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2015-03-05 08:44:59 +0100 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2015-03-05 08:44:59 +0100 |
commit | 18d0a49129e8e70ba2c2bf169f91c92e93dabd84 (patch) | |
tree | aa78bcb03bd3c6e71e2321fda475d67a1d641033 /cpukit/libmisc | |
parent | score: Delete unused CPU_UNROLL_ENQUEUE_PRIORITY (diff) | |
download | rtems-18d0a49129e8e70ba2c2bf169f91c92e93dabd84.tar.bz2 |
Move test support from sapi to libmisc/testsupport
Diffstat (limited to 'cpukit/libmisc')
-rw-r--r-- | cpukit/libmisc/Makefile.am | 6 | ||||
-rw-r--r-- | cpukit/libmisc/testsupport/test.h | 125 | ||||
-rw-r--r-- | cpukit/libmisc/testsupport/testbeginend.c | 43 | ||||
-rw-r--r-- | cpukit/libmisc/testsupport/testextension.c | 72 |
4 files changed, 246 insertions, 0 deletions
diff --git a/cpukit/libmisc/Makefile.am b/cpukit/libmisc/Makefile.am index 8fc208f176..61def145d2 100644 --- a/cpukit/libmisc/Makefile.am +++ b/cpukit/libmisc/Makefile.am @@ -157,6 +157,12 @@ libstringto_a_SOURCES = stringto/stringtodouble.c stringto/stringtofloat.c \ stringto/stringtounsignedchar.c stringto/stringtounsignedlong.c \ stringto/stringtounsignedlonglong.c +## testsupport +noinst_LIBRARIES += libtestsupport.a +libtestsupport_a_SOURCES = +libtestsupport_a_SOURCES += testsupport/testbeginend.c +libtestsupport_a_SOURCES += testsupport/testextension.c + ## fsmount noinst_LIBRARIES += libfsmount.a libfsmount_a_SOURCES = fsmount/fsmount.c fsmount/fsmount.h diff --git a/cpukit/libmisc/testsupport/test.h b/cpukit/libmisc/testsupport/test.h new file mode 100644 index 0000000000..48a33a04e5 --- /dev/null +++ b/cpukit/libmisc/testsupport/test.h @@ -0,0 +1,125 @@ +/* + * Copyright (c) 2014 embedded brains GmbH. All rights reserved. + * + * embedded brains GmbH + * Dornierstr. 4 + * 82178 Puchheim + * Germany + * <rtems@embedded-brains.de> + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_TEST_H +#define _RTEMS_TEST_H + +#include <rtems.h> +#include <rtems/bspIo.h> + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/** + * @defgroup RTEMSTest Test Support + * + * @brief Test support functions. + * + * @{ + */ + +/** + * @brief Each test must define a test name string. + */ +extern const char rtems_test_name[]; + +/** + * @brief Fatal extension for tests. + */ +void rtems_test_fatal_extension( + rtems_fatal_source source, + bool is_internal, + rtems_fatal_code code +); + +/** + * @brief Initial extension for tests. + */ +#define RTEMS_TEST_INITIAL_EXTENSION \ + { NULL, NULL, NULL, NULL, NULL, NULL, NULL, rtems_test_fatal_extension } + +/** + * @brief Prints a begin of test message. + * + * @param[in] printf_func The formatted output function. + * @param[in, out] printf_arg The formatted output function argument. + * + * @returns As specified by printf(). + */ +int rtems_test_begin_with_plugin( + rtems_printk_plugin_t printf_func, + void *printf_arg +); + +/** + * @brief Prints a begin of test message using printf(). + * + * @returns As specified by printf(). + */ +static inline int rtems_test_begin(void) +{ + return rtems_test_begin_with_plugin(rtems_printf_plugin, NULL); +} + +/** + * @brief Prints a begin of test message using printk(). + * + * @returns As specified by printf(). + */ +static inline int rtems_test_begink(void) +{ + return rtems_test_begin_with_plugin(printk_plugin, NULL); +} + +/** + * @brief Prints an end of test message. + * + * @param[in] printf_func The formatted output function. + * @param[in, out] printf_arg The formatted output function argument. + * + * @returns As specified by printf(). + */ +int rtems_test_end_with_plugin( + rtems_printk_plugin_t printf_func, + void *printf_arg +); + +/** + * @brief Prints an end of test message using printf(). + * + * @returns As specified by printf(). + */ +static inline int rtems_test_end(void) +{ + return rtems_test_end_with_plugin(rtems_printf_plugin, NULL); +} + +/** + * @brief Prints an end of test message using printk(). + * + * @returns As specified by printf(). + */ +static inline int rtems_test_endk(void) +{ + return rtems_test_end_with_plugin(printk_plugin, NULL); +} + +/** @} */ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* _RTEMS_TEST_H */ diff --git a/cpukit/libmisc/testsupport/testbeginend.c b/cpukit/libmisc/testsupport/testbeginend.c new file mode 100644 index 0000000000..6383b33a78 --- /dev/null +++ b/cpukit/libmisc/testsupport/testbeginend.c @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2014 embedded brains GmbH. All rights reserved. + * + * embedded brains GmbH + * Dornierstr. 4 + * 82178 Puchheim + * Germany + * <rtems@embedded-brains.de> + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifdef HAVE_CONFIG_H + #include "config.h" +#endif + +#include <rtems/test.h> + +int rtems_test_begin_with_plugin( + rtems_printk_plugin_t printf_func, + void *printf_arg +) +{ + return (*printf_func)( + printf_arg, + "\n\n*** BEGIN OF TEST %s ***\n", + rtems_test_name + ); +} + +int rtems_test_end_with_plugin( + rtems_printk_plugin_t printf_func, + void *printf_arg +) +{ + return (*printf_func)( + printf_arg, + "*** END OF TEST %s ***\n", + rtems_test_name + ); +} diff --git a/cpukit/libmisc/testsupport/testextension.c b/cpukit/libmisc/testsupport/testextension.c new file mode 100644 index 0000000000..f59ae0d3ee --- /dev/null +++ b/cpukit/libmisc/testsupport/testextension.c @@ -0,0 +1,72 @@ +/* + * Copyright (c) 2014 embedded brains GmbH. All rights reserved. + * + * embedded brains GmbH + * Dornierstr. 4 + * 82178 Puchheim + * Germany + * <rtems@embedded-brains.de> + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifdef HAVE_CONFIG_H + #include "config.h" +#endif + +#include <rtems/test.h> +#include <rtems/profiling.h> + +#if defined(RTEMS_PROFILING) +static bool report_done; + +static rtems_interrupt_lock report_lock = + RTEMS_INTERRUPT_LOCK_INITIALIZER( "test report" ); +#endif + +void rtems_test_fatal_extension( + rtems_fatal_source source, + bool is_internal, + rtems_fatal_code code +) +{ +#if defined(RTEMS_PROFILING) + rtems_interrupt_lock_context lock_context; + + /* + * Ensures to report only once on SMP machines and ensures that the report is + * output completely. + */ + rtems_interrupt_lock_acquire( &report_lock, &lock_context ); + + if ( !report_done ) { + report_done = true; + + printk( + "\n*** PROFILING REPORT BEGIN %s ***\n", + rtems_test_name + ); + + rtems_profiling_report_xml( + rtems_test_name, + printk_plugin, + NULL, + 1, + " " + ); + + printk( + "*** PROFILING REPORT END %s ***\n", + rtems_test_name + ); + } + + rtems_interrupt_lock_release( &report_lock, &lock_context ); +#endif + + (void) source; + (void) is_internal; + (void) code; +} |