]> git.saurik.com Git - apple/icu.git/blob - icuSources/tools/ctestfw/unicode/ctest.h
ICU-8.11.1.tar.gz
[apple/icu.git] / icuSources / tools / ctestfw / unicode / ctest.h
1 /*
2 ********************************************************************************
3 *
4 * Copyright (C) 1996-2004, 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 struct TestNode TestNode;
22 U_CDECL_END
23
24 /**
25 * Set this to zero to disable log_verbose() messages.
26 * Otherwise nonzero to see log_verbose() messages.
27 *
28 * @internal Internal APIs for testing purpose only
29 */
30 extern T_CTEST_EXPORT_API int REPEAT_TESTS;
31
32 /**
33 * Set this to zero to disable log_verbose() messages.
34 * Otherwise nonzero to see log_verbose() messages.
35 *
36 * @internal Internal APIs for testing purpose only
37 */
38 extern T_CTEST_EXPORT_API int VERBOSITY;
39
40 /**
41 * Set this to zero to disable log_verbose() messages.
42 * Otherwise nonzero to see log_verbose() messages.
43 *
44 * @internal Internal APIs for testing purpose only
45 */
46 extern T_CTEST_EXPORT_API int ERR_MSG;
47
48 /**
49 * Set this to zero to disable some of the slower tests.
50 * Otherwise nonzero to run the slower tests.
51 *
52 * @internal Internal APIs for testing purpose only
53 */
54 extern T_CTEST_EXPORT_API int QUICK;
55
56 /**
57 * Set this to nonzero to warn (not error) on missing data.
58 * Otherwise, zero will cause an error to be propagated when data is not available.
59 * Affects the behavior of log_dataerr.
60 *
61 * @see log_data_err
62 * @internal Internal APIs for testing purpose only
63 */
64 extern T_CTEST_EXPORT_API int WARN_ON_MISSING_DATA;
65
66 /**
67 * ICU tracing level, is set by command line option
68 *
69 * @internal
70 */
71 extern T_CTEST_EXPORT_API UTraceLevel ICU_TRACE;
72
73 /**
74 * Show the names of all nodes.
75 *
76 * @param root Subtree of tests.
77 * @internal Internal APIs for testing purpose only
78 */
79 T_CTEST_API void T_CTEST_EXPORT2
80 showTests ( const TestNode *root);
81
82 /**
83 * Run a subtree of tests.
84 *
85 * @param root Subtree of tests.
86 * @internal Internal APIs for testing purpose only
87 */
88 T_CTEST_API void T_CTEST_EXPORT2
89 runTests ( const TestNode* root);
90
91 /**
92 * Add a test to the subtree.
93 * Example usage:
94 * <PRE>
95 * TestNode* root=NULL;
96 * addTest(&root, &mytest, "/a/b/mytest" );
97 * </PRE>
98 * @param root Pointer to the root pointer.
99 * @param test Pointer to 'void function(void)' for actual test.
100 * @param path Path from root under which test will be placed. Ex. '/a/b/mytest'
101 * @internal Internal APIs for testing purpose only
102 */
103 T_CTEST_API void T_CTEST_EXPORT2
104 addTest(TestNode** root,
105 TestFunctionPtr test,
106 const char *path);
107
108 /**
109 * Clean up any allocated memory.
110 * Conditions for calling this function are the same as u_cleanup().
111 * @see u_cleanup
112 * @internal Internal APIs for testing purpose only
113 */
114 T_CTEST_API void T_CTEST_EXPORT2
115 cleanUpTestTree(TestNode *tn);
116
117 /**
118 * Retreive a specific subtest. (subtree).
119 *
120 * @param root Pointer to the root.
121 * @param path Path relative to the root, Ex. '/a/b'
122 * @return The subtest, or NULL on failure.
123 * @internal Internal APIs for testing purpose only
124 */
125 T_CTEST_API const TestNode* T_CTEST_EXPORT2
126 getTest(const TestNode* root,
127 const char *path);
128
129
130 /**
131 * Log an error message. (printf style)
132 * @param pattern printf-style format string
133 * @internal Internal APIs for testing purpose only
134 */
135 T_CTEST_API void T_CTEST_EXPORT2
136 log_err(const char* pattern, ...);
137
138 /**
139 * Log an informational message. (printf style)
140 * @param pattern printf-style format string
141 * @internal Internal APIs for testing purpose only
142 */
143 T_CTEST_API void T_CTEST_EXPORT2
144 log_info(const char* pattern, ...);
145
146 /**
147 * Log an informational message. (vprintf style)
148 * @param prefix a string that is output before the pattern and without formatting
149 * @param pattern printf-style format string
150 * @param ap variable-arguments list
151 * @internal Internal APIs for testing purpose only
152 */
153 T_CTEST_API void T_CTEST_EXPORT2
154 vlog_info(const char *prefix, const char *pattern, va_list ap);
155
156 /**
157 * Log a verbose informational message. (printf style)
158 * This message will only appear if the global VERBOSITY is nonzero
159 * @param pattern printf-style format string
160 * @internal Internal APIs for testing purpose only
161 */
162 T_CTEST_API void T_CTEST_EXPORT2
163 log_verbose(const char* pattern, ...);
164
165 /**
166 * Log an error message concerning missing data. (printf style)
167 * If WARN_ON_MISSING_DATA is nonzero, this will case a log_info (warning) to be
168 * printed, but if it is zero this will produce an error (log_err).
169 * @param pattern printf-style format string
170 * @internal Internal APIs for testing purpose only
171 */
172 T_CTEST_API void T_CTEST_EXPORT2
173 log_data_err(const char *pattern, ...);
174
175 /**
176 * Processes the command line arguments.
177 * This is a sample implementation
178 * <PRE>Usage: %s [ -l ] [ -v ] [ -? ] [ /path/to/test ]
179 * -l List only, do not run\
180 * -v turn OFF verbosity
181 * -? print this message</PRE>
182 * @param root Testnode root with tests already attached to it
183 * @param argv argument list from main (stdio.h)
184 * @param argc argument list count from main (stdio.h)
185 * @return positive for error count, 0 for success, negative for illegal argument
186 * @internal Internal APIs for testing purpose only
187 */
188 T_CTEST_API int T_CTEST_EXPORT2
189 processArgs(const TestNode* root,
190 int argc,
191 const char* const argv[]);
192
193
194 T_CTEST_API const char* T_CTEST_EXPORT2
195 getTestName(void);
196
197
198
199 #endif