X-Git-Url: https://git.saurik.com/apple/icu.git/blobdiff_plain/b75a7d8f3b4adbae880cab104ce2c6a50eee4db2..d5d484b0fbe924d3663b177965538d517ee412c1:/icuSources/tools/ctestfw/ctest.c diff --git a/icuSources/tools/ctestfw/ctest.c b/icuSources/tools/ctestfw/ctest.c index f2190d4e..d99450b1 100644 --- a/icuSources/tools/ctestfw/ctest.c +++ b/icuSources/tools/ctestfw/ctest.c @@ -1,10 +1,10 @@ /* -***************************************************************************************** +******************************************************************************** * -* Copyright (C) 1996-2003, International Business Machines +* Copyright (C) 1996-2006, International Business Machines * Corporation and others. All Rights Reserved. * -***************************************************************************************** +******************************************************************************** */ #include #include @@ -12,6 +12,8 @@ #include #include +#include "unicode/utrace.h" + /* NOTES: 3/20/1999 srl - strncpy called w/o setting nulls at the end */ @@ -69,7 +71,6 @@ static void help ( const char *argv0 ); * @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 @@ -85,6 +86,7 @@ int VERBOSITY = 0; /* be No-verbose by default */ 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] */ @@ -135,7 +137,9 @@ static TestNode *createTestNode( ) return newNode; } -void cleanUpTestTree(TestNode *tn) { +void T_CTEST_EXPORT2 +cleanUpTestTree(TestNode *tn) +{ if(tn->child != NULL) { cleanUpTestTree(tn->child); } @@ -147,9 +151,10 @@ void cleanUpTestTree(TestNode *tn) { } -void addTest ( TestNode** root, - TestFunctionPtr test, - const char* name ) +void T_CTEST_EXPORT2 +addTest(TestNode** root, + TestFunctionPtr test, + const char* name ) { TestNode *newNode; @@ -298,7 +303,8 @@ static void iterateTestsWithLevel ( const TestNode* root, -void showTests ( const TestNode *root ) +void T_CTEST_EXPORT2 +showTests ( const TestNode *root ) { /* make up one for them */ const TestNode *aList[MAXTESTS]; @@ -310,7 +316,8 @@ void showTests ( const TestNode *root ) } -void runTests ( const TestNode *root ) +void T_CTEST_EXPORT2 +runTests ( const TestNode *root ) { int i; const TestNode *aList[MAXTESTS]; @@ -347,7 +354,8 @@ void runTests ( const TestNode *root ) } } -const char* getTestName(void) +const char* T_CTEST_EXPORT2 +getTestName(void) { if(currentTest != NULL) { return currentTest->name; @@ -356,15 +364,18 @@ const char* getTestName(void) } } -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++; @@ -420,18 +431,19 @@ static void vlog_err(const char *prefix, const char *pattern, va_list ap) } 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); @@ -445,14 +457,15 @@ static void vlog_verbose(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); 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) { @@ -466,7 +479,8 @@ void log_err(const char* pattern, ...) vlog_err(NULL, pattern, ap); } -void log_info(const char* pattern, ...) +void T_CTEST_EXPORT2 +log_info(const char* pattern, ...) { va_list ap; @@ -474,7 +488,8 @@ void log_info(const char* pattern, ...) vlog_info(NULL, pattern, ap); } -void log_verbose(const char* pattern, ...) +void T_CTEST_EXPORT2 +log_verbose(const char* pattern, ...) { va_list ap; @@ -483,7 +498,8 @@ void log_verbose(const char* pattern, ...) } -void log_data_err(const char* pattern, ...) +void T_CTEST_EXPORT2 +log_data_err(const char* pattern, ...) { va_list ap; va_start(ap, pattern); @@ -502,7 +518,8 @@ void log_data_err(const char* pattern, ...) } -int processArgs(const TestNode* root, +int T_CTEST_EXPORT2 +processArgs(const TestNode* root, int argc, const char* const argv[]) { @@ -580,7 +597,22 @@ int processArgs(const TestNode* root, { 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; @@ -619,19 +651,22 @@ int processArgs(const TestNode* root, 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"); }