2 ********************************************************************************
4 * Copyright (C) 1996-2004, International Business Machines
5 * Corporation and others. All Rights Reserved.
7 ********************************************************************************
13 #include "unicode/testtype.h"
14 #include "unicode/utrace.h"
17 /* prototypes *********************************/
20 typedef void (U_CALLCONV
*TestFunctionPtr
)(void);
21 typedef struct TestNode TestNode
;
25 * Set this to zero to disable log_verbose() messages.
26 * Otherwise nonzero to see log_verbose() messages.
28 * @internal Internal APIs for testing purpose only
30 extern T_CTEST_EXPORT_API
int REPEAT_TESTS
;
33 * Set this to zero to disable log_verbose() messages.
34 * Otherwise nonzero to see log_verbose() messages.
36 * @internal Internal APIs for testing purpose only
38 extern T_CTEST_EXPORT_API
int VERBOSITY
;
41 * Set this to zero to disable log_verbose() messages.
42 * Otherwise nonzero to see log_verbose() messages.
44 * @internal Internal APIs for testing purpose only
46 extern T_CTEST_EXPORT_API
int ERR_MSG
;
49 * Set this to zero to disable some of the slower tests.
50 * Otherwise nonzero to run the slower tests.
52 * @internal Internal APIs for testing purpose only
54 extern T_CTEST_EXPORT_API
int QUICK
;
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.
62 * @internal Internal APIs for testing purpose only
64 extern T_CTEST_EXPORT_API
int WARN_ON_MISSING_DATA
;
67 * ICU tracing level, is set by command line option
71 extern T_CTEST_EXPORT_API UTraceLevel ICU_TRACE
;
74 * Show the names of all nodes.
76 * @param root Subtree of tests.
77 * @internal Internal APIs for testing purpose only
79 T_CTEST_API
void T_CTEST_EXPORT2
80 showTests ( const TestNode
*root
);
83 * Run a subtree of tests.
85 * @param root Subtree of tests.
86 * @internal Internal APIs for testing purpose only
88 T_CTEST_API
void T_CTEST_EXPORT2
89 runTests ( const TestNode
* root
);
92 * Add a test to the subtree.
95 * TestNode* root=NULL;
96 * addTest(&root, &mytest, "/a/b/mytest" );
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
103 T_CTEST_API
void T_CTEST_EXPORT2
104 addTest(TestNode
** root
,
105 TestFunctionPtr test
,
109 * Clean up any allocated memory.
110 * Conditions for calling this function are the same as u_cleanup().
112 * @internal Internal APIs for testing purpose only
114 T_CTEST_API
void T_CTEST_EXPORT2
115 cleanUpTestTree(TestNode
*tn
);
118 * Retreive a specific subtest. (subtree).
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
125 T_CTEST_API
const TestNode
* T_CTEST_EXPORT2
126 getTest(const TestNode
* root
,
131 * Log an error message. (printf style)
132 * @param pattern printf-style format string
133 * @internal Internal APIs for testing purpose only
135 T_CTEST_API
void T_CTEST_EXPORT2
136 log_err(const char* pattern
, ...);
139 * Log an informational message. (printf style)
140 * @param pattern printf-style format string
141 * @internal Internal APIs for testing purpose only
143 T_CTEST_API
void T_CTEST_EXPORT2
144 log_info(const char* pattern
, ...);
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
153 T_CTEST_API
void T_CTEST_EXPORT2
154 vlog_info(const char *prefix
, const char *pattern
, va_list ap
);
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
162 T_CTEST_API
void T_CTEST_EXPORT2
163 log_verbose(const char* pattern
, ...);
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
172 T_CTEST_API
void T_CTEST_EXPORT2
173 log_data_err(const char *pattern
, ...);
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
188 T_CTEST_API
int T_CTEST_EXPORT2
189 processArgs(const TestNode
* root
,
191 const char* const argv
[]);
194 T_CTEST_API
const char* T_CTEST_EXPORT2