source: rtems/cpukit/libmisc/testsupport/testbeginend.c @ bcd0c06c

5
Last change on this file since bcd0c06c was bcd0c06c, checked in by Chris Johns <chrisj@…>, on 11/07/17 at 21:25:36

tests: Use rtems_test_begin and rtems_test_end.

Add a tests enum and move all test banner test to the library in libmisc.

Update #3199.

  • Property mode set to 100644
File size: 2.8 KB
Line 
1/*
2 * Copyright (c) 2014, 2017 embedded brains GmbH.  All rights reserved.
3 *
4 *  embedded brains GmbH
5 *  Dornierstr. 4
6 *  82178 Puchheim
7 *  Germany
8 *  <rtems@embedded-brains.de>
9 *
10 * Copyright (c) 2017 Chris Johns <chrisj@rtems.org>. All rights reserved.
11 *
12 * The license and distribution terms for this file may be
13 * found in the file LICENSE in this distribution or at
14 * http://www.rtems.org/license/LICENSE.
15 */
16
17#ifdef HAVE_CONFIG_H
18  #include "config.h"
19#endif
20
21#include <rtems/test.h>
22#include <rtems/bspIo.h>
23#include <rtems/version.h>
24
25#define TEST_BUILD_DEFAULT "default"
26#if RTEMS_POSIX
27  #define TEST_BUILD_DEFAULT ""
28  #define TEST_BUILD_POSIX   "posix "
29#else
30  #define TEST_BUILD_POSIX
31#endif
32#if RTEMS_SMP
33  #define TEST_BUILD_DEFAULT ""
34  #define TEST_BUILD_SMP     "smp "
35#else
36  #define TEST_BUILD_SMP
37#endif
38#if RTEMS_MULTIPROCESSING
39  #define TEST_BUILD_DEFAULT ""
40  #define TEST_BUILD_MP      "mp "
41#else
42  #define TEST_BUILD_MP
43#endif
44#if RTEMS_PARAVIRT
45  #define TEST_BUILD_DEFAULT  ""
46  #define TEST_BUILD_PARAVIRT "paravirt "
47#else
48  #define TEST_BUILD_PARAVIRT
49#endif
50#if RTEMS_NETWORKING
51  #define TEST_BUILD_DEFAULT    ""
52  #define TEST_BUILD_NETWORKING "legacy-net "
53#else
54  #define TEST_BUILD_NETWORKING
55#endif
56#if RTEMS_DEBUG
57  #define TEST_BUILD_DEFAULT ""
58  #define TEST_BUILD_DEBUG   "debug "
59#else
60  #define TEST_BUILD_DEBUG
61#endif
62#if RTEMS_PROFILING
63  #define TEST_BUILD_DEFAULT   ""
64  #define TEST_BUILD_PROFILING "profiling "
65#else
66  #define TEST_BUILD_PROFILING
67#endif
68
69#define TEST_BUILD_STRING \
70         TEST_BUILD_DEFAULT \
71         TEST_BUILD_POSIX \
72         TEST_BUILD_SMP \
73         TEST_BUILD_MP \
74         TEST_BUILD_PARAVIRT \
75         TEST_BUILD_NETWORKING \
76         TEST_BUILD_DEBUG \
77         TEST_BUILD_PROFILING
78
79rtems_printer rtems_test_printer = {
80  .printer = rtems_printk_printer
81};
82
83static const char* const test_state_strings[] =
84{
85  "EXPECTED-PASS",
86  "EXPECTED-FAIL",
87  "USER_INPUT",
88  "INDETERMINATE",
89  "BENCHMARK"
90};
91
92int rtems_test_begin(const char* name, const RTEMS_TEST_STATE state)
93{
94  int l;
95  l = rtems_printf(
96    &rtems_test_printer,
97    "\n\n*** BEGIN OF TEST %s ***\n", name
98  );
99  l += rtems_printf(
100    &rtems_test_printer,
101    "*** TEST VERSION: %s\n", rtems_version()
102  );
103  l += rtems_printf(
104    &rtems_test_printer,
105    "*** TEST STATE: %s\n", test_state_strings[state]
106  );
107  l += rtems_printf(
108    &rtems_test_printer,
109    "*** TEST BUILD: %s\n", TEST_BUILD_STRING
110  );
111  l += rtems_printf(
112    &rtems_test_printer,
113    "*** TEST TOOLS: " __VERSION__ "\n"
114  );
115  return l;
116}
117
118int rtems_test_end(const char* name)
119{
120  return rtems_printf(
121    &rtems_test_printer,
122    "\n*** END OF TEST %s ***\n\n", name
123  );
124}
125
126int rtems_test_printf(
127  const char* format,
128  ...
129)
130{
131  va_list ap;
132  int len;
133  va_start(ap, format);
134  len = rtems_vprintf(
135    &rtems_test_printer,
136    format,
137    ap
138  );
139  va_end(ap);
140  return len;
141}
Note: See TracBrowser for help on using the repository browser.