/*
-*****************************************************************************************
+********************************************************************************
*
-* Copyright (C) 1996-2003, International Business Machines
+* Copyright (C) 1996-2006, International Business Machines
* Corporation and others. All Rights Reserved.
*
-*****************************************************************************************
+********************************************************************************
*/
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <stdarg.h>
+#include "unicode/utrace.h"
+
/* NOTES:
3/20/1999 srl - strncpy called w/o setting nulls at the end
*/
* @param ap vprintf style arg list
*/
static void vlog_err(const char *prefix, const char *pattern, va_list ap);
-static void vlog_info(const char *prefix, const char *pattern, va_list ap);
static void vlog_verbose(const char *prefix, const char *pattern, va_list ap);
/* If we need to make the framework multi-thread safe
int ERR_MSG =1; /* error messages will be displayed by default*/
int QUICK = 1; /* Skip some of the slower tests? */
int WARN_ON_MISSING_DATA = 0; /* Reduce data errs to warnings? */
+UTraceLevel ICU_TRACE = UTRACE_OFF; /* ICU tracing level */
/*-------------------------------------------*/
/* strncmp that also makes sure there's a \0 at s2[0] */
return newNode;
}
-void cleanUpTestTree(TestNode *tn) {
+void T_CTEST_EXPORT2
+cleanUpTestTree(TestNode *tn)
+{
if(tn->child != NULL) {
cleanUpTestTree(tn->child);
}
}
-void addTest ( TestNode** root,
- TestFunctionPtr test,
- const char* name )
+void T_CTEST_EXPORT2
+addTest(TestNode** root,
+ TestFunctionPtr test,
+ const char* name )
{
TestNode *newNode;
-void showTests ( const TestNode *root )
+void T_CTEST_EXPORT2
+showTests ( const TestNode *root )
{
/* make up one for them */
const TestNode *aList[MAXTESTS];
}
-void runTests ( const TestNode *root )
+void T_CTEST_EXPORT2
+runTests ( const TestNode *root )
{
int i;
const TestNode *aList[MAXTESTS];
}
}
-const char* getTestName(void)
+const char* T_CTEST_EXPORT2
+getTestName(void)
{
if(currentTest != NULL) {
return currentTest->name;
}
}
-const TestNode* getTest(const TestNode* root, const char* name)
+const TestNode* T_CTEST_EXPORT2
+getTest(const TestNode* root, const char* name)
{
const char* nextName;
TestNode *nextNode;
const TestNode* curNode;
int nameLen; /* length of current 'name' */
- if (root == NULL)
+ if (root == NULL) {
log_err("TEST CAN'T BE FOUND!\n");
+ return NULL;
+ }
/* remove leading slash */
if ( *name == TEST_SEPARATOR )
name++;
}
fprintf(stderr, "%-*s", INDENT_LEVEL," " );
if(prefix) {
- fputs(prefix, stderr);
+ fputs(prefix, stderr);
}
vfprintf(stderr, pattern, ap);
fflush(stderr);
va_end(ap);
}
-static void vlog_info(const char *prefix, const char *pattern, va_list ap)
+void T_CTEST_EXPORT2
+vlog_info(const char *prefix, const char *pattern, va_list ap)
{
fprintf(stdout, "%-*s", INDENT_LEVEL," " );
if(prefix) {
- fputs(prefix, stderr);
+ fputs(prefix, stdout);
}
vfprintf(stdout, pattern, ap);
fflush(stdout);
fprintf(stdout, "%-*s", INDENT_LEVEL," " );
if(prefix) {
- fputs(prefix, stderr);
+ fputs(prefix, stdout);
}
vfprintf(stdout, pattern, ap);
fflush(stdout);
va_end(ap);
}
-void log_err(const char* pattern, ...)
+void T_CTEST_EXPORT2
+log_err(const char* pattern, ...)
{
va_list ap;
if(strchr(pattern, '\n') != NULL) {
vlog_err(NULL, pattern, ap);
}
-void log_info(const char* pattern, ...)
+void T_CTEST_EXPORT2
+log_info(const char* pattern, ...)
{
va_list ap;
vlog_info(NULL, pattern, ap);
}
-void log_verbose(const char* pattern, ...)
+void T_CTEST_EXPORT2
+log_verbose(const char* pattern, ...)
{
va_list ap;
}
-void log_data_err(const char* pattern, ...)
+void T_CTEST_EXPORT2
+log_data_err(const char* pattern, ...)
{
va_list ap;
va_start(ap, pattern);
}
-int processArgs(const TestNode* root,
+int T_CTEST_EXPORT2
+processArgs(const TestNode* root,
int argc,
const char* const argv[])
{
{
subtreeOptionSeen=FALSE;
}
- else if (strcmp( argv[1], "-h" )==0 )
+ else if (strcmp( argv[i], "-t_info") == 0) {
+ ICU_TRACE = UTRACE_INFO;
+ }
+ else if (strcmp( argv[i], "-t_error") == 0) {
+ ICU_TRACE = UTRACE_ERROR;
+ }
+ else if (strcmp( argv[i], "-t_warn") == 0) {
+ ICU_TRACE = UTRACE_WARNING;
+ }
+ else if (strcmp( argv[i], "-t_verbose") == 0) {
+ ICU_TRACE = UTRACE_VERBOSE;
+ }
+ else if (strcmp( argv[i], "-t_oc") == 0) {
+ ICU_TRACE = UTRACE_OPEN_CLOSE;
+ }
+ else if (strcmp( argv[i], "-h" )==0 || strcmp( argv[i], "--help" )==0)
{
help( argv[0] );
return 0;
static void help ( const char *argv0 )
{
- printf("Usage: %s [ -l ] [ -v ] [ -verbose] [-a] [ -all] [-n] \n [ -no_err_msg] [ -h ] [ /path/to/test ]\n",
+ printf("Usage: %s [ -l ] [ -v ] [ -verbose] [-a] [ -all] [-n] [ -no_err_msg]\n"
+ " [ -h ] [-t_info | -t_error | -t_warn | -t_oc | -t_verbose]"
+ " [ /path/to/test ]\n",
argv0);
- printf(" -l To get a list of test names\n");
- printf(" -e to do exhaustive testing\n");
+ printf(" -l To get a list of test names\n");
+ printf(" -e to do exhaustive testing\n");
printf(" -verbose To turn ON verbosity\n");
- printf(" -v To turn ON verbosity(same as -verbose)\n");
- printf(" -h To print this message\n");
- printf(" -n To turn OFF printing error messages\n");
- printf(" -w Don't fail on data-loading errs, just warn. Useful if\n"
+ printf(" -v To turn ON verbosity(same as -verbose)\n");
+ printf(" -h To print this message\n");
+ printf(" -n To turn OFF printing error messages\n");
+ printf(" -w Don't fail on data-loading errs, just warn. Useful if\n"
" user has reduced/changed the common set of ICU data \n");
+ printf(" -t_info | -t_error | -t_warn | -t_oc | -t_verbose Enable ICU tracing\n");
printf(" -no_err_msg (same as -n) \n");
- printf(" -r repeat tests after calling u_cleanup \n");
- printf(" -[/subtest] To run a subtest \n");
+ printf(" -r repeat tests after calling u_cleanup \n");
+ printf(" -[/subtest] To run a subtest \n");
printf(" eg: to run just the utility tests type: cintltest /tsutil) \n");
}