summaryrefslogtreecommitdiff
path: root/test/pers_test_base.h
blob: 83c7d95e0b0c38653ebfb9fa757936717c801b00 (plain)
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
/******************************************************************************
 * Project         Persistency
 * (c) copyright   2013
 * Company         XS Embedded GmbH
 *****************************************************************************/
/******************************************************************************
 * This Source Code Form is subject to the terms of the
 * Mozilla Public License, v. 2.0. If a  copy of the MPL was not distributed
 * with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
******************************************************************************/
 /**
 * @file           pers_test_base.h
 * @ingroup        Persistence client library test
 * @author         awehrle
 * @brief          Test of persistence client library
 * @see
 */


#ifndef PERSBASETEST_H_
#define PERSBASETEST_H_

#include <stdbool.h>
#include <string.h>

#ifdef __cplusplus
extern "C" {
#endif

#define MAGIC_STRING "$$XS_TEST$$"

#define FAILED 0
#define PASSED 1
#define NONE 2

#define BORDER 0
#define GOOD 1

#define UNIT 0
#define COMPONENT 1

/**
* @brief: Report name of test. This has to be reported first.
* MANDATORY
*/
#define X_TEST_REPORT_TEST_ID(ID) do { \
printf (MAGIC_STRING"%s", ID); \
printf ("\n"); \
} while(0)

/**
* @brief: Report name of test. This has to be reported first.
* MANDATORY
*/
#define X_TEST_REPORT_TEST_NAME_ID(ID, ...) do { \
printf (MAGIC_STRING"%s$$", ID); \
printf ("testName:%s", __VA_ARGS__); \
printf ("\n"); \
} while(0)

/**
* @brief: Path to root of source code directory under test
* MANDATORY
*/
#define X_TEST_REPORT_PATH_ID(ID, ...) do { \
printf (MAGIC_STRING"%s$$", ID); \
printf ("path:"__VA_ARGS__); \
printf ("\n"); \
} while(0)

/**
* @brief: Name of subcomponent under test, leave empty or set value NONE if not suitable for a COMPONENT test
* MANDATORY
*/
#define X_TEST_REPORT_COMP_NAME_ID(ID, ...) do { \
printf (MAGIC_STRING"%s$$", ID); \
printf ("compName:"__VA_ARGS__); \
printf ("\n"); \
} while(0)

/**
* @brief: Name of class or file under test, leave empty or set value NONE for a COMPONENT test
* MANDATORY
*/
#define X_TEST_REPORT_FILE_NAME_ID(ID, ...) do { \
printf (MAGIC_STRING"%s$$", ID); \
printf ("fileName:"__VA_ARGS__); \
printf ("\n"); \
} while(0)

/**
* @brief: If information exists: Reference to a requirement, feature or bug ID. Else leave empty or set value NONE
* MANDATORY
*/
#define X_TEST_REPORT_REFERENCE_ID(ID, ...) do { \
printf (MAGIC_STRING"%s$$", ID); \
printf ("ref:"__VA_ARGS__); \
printf ("\n"); \
} while(0)

/**
* @brief: A short description of test case.
* Do not leave empty, can also be a internal department Test ID like CORE-OS-BOOT-0001
* MANDATORY
*/
#define X_TEST_REPORT_DESCRIPTION_ID(ID, ...) do { \
printf (MAGIC_STRING"%s$$", ID); \
printf ("desc:"__VA_ARGS__); \
printf ("\n"); \
} while(0)

/**
* @brief: Reports weather this is a UNIT or a COMPONENT test
* MANDATORY
*/
#define X_TEST_REPORT_KIND_ID(ID, kind) do { \
printf (MAGIC_STRING"%s$$kind:%s\n", ID, kind==UNIT?"UNIT":kind==COMPONENT?"COMPONENT":"NONE"); \
} while(0)

/**
* @brief: valid values: PASSED, FAILED or NONE. PASSED if test result is ok, FAILED if test result is not as expected, NONE if no test exists for whole file or class
* MANDATORY
*/
#define X_TEST_REPORT_RESULT_ID(ID, result) do { \
printf (MAGIC_STRING"%s$$result:%s\n", ID, result==PASSED?"PASSED":result==FAILED?"FAILED":"NONE"); \
} while(0)

/**
* @brief: Additional information, if test "just" checks common information flow inside structure (GOOD test case) or if structure is tested with invalid or border values(BORDER)
* OPTIONAL
*/
#define X_TEST_REPORT_TYPE_ID(ID, type) do { \
printf (MAGIC_STRING"%s$$type:%s\n", ID, type==BORDER?"BORDER":"GOOD"); \
} while(0)

#ifdef __cplusplus
}
#endif

#endif /* PERSBASETEST_H_ */