blob: 415370860fe950322794a413a7c3ad0cdedaf6ec [file] [log] [blame]
Inaky Perez-Gonzalez8ddf82c2015-04-10 16:44:37 -07001/* tc_utilities.h - testcase utilities header file */
2
3/*
4 * Copyright (c) 2012-2015 Wind River Systems, Inc.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are met:
8 *
9 * 1) Redistributions of source code must retain the above copyright notice,
10 * this list of conditions and the following disclaimer.
11 *
12 * 2) Redistributions in binary form must reproduce the above copyright notice,
13 * this list of conditions and the following disclaimer in the documentation
14 * and/or other materials provided with the distribution.
15 *
16 * 3) Neither the name of Wind River Systems nor the names of its contributors
17 * may be used to endorse or promote products derived from this software without
18 * specific prior written permission.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
24 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30 * POSSIBILITY OF SUCH DAMAGE.
31 */
32
33#ifndef __TC_UTIL_H__
34#define __TC_UTIL_H__
35
36/* includes */
37
38#if defined(CONFIG_NANOKERNEL)
39#include <nanokernel.h>
40#else
41#include <microkernel.h>
42#endif
43
44#include <misc/printk.h>
45#include <string.h>
46
47/* defines */
48
49#define PRINT_DATA(fmt, ...) printk(fmt, ##__VA_ARGS__)
50
51#define PRINT_LINE \
52 PRINT_DATA( \
53 "============================================================" \
54 "=======\n")
55
56/* stack size and priority for test suite task */
57#define TASK_STACK_SIZE (1024 * 2)
58
59#define FAIL "FAIL"
60#define PASS "PASS"
61#define FMT_ERROR "%s - %s@%d. "
62
63#define TC_PASS 0
64#define TC_FAIL 1
65
66#define TC_ERROR(fmt, ...) \
67 do { \
68 PRINT_DATA(FMT_ERROR, FAIL, __func__, __LINE__); \
69 PRINT_DATA(fmt, ##__VA_ARGS__); \
70 } while (0)
71
72#define TC_PRINT(fmt, ...) PRINT_DATA(fmt, ##__VA_ARGS__)
73#define TC_START(name) PRINT_DATA("tc_start() - %s\n", name)
74#define TC_END(result, fmt, ...) PRINT_DATA(fmt, ##__VA_ARGS__)
75
76/* prints result and the function name */
77#define TC_END_RESULT(result) \
78 do { \
79 PRINT_LINE; \
80 TC_END(result, "%s - %s.\n", \
81 result == TC_PASS ? PASS : FAIL, __func__); \
82 } while (0)
83
84#define TC_END_REPORT(result) \
85 do { \
86 PRINT_LINE; \
87 TC_END(result, \
88 "VXMICRO PROJECT EXECUTION %s\n", \
89 result == TC_PASS ? "SUCCESSFUL" : "FAILED"); \
90 } while (0)
91
92#endif /* __TC_UTIL_H__ */