Install also the benchmark (Yocto)
[profile/ivi/persistence-client-library.git] / test / pers_test_base.h
1 /******************************************************************************
2  * Project         Persistency
3  * (c) copyright   2013
4  * Company         XS Embedded GmbH
5  *****************************************************************************/
6 /******************************************************************************
7  * This Source Code Form is subject to the terms of the
8  * Mozilla Public License, v. 2.0. If a  copy of the MPL was not distributed
9  * with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
10 ******************************************************************************/
11  /**
12  * @file           pers_test_base.h
13  * @ingroup        Persistence client library test
14  * @author         awehrle
15  * @brief          Test of persistence client library
16  * @see
17  */
18
19
20 #ifndef PERSBASETEST_H_
21 #define PERSBASETEST_H_
22
23 #include <stdbool.h>
24 #include <string.h>
25
26 #ifdef __cplusplus
27 extern "C" {
28 #endif
29
30 #define MAGIC_STRING "$$XS_TEST$$"
31
32 #define FAILED 0
33 #define PASSED 1
34 #define NONE 2
35
36 #define BORDER 0
37 #define GOOD 1
38
39 #define UNIT 0
40 #define COMPONENT 1
41
42 /**
43 * @brief: Report name of test. This has to be reported first.
44 * MANDATORY
45 */
46 #define X_TEST_REPORT_TEST_ID(ID) do { \
47 printf (MAGIC_STRING"%s", ID); \
48 printf ("\n"); \
49 } while(0)
50
51 /**
52 * @brief: Report name of test. This has to be reported first.
53 * MANDATORY
54 */
55 #define X_TEST_REPORT_TEST_NAME_ID(ID, ...) do { \
56 printf (MAGIC_STRING"%s$$", ID); \
57 printf ("testName:%s", __VA_ARGS__); \
58 printf ("\n"); \
59 } while(0)
60
61 /**
62 * @brief: Path to root of source code directory under test
63 * MANDATORY
64 */
65 #define X_TEST_REPORT_PATH_ID(ID, ...) do { \
66 printf (MAGIC_STRING"%s$$", ID); \
67 printf ("path:"__VA_ARGS__); \
68 printf ("\n"); \
69 } while(0)
70
71 /**
72 * @brief: Name of subcomponent under test, leave empty or set value NONE if not suitable for a COMPONENT test
73 * MANDATORY
74 */
75 #define X_TEST_REPORT_COMP_NAME_ID(ID, ...) do { \
76 printf (MAGIC_STRING"%s$$", ID); \
77 printf ("compName:"__VA_ARGS__); \
78 printf ("\n"); \
79 } while(0)
80
81 /**
82 * @brief: Name of class or file under test, leave empty or set value NONE for a COMPONENT test
83 * MANDATORY
84 */
85 #define X_TEST_REPORT_FILE_NAME_ID(ID, ...) do { \
86 printf (MAGIC_STRING"%s$$", ID); \
87 printf ("fileName:"__VA_ARGS__); \
88 printf ("\n"); \
89 } while(0)
90
91 /**
92 * @brief: If information exists: Reference to a requirement, feature or bug ID. Else leave empty or set value NONE
93 * MANDATORY
94 */
95 #define X_TEST_REPORT_REFERENCE_ID(ID, ...) do { \
96 printf (MAGIC_STRING"%s$$", ID); \
97 printf ("ref:"__VA_ARGS__); \
98 printf ("\n"); \
99 } while(0)
100
101 /**
102 * @brief: A short description of test case.
103 * Do not leave empty, can also be a internal department Test ID like CORE-OS-BOOT-0001
104 * MANDATORY
105 */
106 #define X_TEST_REPORT_DESCRIPTION_ID(ID, ...) do { \
107 printf (MAGIC_STRING"%s$$", ID); \
108 printf ("desc:"__VA_ARGS__); \
109 printf ("\n"); \
110 } while(0)
111
112 /**
113 * @brief: Reports weather this is a UNIT or a COMPONENT test
114 * MANDATORY
115 */
116 #define X_TEST_REPORT_KIND_ID(ID, kind) do { \
117 printf (MAGIC_STRING"%s$$kind:%s\n", ID, kind==UNIT?"UNIT":kind==COMPONENT?"COMPONENT":"NONE"); \
118 } while(0)
119
120 /**
121 * @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
122 * MANDATORY
123 */
124 #define X_TEST_REPORT_RESULT_ID(ID, result) do { \
125 printf (MAGIC_STRING"%s$$result:%s\n", ID, result==PASSED?"PASSED":result==FAILED?"FAILED":"NONE"); \
126 } while(0)
127
128 /**
129 * @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)
130 * OPTIONAL
131 */
132 #define X_TEST_REPORT_TYPE_ID(ID, type) do { \
133 printf (MAGIC_STRING"%s$$type:%s\n", ID, type==BORDER?"BORDER":"GOOD"); \
134 } while(0)
135
136 #ifdef __cplusplus
137 }
138 #endif
139
140 #endif /* PERSBASETEST_H_ */