[PATCH 2/2] libmisc/testsupport: Add RTEMS version, build and tools to the tests.

Chris Johns chrisj at rtems.org
Sun Nov 5 07:45:10 UTC 2017


Output the RTEMS version, the build and the version of the tools
used to build the kernel and tests. This can be used by rtems-test
to manage the test results and provide better reporting.

Close #3217.
---
 cpukit/libmisc/testsupport/test.h           | 95 ++++++++++++++++++++++++++++-
 cpukit/libmisc/testsupport/testbeginend.c   | 22 ++++++-
 testsuites/Makefile.am                      |  2 +-
 testsuites/libtests/capture01/init.c        |  2 +-
 testsuites/libtests/complex/init.c          |  2 +-
 testsuites/libtests/math/init.c             |  2 +-
 testsuites/libtests/mathf/init.c            |  2 +-
 testsuites/libtests/mathl/init.c            |  2 +-
 testsuites/psxtests/include/pmacros.h       |  2 +-
 testsuites/samples/capture/init.c           |  2 +-
 testsuites/samples/hello/init.c             |  2 +-
 testsuites/samples/paranoia/init.c          |  2 +-
 testsuites/smptests/smp05/init.c            |  2 +-
 testsuites/smptests/smp07/init.c            |  2 +-
 testsuites/support/include/buffer_test_io.h | 90 ---------------------------
 testsuites/support/include/test_io.h        | 69 +++++++++++++++++++++
 testsuites/support/include/tmacros.h        |  2 +-
 17 files changed, 196 insertions(+), 106 deletions(-)
 delete mode 100644 testsuites/support/include/buffer_test_io.h
 create mode 100644 testsuites/support/include/test_io.h

diff --git a/cpukit/libmisc/testsupport/test.h b/cpukit/libmisc/testsupport/test.h
index d9ac6caf91..258667a923 100644
--- a/cpukit/libmisc/testsupport/test.h
+++ b/cpukit/libmisc/testsupport/test.h
@@ -18,6 +18,7 @@
 #include <rtems.h>
 #include <rtems/printer.h>
 #include <rtems/score/atomic.h>
+#include <rtems/score/cpuopts.h>
 #include <rtems/score/smpbarrier.h>
 
 #ifdef __cplusplus
@@ -58,6 +59,98 @@ void rtems_test_fatal_extension(
   { NULL, NULL, NULL, NULL, NULL, NULL, NULL, rtems_test_fatal_extension }
 
 /**
+ * @brief Build of the kernel. Print the test's build state and tools.
+ */
+#define TEST_BUILD_DEFAULT "default"
+#if RTEMS_POSIX
+  #define TEST_BUILD_DEFAULT ""
+  #define TEST_BUILD_POSIX   "posix "
+#else
+  #define TEST_BUILD_POSIX
+#endif
+#if RTEMS_SMP
+  #define TEST_BUILD_DEFAULT ""
+  #define TEST_BUILD_SMP     "smp "
+#else
+  #define TEST_BUILD_SMP
+#endif
+#if RTEMS_MULTIPROCESSING
+  #define TEST_BUILD_DEFAULT ""
+  #define TEST_BUILD_MP      "mp "
+#else
+  #define TEST_BUILD_MP
+#endif
+#if RTEMS_PARAVIRT
+  #define TEST_BUILD_DEFAULT  ""
+  #define TEST_BUILD_PARAVIRT "paravirt "
+#else
+  #define TEST_BUILD_PARAVIRT
+#endif
+#if RTEMS_NETWORKING
+  #define TEST_BUILD_DEFAULT    ""
+  #define TEST_BUILD_NETWORKING "legacy-net "
+#else
+  #define TEST_BUILD_NETWORKING
+#endif
+#if RTEMS_DEBUG
+  #define TEST_BUILD_DEFAULT ""
+  #define TEST_BUILD_DEBUG   "debug "
+#else
+  #define TEST_BUILD_DEBUG
+#endif
+#if RTEMS_PROFILING
+  #define TEST_BUILD_DEFAULT   ""
+  #define TEST_BUILD_PROFILING "profiling "
+#else
+  #define TEST_BUILD_PROFILING
+#endif
+
+#define TEST_BUILD_STRING \
+         "*** TEST BUILD: " TEST_BUILD_DEFAULT \
+         TEST_BUILD_POSIX \
+         TEST_BUILD_SMP \
+         TEST_BUILD_MP \
+         TEST_BUILD_PARAVIRT \
+         TEST_BUILD_NETWORKING \
+         TEST_BUILD_DEBUG \
+         TEST_BUILD_PROFILING \
+         "\n"
+
+/**
+ * @brief Tools being used to build the kernel and tests.
+ */
+#define TEST_TOOLS_STRING "*** TEST TOOLS: " __VERSION__ "\n"
+
+/**
+ * @brief Test states.
+ */
+#if (TEST_STATE_EXPECTED_FAIL && TEST_STATE_USER_INPUT) || \
+    (TEST_STATE_EXPECTED_FAIL && TEST_STATE_INDETERMINATE) || \
+    (TEST_STATE_EXPECTED_FAIL && TEST_STATE_BENCHMARK) || \
+    (TEST_STATE_USER_INPUT    && TEST_STATE_INDETERMINATE) || \
+    (TEST_STATE_USER_INPUT    && TEST_STATE_BENCHMARK) || \
+    (TEST_STATE_INDETERMINATE && TEST_STATE_BENCHMARK)
+  #error Test states must be unique
+#endif
+
+#if TEST_STATE_EXPECTED_FAIL
+  #define TEST_STATE_STRING "*** TEST STATE: EXPECTED-FAIL\n"
+#elif TEST_STATE_USER_INPUT
+  #define TEST_STATE_STRING "*** TEST STATE: USER_INPUT\n"
+#elif TEST_STATE_INDETERMINATE
+  #define TEST_STATE_STRING "*** TEST STATE: INDETERMINATE\n"
+#elif TEST_STATE_BENCHMARK
+  #define TEST_STATE_STRING "*** TEST STATE: BENCHMARK\n"
+#else
+  #define TEST_STATE_STRING "*** TEST STATE: EXPECTED-PASS\n"
+#endif
+
+/**
+ * @brief Version of RTEMS.
+ */
+#define TEST_VERSION_STRING "*** TEST VERSION: " RTEMS_VERSION "\n"
+
+/**
  * @brief Begin of test message format string.
  */
 #define TEST_BEGIN_STRING "\n\n*** BEGIN OF TEST %s ***\n", rtems_test_name
@@ -72,7 +165,7 @@ void rtems_test_fatal_extension(
  *
  * @returns As specified by printf().
  */
-int rtems_test_begin(void);
+int rtems_test_begin(const char* state);
 
 /**
  * @brief Prints an end of test message using printf().
diff --git a/cpukit/libmisc/testsupport/testbeginend.c b/cpukit/libmisc/testsupport/testbeginend.c
index ff64851c02..47f206804f 100644
--- a/cpukit/libmisc/testsupport/testbeginend.c
+++ b/cpukit/libmisc/testsupport/testbeginend.c
@@ -23,12 +23,30 @@ rtems_printer rtems_test_printer = {
   .printer = rtems_printk_printer
 };
 
-int rtems_test_begin(void)
+int rtems_test_begin(const char* state)
 {
-  return rtems_printf(
+  int l;
+  l = rtems_printf(
     &rtems_test_printer,
     TEST_BEGIN_STRING
   );
+  l += rtems_printf(
+    &rtems_test_printer,
+    TEST_VERSION_STRING
+  );
+  l += rtems_printf(
+    &rtems_test_printer,
+    TEST_STATE_STRING
+  );
+  l += rtems_printf(
+    &rtems_test_printer,
+    TEST_BUILD_STRING
+  );
+  l += rtems_printf(
+    &rtems_test_printer,
+    TEST_TOOLS_STRING
+  );
+  return l;
 }
 
 int rtems_test_end(void)
diff --git a/testsuites/Makefile.am b/testsuites/Makefile.am
index a466996fa4..4c6eaf1d93 100644
--- a/testsuites/Makefile.am
+++ b/testsuites/Makefile.am
@@ -4,7 +4,7 @@ DISTCLEANFILES =
 CLEANFILES =
 
 noinst_HEADERS =
-noinst_HEADERS += support/include/buffer_test_io.h
+noinst_HEADERS += support/include/test_io.h
 noinst_HEADERS += support/include/test_support.h
 noinst_HEADERS += support/include/tmacros.h
 noinst_HEADERS += support/include/pritime.h
diff --git a/testsuites/libtests/capture01/init.c b/testsuites/libtests/capture01/init.c
index a7a8e0c45a..aae3c1e4f7 100644
--- a/testsuites/libtests/capture01/init.c
+++ b/testsuites/libtests/capture01/init.c
@@ -48,7 +48,7 @@ rtems_task Init(
 
   rtems_print_printer_fprintf_putc(&rtems_test_printer);
 
-  rtems_test_begin();
+  rtems_test_begin(TEST_STATE_STRING);
 
   rtems_task_set_priority(RTEMS_SELF, 20, &old_priority);
   rtems_task_mode(RTEMS_PREEMPT,  RTEMS_PREEMPT_MASK, &old_mode);
diff --git a/testsuites/libtests/complex/init.c b/testsuites/libtests/complex/init.c
index 5f8ba34799..5a95db96f1 100644
--- a/testsuites/libtests/complex/init.c
+++ b/testsuites/libtests/complex/init.c
@@ -60,7 +60,7 @@ int main( void )
 {
 #if __rtems__
   rtems_print_printer_fprintf_putc(&rtems_test_printer);
-  rtems_test_begin();
+  rtems_test_begin(TEST_STATE_STRING);
 #endif
 
   docomplex();
diff --git a/testsuites/libtests/math/init.c b/testsuites/libtests/math/init.c
index fc493e86e7..c0364bdd99 100644
--- a/testsuites/libtests/math/init.c
+++ b/testsuites/libtests/math/init.c
@@ -62,7 +62,7 @@ int main( void )
 {
 #if __rtems__
   rtems_print_printer_fprintf_putc(&rtems_test_printer);
-  rtems_test_begin();
+  rtems_test_begin(TEST_STATE_STRING);
 #endif
 
   domath();
diff --git a/testsuites/libtests/mathf/init.c b/testsuites/libtests/mathf/init.c
index a553e25482..12c529d741 100644
--- a/testsuites/libtests/mathf/init.c
+++ b/testsuites/libtests/mathf/init.c
@@ -60,7 +60,7 @@ int main( void )
 {
 #if __rtems__
   rtems_print_printer_fprintf_putc(&rtems_test_printer);
-  rtems_test_begin();
+  rtems_test_begin(TEST_STATE_STRING);
 #endif
 
   domathf();
diff --git a/testsuites/libtests/mathl/init.c b/testsuites/libtests/mathl/init.c
index 7e239f3fbe..97a3d5da0c 100644
--- a/testsuites/libtests/mathl/init.c
+++ b/testsuites/libtests/mathl/init.c
@@ -60,7 +60,7 @@ int main( void )
 {
 #if __rtems__
   rtems_print_printer_fprintf_putc(&rtems_test_printer);
-  rtems_test_begin();
+  rtems_test_begin(TEST_STATE_STRING);
 #endif
 
   domathl();
diff --git a/testsuites/psxtests/include/pmacros.h b/testsuites/psxtests/include/pmacros.h
index 76e30f5392..13e0e0be12 100644
--- a/testsuites/psxtests/include/pmacros.h
+++ b/testsuites/psxtests/include/pmacros.h
@@ -20,7 +20,7 @@
 #include <unistd.h>
 
 #include <tmacros.h>
-#include <buffer_test_io.h>
+#include <test_io.h>
 
 /*
  *  These help manipulate the "struct tm" form of time
diff --git a/testsuites/samples/capture/init.c b/testsuites/samples/capture/init.c
index 3f2bc848b1..2adb85b209 100644
--- a/testsuites/samples/capture/init.c
+++ b/testsuites/samples/capture/init.c
@@ -47,7 +47,7 @@ rtems_task Init(
   rtems_mode          old_mode;
 
   rtems_print_printer_fprintf_putc(&rtems_test_printer);
-  rtems_test_begin();
+  rtems_test_begin(TEST_STATE_STRING);
 
   status = rtems_shell_wait_for_input(
     STDIN_FILENO,
diff --git a/testsuites/samples/hello/init.c b/testsuites/samples/hello/init.c
index 216a8b7e06..f67734a0c8 100644
--- a/testsuites/samples/hello/init.c
+++ b/testsuites/samples/hello/init.c
@@ -29,7 +29,7 @@ rtems_task Init(
 )
 {
   rtems_print_printer_fprintf_putc(&rtems_test_printer);
-  rtems_test_begin();
+  rtems_test_begin(TEST_STATE_STRING);
   printf( "Hello World\n" );
   rtems_test_end();
   exit( 0 );
diff --git a/testsuites/samples/paranoia/init.c b/testsuites/samples/paranoia/init.c
index c5110e2722..4847a8606a 100644
--- a/testsuites/samples/paranoia/init.c
+++ b/testsuites/samples/paranoia/init.c
@@ -36,7 +36,7 @@ rtems_task Init(
 #endif
 
   rtems_print_printer_fprintf_putc(&rtems_test_printer);
-  rtems_test_begin();
+  rtems_test_begin(TEST_STATE_STRING);
   paranoia(1, args);
   rtems_test_end();
   exit( 0 );
diff --git a/testsuites/smptests/smp05/init.c b/testsuites/smptests/smp05/init.c
index 7211e8ca88..40c225ef79 100644
--- a/testsuites/smptests/smp05/init.c
+++ b/testsuites/smptests/smp05/init.c
@@ -50,7 +50,7 @@ rtems_task Init(
   rtems_status_code  status;
 
   locked_print_initialize();
-  rtems_test_begin();
+  rtems_test_begin(TEST_STATE_STRING);
 
   if ( rtems_get_processor_count() == 1 ) {
     success();
diff --git a/testsuites/smptests/smp07/init.c b/testsuites/smptests/smp07/init.c
index 0dbf70b001..ec38344e11 100644
--- a/testsuites/smptests/smp07/init.c
+++ b/testsuites/smptests/smp07/init.c
@@ -98,7 +98,7 @@ rtems_task Init(
   rtems_id           Timer;
 
   locked_print_initialize();
-  rtems_test_begin();
+  rtems_test_begin(TEST_STATE_STRING);
 
   if ( rtems_get_processor_count() == 1 ) {
     success();
diff --git a/testsuites/support/include/buffer_test_io.h b/testsuites/support/include/buffer_test_io.h
deleted file mode 100644
index 1ff15f6ca8..0000000000
--- a/testsuites/support/include/buffer_test_io.h
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- *  Support for running the test output through a buffer
- */
-
-#ifndef __BUFFER_TEST_IO_h
-#define __BUFFER_TEST_IO_h
-
-#include <rtems/test.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/*
- * Test states. No state string is an expected pass.
- */
-#if (TEST_STATE_EXPECTED_FAIL && TEST_STATE_USER_INPUT) || \
-    (TEST_STATE_EXPECTED_FAIL && TEST_STATE_INDETERMINATE) || \
-    (TEST_STATE_EXPECTED_FAIL && TEST_STATE_BENCHMARK) || \
-    (TEST_STATE_USER_INPUT    && TEST_STATE_INDETERMINATE) || \
-    (TEST_STATE_USER_INPUT    && TEST_STATE_BENCHMARK) || \
-    (TEST_STATE_INDETERMINATE && TEST_STATE_BENCHMARK)
-  #error Test states must be unique
-#endif
-
-#if TEST_STATE_EXPECTED_FAIL
-  #define TEST_STATE_STRING "*** TEST STATE: EXPECTED-FAIL\n"
-#elif TEST_STATE_USER_INPUT
-  #define TEST_STATE_STRING "*** TEST STATE: USER_INPUT\n"
-#elif TEST_STATE_INDETERMINATE
-  #define TEST_STATE_STRING "*** TEST STATE: INDETERMINATE\n"
-#elif TEST_STATE_BENCHMARK
-  #define TEST_STATE_STRING "*** TEST STATE: BENCHMARK\n"
-#endif
-
-#undef printf
-#define printf(...) \
-  do { \
-     rtems_printf( &rtems_test_printer, __VA_ARGS__ ); \
-  } while (0)
-
-#undef puts
-#define puts(_s) \
-  do { \
-     rtems_printf( &rtems_test_printer, "%s\n", _s ); \
-  } while (0)
-
-#undef putchar
-#define putchar(_c) \
-  do { \
-     rtems_printf( &rtems_test_printer, "%c", _c ); \
-  } while (0)
-
-/* Do not call exit() since it closes stdin, etc and pulls in stdio code */
-#define rtems_test_exit(_s) \
-  do { \
-    rtems_shutdown_executive(0); \
-  } while (0)
-
-#define FLUSH_OUTPUT() \
-  do { \
-  } while (0)
-
-#if defined(TEST_STATE_STRING)
-  #define TEST_BEGIN() \
-  do { \
-    rtems_printf( &rtems_test_printer, "\n"); \
-    rtems_printf( &rtems_test_printer, TEST_BEGIN_STRING ); \
-    rtems_printf( &rtems_test_printer, TEST_STATE_STRING ); \
-  } while (0)
-#else
-  #define TEST_BEGIN() \
-  do { \
-    rtems_printf( &rtems_test_printer, "\n" ); \
-    rtems_printf( &rtems_test_printer, TEST_BEGIN_STRING ); \
-  } while (0)
-#endif
-
-#define TEST_END() \
-  do { \
-     rtems_printf( &rtems_test_printer, "\n" ); \
-     rtems_printf( &rtems_test_printer, TEST_END_STRING ); \
-     rtems_printf( &rtems_test_printer, "\n" ); \
-  } while (0)
-
-#ifdef __cplusplus
-};
-#endif
-
-#endif
diff --git a/testsuites/support/include/test_io.h b/testsuites/support/include/test_io.h
new file mode 100644
index 0000000000..5d9e78e452
--- /dev/null
+++ b/testsuites/support/include/test_io.h
@@ -0,0 +1,69 @@
+/*
+ *  Support for running the test output through a buffer
+ */
+
+#ifndef __BUFFER_TEST_IO_h
+#define __BUFFER_TEST_IO_h
+
+#include <rtems/test.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#undef printf
+#define printf(...) \
+  do { \
+     rtems_printf( &rtems_test_printer, __VA_ARGS__ ); \
+  } while (0)
+
+#undef puts
+#define puts(_s) \
+  do { \
+     rtems_printf( &rtems_test_printer, "%s\n", _s ); \
+  } while (0)
+
+#undef putchar
+#define putchar(_c) \
+  do { \
+     rtems_printf( &rtems_test_printer, "%c", _c ); \
+  } while (0)
+
+/* Do not call exit() since it closes stdin, etc and pulls in stdio code */
+#define rtems_test_exit(_s) \
+  do { \
+    rtems_shutdown_executive(0); \
+  } while (0)
+
+#define FLUSH_OUTPUT() \
+  do { \
+  } while (0)
+
+#if defined(TEST_STATE_STRING)
+  #define TEST_BEGIN_STATE_PRINT() rtems_printf( &rtems_test_printer, TEST_STATE_STRING )
+#else
+  #define TEST_BEGIN_STATE_PRINT()
+#endif
+
+#define TEST_BEGIN() \
+do { \
+  rtems_printf( &rtems_test_printer, "\n"); \
+  rtems_printf( &rtems_test_printer, TEST_BEGIN_STRING ); \
+  rtems_printf( &rtems_test_printer, TEST_VERSION_STRING ); \
+  TEST_BEGIN_STATE_PRINT(); \
+  rtems_printf( &rtems_test_printer, TEST_BUILD_STRING ); \
+  rtems_printf( &rtems_test_printer, TEST_TOOLS_STRING ); \
+} while (0)
+
+#define TEST_END() \
+  do { \
+     rtems_printf( &rtems_test_printer, "\n" ); \
+     rtems_printf( &rtems_test_printer, TEST_END_STRING ); \
+     rtems_printf( &rtems_test_printer, "\n" ); \
+  } while (0)
+
+#ifdef __cplusplus
+};
+#endif
+
+#endif
diff --git a/testsuites/support/include/tmacros.h b/testsuites/support/include/tmacros.h
index 354d4cf60f..934f4c8309 100644
--- a/testsuites/support/include/tmacros.h
+++ b/testsuites/support/include/tmacros.h
@@ -29,7 +29,7 @@
 #include <rtems/test.h>
 #include <rtems/score/threaddispatch.h>
 
-#include <buffer_test_io.h>
+#include <test_io.h>
 
 #ifdef __cplusplus
 extern "C" {
-- 
2.13.2




More information about the devel mailing list