]> git.saurik.com Git - apple/icu.git/blob - icuSources/tools/ctestfw/unicode/ctest.h
ICU-400.38.tar.gz
[apple/icu.git] / icuSources / tools / ctestfw / unicode / ctest.h
1 /*
2 ********************************************************************************
3 *
4 * Copyright (C) 1996-2008, International Business Machines
5 * Corporation and others. All Rights Reserved.
6 *
7 ********************************************************************************
8 */
9
10 #ifndef CTEST_H
11 #define CTEST_H
12
13 #include "unicode/testtype.h"
14 #include "unicode/utrace.h"
15
16
17 /* prototypes *********************************/
18
19 U_CDECL_BEGIN
20 typedef void (U_CALLCONV *TestFunctionPtr)(void);
21 typedef int (U_CALLCONV *ArgHandlerPtr)(int arg, int argc, const char* const argv[], void *context);
22 typedef struct TestNode TestNode;
23 U_CDECL_END
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 */
31 extern T_CTEST_EXPORT_API int REPEAT_TESTS;
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 */
39 extern T_CTEST_EXPORT_API int VERBOSITY;
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 */
47 extern T_CTEST_EXPORT_API int ERR_MSG;
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 */
55 extern T_CTEST_EXPORT_API int QUICK;
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 */
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;
73
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
89 /**
90 * Show the names of all nodes.
91 *
92 * @param root Subtree of tests.
93 * @internal Internal APIs for testing purpose only
94 */
95 T_CTEST_API void T_CTEST_EXPORT2
96 showTests ( const TestNode *root);
97
98 /**
99 * Run a subtree of tests.
100 *
101 * @param root Subtree of tests.
102 * @internal Internal APIs for testing purpose only
103 */
104 T_CTEST_API void T_CTEST_EXPORT2
105 runTests ( const TestNode* root);
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 */
119 T_CTEST_API void T_CTEST_EXPORT2
120 addTest(TestNode** root,
121 TestFunctionPtr test,
122 const char *path);
123
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);
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 */
141 T_CTEST_API const TestNode* T_CTEST_EXPORT2
142 getTest(const TestNode* root,
143 const char *path);
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 */
151 T_CTEST_API void T_CTEST_EXPORT2
152 log_err(const char* pattern, ...);
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 */
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);
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 */
178 T_CTEST_API void T_CTEST_EXPORT2
179 log_verbose(const char* pattern, ...);
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 */
188 T_CTEST_API void T_CTEST_EXPORT2
189 log_data_err(const char *pattern, ...);
190
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
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 */
212 T_CTEST_API int T_CTEST_EXPORT2
213 runTestRequest(const TestNode* root,
214 int argc,
215 const char* const argv[]);
216
217
218 T_CTEST_API const char* T_CTEST_EXPORT2
219 getTestName(void);
220
221
222
223 #endif