]>
Commit | Line | Data |
---|---|---|
b75a7d8f | 1 | /* |
46f4442e A |
2 | ******************************************************************************** |
3 | * | |
4 | * Copyright (C) 1996-2008, International Business Machines | |
5 | * Corporation and others. All Rights Reserved. | |
6 | * | |
7 | ******************************************************************************** | |
8 | */ | |
b75a7d8f | 9 | |
b75a7d8f A |
10 | #ifndef CTEST_H |
11 | #define CTEST_H | |
12 | ||
374ca955 A |
13 | #include "unicode/testtype.h" |
14 | #include "unicode/utrace.h" | |
b75a7d8f A |
15 | |
16 | ||
17 | /* prototypes *********************************/ | |
18 | ||
374ca955 A |
19 | U_CDECL_BEGIN |
20 | typedef void (U_CALLCONV *TestFunctionPtr)(void); | |
46f4442e | 21 | typedef int (U_CALLCONV *ArgHandlerPtr)(int arg, int argc, const char* const argv[], void *context); |
b75a7d8f | 22 | typedef struct TestNode TestNode; |
374ca955 | 23 | U_CDECL_END |
b75a7d8f A |
24 | |
25 | /** | |
26 | * Set this to zero to disable log_verbose() messages. | |
27 | * Otherwise nonzero to see log_verbose() messages. | |
28 | * | |
29 | * @internal Internal APIs for testing purpose only | |
30 | */ | |
374ca955 | 31 | extern T_CTEST_EXPORT_API int REPEAT_TESTS; |
b75a7d8f A |
32 | |
33 | /** | |
34 | * Set this to zero to disable log_verbose() messages. | |
35 | * Otherwise nonzero to see log_verbose() messages. | |
36 | * | |
37 | * @internal Internal APIs for testing purpose only | |
38 | */ | |
374ca955 | 39 | extern T_CTEST_EXPORT_API int VERBOSITY; |
b75a7d8f A |
40 | |
41 | /** | |
42 | * Set this to zero to disable log_verbose() messages. | |
43 | * Otherwise nonzero to see log_verbose() messages. | |
44 | * | |
45 | * @internal Internal APIs for testing purpose only | |
46 | */ | |
374ca955 | 47 | extern T_CTEST_EXPORT_API int ERR_MSG; |
b75a7d8f A |
48 | |
49 | /** | |
50 | * Set this to zero to disable some of the slower tests. | |
51 | * Otherwise nonzero to run the slower tests. | |
52 | * | |
53 | * @internal Internal APIs for testing purpose only | |
54 | */ | |
374ca955 | 55 | extern T_CTEST_EXPORT_API int QUICK; |
b75a7d8f A |
56 | |
57 | /** | |
58 | * Set this to nonzero to warn (not error) on missing data. | |
59 | * Otherwise, zero will cause an error to be propagated when data is not available. | |
60 | * Affects the behavior of log_dataerr. | |
61 | * | |
62 | * @see log_data_err | |
63 | * @internal Internal APIs for testing purpose only | |
64 | */ | |
374ca955 A |
65 | extern T_CTEST_EXPORT_API int WARN_ON_MISSING_DATA; |
66 | ||
67 | /** | |
68 | * ICU tracing level, is set by command line option | |
69 | * | |
70 | * @internal | |
71 | */ | |
72 | extern T_CTEST_EXPORT_API UTraceLevel ICU_TRACE; | |
b75a7d8f | 73 | |
46f4442e A |
74 | /** |
75 | * Maximum amount of memory uprv_malloc should allocate before returning NULL. | |
76 | * | |
77 | * @internal | |
78 | */ | |
79 | extern T_CTEST_EXPORT_API size_t MAX_MEMORY_ALLOCATION; | |
80 | ||
81 | /** | |
82 | * If memory tracing was enabled, contains the number of unfreed allocations. | |
83 | * | |
84 | * @internal | |
85 | */ | |
86 | extern T_CTEST_EXPORT_API int32_t ALLOCATION_COUNT; | |
87 | ||
88 | ||
b75a7d8f A |
89 | /** |
90 | * Show the names of all nodes. | |
91 | * | |
92 | * @param root Subtree of tests. | |
93 | * @internal Internal APIs for testing purpose only | |
94 | */ | |
374ca955 A |
95 | T_CTEST_API void T_CTEST_EXPORT2 |
96 | showTests ( const TestNode *root); | |
b75a7d8f A |
97 | |
98 | /** | |
99 | * Run a subtree of tests. | |
100 | * | |
101 | * @param root Subtree of tests. | |
102 | * @internal Internal APIs for testing purpose only | |
103 | */ | |
374ca955 A |
104 | T_CTEST_API void T_CTEST_EXPORT2 |
105 | runTests ( const TestNode* root); | |
b75a7d8f A |
106 | |
107 | /** | |
108 | * Add a test to the subtree. | |
109 | * Example usage: | |
110 | * <PRE> | |
111 | * TestNode* root=NULL; | |
112 | * addTest(&root, &mytest, "/a/b/mytest" ); | |
113 | * </PRE> | |
114 | * @param root Pointer to the root pointer. | |
115 | * @param test Pointer to 'void function(void)' for actual test. | |
116 | * @param path Path from root under which test will be placed. Ex. '/a/b/mytest' | |
117 | * @internal Internal APIs for testing purpose only | |
118 | */ | |
374ca955 A |
119 | T_CTEST_API void T_CTEST_EXPORT2 |
120 | addTest(TestNode** root, | |
121 | TestFunctionPtr test, | |
122 | const char *path); | |
b75a7d8f | 123 | |
374ca955 A |
124 | /** |
125 | * Clean up any allocated memory. | |
126 | * Conditions for calling this function are the same as u_cleanup(). | |
127 | * @see u_cleanup | |
128 | * @internal Internal APIs for testing purpose only | |
129 | */ | |
130 | T_CTEST_API void T_CTEST_EXPORT2 | |
131 | cleanUpTestTree(TestNode *tn); | |
b75a7d8f A |
132 | |
133 | /** | |
134 | * Retreive a specific subtest. (subtree). | |
135 | * | |
136 | * @param root Pointer to the root. | |
137 | * @param path Path relative to the root, Ex. '/a/b' | |
138 | * @return The subtest, or NULL on failure. | |
139 | * @internal Internal APIs for testing purpose only | |
140 | */ | |
374ca955 A |
141 | T_CTEST_API const TestNode* T_CTEST_EXPORT2 |
142 | getTest(const TestNode* root, | |
143 | const char *path); | |
b75a7d8f A |
144 | |
145 | ||
146 | /** | |
147 | * Log an error message. (printf style) | |
148 | * @param pattern printf-style format string | |
149 | * @internal Internal APIs for testing purpose only | |
150 | */ | |
374ca955 A |
151 | T_CTEST_API void T_CTEST_EXPORT2 |
152 | log_err(const char* pattern, ...); | |
b75a7d8f A |
153 | |
154 | /** | |
155 | * Log an informational message. (printf style) | |
156 | * @param pattern printf-style format string | |
157 | * @internal Internal APIs for testing purpose only | |
158 | */ | |
374ca955 A |
159 | T_CTEST_API void T_CTEST_EXPORT2 |
160 | log_info(const char* pattern, ...); | |
161 | ||
162 | /** | |
163 | * Log an informational message. (vprintf style) | |
164 | * @param prefix a string that is output before the pattern and without formatting | |
165 | * @param pattern printf-style format string | |
166 | * @param ap variable-arguments list | |
167 | * @internal Internal APIs for testing purpose only | |
168 | */ | |
169 | T_CTEST_API void T_CTEST_EXPORT2 | |
170 | vlog_info(const char *prefix, const char *pattern, va_list ap); | |
b75a7d8f A |
171 | |
172 | /** | |
173 | * Log a verbose informational message. (printf style) | |
174 | * This message will only appear if the global VERBOSITY is nonzero | |
175 | * @param pattern printf-style format string | |
176 | * @internal Internal APIs for testing purpose only | |
177 | */ | |
374ca955 A |
178 | T_CTEST_API void T_CTEST_EXPORT2 |
179 | log_verbose(const char* pattern, ...); | |
b75a7d8f A |
180 | |
181 | /** | |
182 | * Log an error message concerning missing data. (printf style) | |
183 | * If WARN_ON_MISSING_DATA is nonzero, this will case a log_info (warning) to be | |
184 | * printed, but if it is zero this will produce an error (log_err). | |
185 | * @param pattern printf-style format string | |
186 | * @internal Internal APIs for testing purpose only | |
187 | */ | |
374ca955 A |
188 | T_CTEST_API void T_CTEST_EXPORT2 |
189 | log_data_err(const char *pattern, ...); | |
b75a7d8f | 190 | |
46f4442e A |
191 | /** |
192 | * Initialize the variables above. This allows the test to set up accordingly | |
193 | * before running the tests. | |
194 | * This must be called before runTests. | |
195 | */ | |
196 | T_CTEST_API int T_CTEST_EXPORT2 | |
197 | initArgs( int argc, const char* const argv[], ArgHandlerPtr argHandler, void *context); | |
198 | ||
b75a7d8f A |
199 | /** |
200 | * Processes the command line arguments. | |
201 | * This is a sample implementation | |
202 | * <PRE>Usage: %s [ -l ] [ -v ] [ -? ] [ /path/to/test ] | |
203 | * -l List only, do not run\ | |
204 | * -v turn OFF verbosity | |
205 | * -? print this message</PRE> | |
206 | * @param root Testnode root with tests already attached to it | |
207 | * @param argv argument list from main (stdio.h) | |
208 | * @param argc argument list count from main (stdio.h) | |
209 | * @return positive for error count, 0 for success, negative for illegal argument | |
210 | * @internal Internal APIs for testing purpose only | |
211 | */ | |
374ca955 | 212 | T_CTEST_API int T_CTEST_EXPORT2 |
46f4442e | 213 | runTestRequest(const TestNode* root, |
374ca955 A |
214 | int argc, |
215 | const char* const argv[]); | |
b75a7d8f A |
216 | |
217 | ||
374ca955 A |
218 | T_CTEST_API const char* T_CTEST_EXPORT2 |
219 | getTestName(void); | |
b75a7d8f A |
220 | |
221 | ||
222 | ||
223 | #endif |