]> git.saurik.com Git - apple/icu.git/blame - icuSources/tools/ctestfw/unicode/ctest.h
ICU-400.42.tar.gz
[apple/icu.git] / icuSources / tools / ctestfw / unicode / ctest.h
CommitLineData
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
19U_CDECL_BEGIN
20typedef void (U_CALLCONV *TestFunctionPtr)(void);
46f4442e 21typedef int (U_CALLCONV *ArgHandlerPtr)(int arg, int argc, const char* const argv[], void *context);
b75a7d8f 22typedef struct TestNode TestNode;
374ca955 23U_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 31extern 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 39extern 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 47extern 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 55extern 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
65extern 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 */
72extern 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 */
79extern 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 */
86extern 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
95T_CTEST_API void T_CTEST_EXPORT2
96showTests ( 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
104T_CTEST_API void T_CTEST_EXPORT2
105runTests ( 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
119T_CTEST_API void T_CTEST_EXPORT2
120addTest(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 */
130T_CTEST_API void T_CTEST_EXPORT2
131cleanUpTestTree(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
141T_CTEST_API const TestNode* T_CTEST_EXPORT2
142getTest(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
151T_CTEST_API void T_CTEST_EXPORT2
152log_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
159T_CTEST_API void T_CTEST_EXPORT2
160log_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 */
169T_CTEST_API void T_CTEST_EXPORT2
170vlog_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
178T_CTEST_API void T_CTEST_EXPORT2
179log_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
188T_CTEST_API void T_CTEST_EXPORT2
189log_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 */
196T_CTEST_API int T_CTEST_EXPORT2
197initArgs( 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 212T_CTEST_API int T_CTEST_EXPORT2
46f4442e 213runTestRequest(const TestNode* root,
374ca955
A
214 int argc,
215 const char* const argv[]);
b75a7d8f
A
216
217
374ca955
A
218T_CTEST_API const char* T_CTEST_EXPORT2
219getTestName(void);
b75a7d8f
A
220
221
222
223#endif