summaryrefslogtreecommitdiffstats
path: root/cpukit/libmisc/testsupport/testbeginend.c
blob: 154df030ac819bf51d31eeedcac75d77824666d8 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
/*
 * Copyright (c) 2014, 2017 embedded brains GmbH.  All rights reserved.
 *
 *  embedded brains GmbH
 *  Dornierstr. 4
 *  82178 Puchheim
 *  Germany
 *  <rtems@embedded-brains.de>
 *
 * Copyright (c) 2017 Chris Johns <chrisj@rtems.org>. All rights reserved.
 *
 * 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/bspIo.h>
#include <rtems/version.h>

#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
#ifndef TEST_BUILD_DEFAULT
#define TEST_BUILD_DEFAULT "default"
#endif

#define TEST_BUILD_STRING \
         TEST_BUILD_DEFAULT \
         TEST_BUILD_POSIX \
         TEST_BUILD_SMP \
         TEST_BUILD_MP \
         TEST_BUILD_PARAVIRT \
         TEST_BUILD_NETWORKING \
         TEST_BUILD_DEBUG \
         TEST_BUILD_PROFILING

rtems_printer rtems_test_printer = {
  .printer = rtems_printk_printer
};

static const char* const test_state_strings[] =
{
  "EXPECTED-PASS",
  "EXPECTED-FAIL",
  "USER_INPUT",
  "INDETERMINATE",
  "BENCHMARK"
};

int rtems_test_begin(const char* name, const RTEMS_TEST_STATE state)
{
  int l;
  l = rtems_printf(
    &rtems_test_printer,
    "\n\n*** BEGIN OF TEST %s ***\n", name
  );
  l += rtems_printf(
    &rtems_test_printer,
    "*** TEST VERSION: %s\n", rtems_version()
  );
  l += rtems_printf(
    &rtems_test_printer,
    "*** TEST STATE: %s\n", test_state_strings[state]
  );
  l += rtems_printf(
    &rtems_test_printer,
    "*** TEST BUILD: %s\n", TEST_BUILD_STRING
  );
  l += rtems_printf(
    &rtems_test_printer,
    "*** TEST TOOLS: " __VERSION__ "\n"
  );
  return l;
}

int rtems_test_end(const char* name)
{
  return rtems_printf(
    &rtems_test_printer,
    "\n*** END OF TEST %s ***\n\n", name
  );
}

void rtems_test_exit(int status)
{
  (void) status;
  rtems_shutdown_executive(0);
}

int rtems_test_printf(
  const char* format,
  ...
)
{
  va_list ap;
  int len;
  va_start(ap, format);
  len = rtems_vprintf(
    &rtems_test_printer,
    format,
    ap
  );
  va_end(ap);
  return len;
}