/*
********************************************************************************
*
-* Copyright (C) 1996-2010, International Business Machines
+* Copyright (C) 1996-2013, International Business Machines
* Corporation and others. All Rights Reserved.
*
********************************************************************************
#include "unicode/utrace.h"
#include "unicode/uclean.h"
-#include "umutex.h"
#include "putilimp.h"
+#include "udbgutil.h"
/* NOTES:
3/20/1999 srl - strncpy called w/o setting nulls at the end
*/
static void vlog_err(const char *prefix, const char *pattern, va_list ap);
static void vlog_verbose(const char *prefix, const char *pattern, va_list ap);
+static UBool vlog_knownIssue(const char *ticket, const char *pattern, va_list ap);
/**
* Log test structure, with indent
static int ONE_ERROR = 0; /* were there any other errors? */
static int DATA_ERROR_COUNT = 0; /* count of data related errors or warnings */
static int INDENT_LEVEL = 0;
+static UBool NO_KNOWN = FALSE;
+static void *knownList = NULL;
+static char gTestName[1024] = "";
static UBool ON_LINE = FALSE; /* are we on the top line with our test name? */
static UBool HANGING_OUTPUT = FALSE; /* did the user leave us without a trailing \n ? */
static int GLOBAL_PRINT_COUNT = 0; /* global count of printouts */
UTraceLevel ICU_TRACE = UTRACE_OFF; /* ICU tracing level */
size_t MINIMUM_MEMORY_SIZE_FAILURE = (size_t)-1; /* Minimum library memory allocation window that will fail. */
size_t MAXIMUM_MEMORY_SIZE_FAILURE = (size_t)-1; /* Maximum library memory allocation window that will fail. */
-int32_t ALLOCATION_COUNT = 0;
static const char *ARGV_0 = "[ALL]";
static const char *XML_FILE_NAME=NULL;
static char XML_PREFIX[256];
-
+static const char *SUMMARY_FILE = NULL;
FILE *XML_FILE = NULL;
/*-------------------------------------------*/
#if SHOW_TIMES
startTime = uprv_getRawUTCtime();
#endif
+ strcpy(gTestName, pathToFunction);
root->test(); /* PERFORM THE TEST ************************/
#if SHOW_TIMES
stopTime = uprv_getRawUTCtime();
ON_LINE=FALSE; /* just in case */
+ if(knownList != NULL) {
+ if( udbg_knownIssue_print(knownList) ) {
+ fprintf(stdout, "(To run suppressed tests, use the -K option.) \n\n");
+ }
+ udbg_knownIssue_close(knownList);
+ }
+
if (ERROR_COUNT)
{
fprintf(stdout,"\nSUMMARY:\n");
fprintf(stdout, " Errors in\n");
for (i=0;i < ERRONEOUS_FUNCTION_COUNT; i++)
fprintf(stdout, "[%s]\n",ERROR_LOG[i]);
+ if(SUMMARY_FILE != NULL) {
+ FILE *summf = fopen(SUMMARY_FILE, "w");
+ if(summf!=NULL) {
+ for (i=0;i < ERRONEOUS_FUNCTION_COUNT; i++)
+ fprintf(summf, "%s\n",ERROR_LOG[i]);
+ fclose(summf);
+ }
+ }
}
else
{
GLOBAL_PRINT_COUNT++;
}
+static UBool vlog_knownIssue(const char *ticket, const char *pattern, va_list ap)
+{
+ char buf[2048];
+ UBool firstForTicket;
+ UBool firstForWhere;
+
+ if(NO_KNOWN) return FALSE;
+ if(pattern==NULL) pattern="";
+
+ vsprintf(buf, pattern, ap);
+ knownList = udbg_knownIssue_open(knownList, ticket, gTestName, buf,
+ &firstForTicket, &firstForWhere);
+
+ if(firstForTicket || firstForWhere) {
+ log_info("(Known issue #%s) %s", ticket, buf);
+ } else {
+ log_verbose("(Known issue #%s) %s", ticket, buf);
+ }
+
+ return TRUE;
+}
+
+
void T_CTEST_EXPORT2
vlog_info(const char *prefix, const char *pattern, va_list ap)
{
vlog_err(NULL, pattern, ap);
}
+UBool T_CTEST_EXPORT2
+log_knownIssue(const char *ticket, const char *pattern, ...) {
+ va_list ap;
+ va_start(ap, pattern);
+ return vlog_knownIssue(ticket, pattern, ap);
+}
+
void T_CTEST_EXPORT2
log_err_status(UErrorCode status, const char* pattern, ...)
{
va_list ap;
va_start(ap, pattern);
- first_line_err();
if ((status == U_FILE_ACCESS_ERROR || status == U_MISSING_RESOURCE_ERROR)) {
++DATA_ERROR_COUNT; /* for informational message at the end */
if (WARN_ON_MISSING_DATA == 0) {
+ first_line_err();
/* Fatal error. */
if (strchr(pattern, '\n') != NULL) {
++ERROR_COUNT;
} else {
- ++ONE_ERROR;
+ ++ONE_ERROR;
}
vlog_err(NULL, pattern, ap); /* no need for prefix in default case */
} else {
vlog_info("[DATA] ", pattern, ap);
}
} else {
+ first_line_err();
/* Fatal error. */
if(strchr(pattern, '\n') != NULL) {
++ERROR_COUNT;
} else {
- ++ONE_ERROR;
+ ++ONE_ERROR;
}
vlog_err(NULL, pattern, ap); /* no need for prefix in default case */
}
if (MINIMUM_MEMORY_SIZE_FAILURE <= size && size <= MAXIMUM_MEMORY_SIZE_FAILURE) {
return NULL;
}
- umtx_atomic_inc(&ALLOCATION_COUNT);
return malloc(size);
}
static void *U_CALLCONV ctest_libRealloc(const void *context, void *mem, size_t size) {
/*free(mem);*/ /* Realloc doesn't free on failure. */
return NULL;
}
- if (mem == NULL) {
- /* New allocation. */
- umtx_atomic_inc(&ALLOCATION_COUNT);
- }
return realloc(mem, size);
}
static void U_CALLCONV ctest_libFree(const void *context, void *mem) {
- if (mem != NULL) {
- umtx_atomic_dec(&ALLOCATION_COUNT);
- }
free(mem);
}
initArgs( int argc, const char* const argv[], ArgHandlerPtr argHandler, void *context)
{
int i;
- int doList = FALSE;
- int argSkip = 0;
+ int argSkip = 0;
VERBOSITY = FALSE;
ERR_MSG = TRUE;
}
else if (strcmp( argv[i], "-l" )==0 )
{
- doList = TRUE;
+ /* doList = TRUE; */
}
else if (strcmp( argv[i], "-e1") == 0)
{
{
QUICK = 0;
}
+ else if (strcmp( argv[i], "-K") ==0)
+ {
+ NO_KNOWN = 1;
+ }
+ else if (strncmp( argv[i], "-E",2) ==0)
+ {
+ SUMMARY_FILE=argv[i]+2;
+ }
else if (strcmp( argv[i], "-w") ==0)
{
WARN_ON_MISSING_DATA = TRUE;
printf(" -v To turn ON verbosity(same as -verbose)\n");
printf(" -x file.xml Write junit format output to file.xml\n");
printf(" -h To print this message\n");
+ printf(" -K to turn OFF suppressing known issues\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");
REPEAT_TESTS = value;
break;
case ICU_TRACE_OPTION:
- ICU_TRACE = value;
+ ICU_TRACE = (UTraceLevel)value;
break;
default :
break;
fprintf(stderr," Error: couldn't open XML output file %s\n", XML_FILE_NAME);
return 1;
}
- while(*rootName&&!isalnum(*rootName)) {
+ while(*rootName&&!isalnum((int)*rootName)) {
rootName++;
}
strcpy(XML_PREFIX,rootName);
{
char *p = XML_PREFIX+strlen(XML_PREFIX);
- for(p--;*p&&p>XML_PREFIX&&!isalnum(*p);p--) {
+ for(p--;*p&&p>XML_PREFIX&&!isalnum((int)*p);p--) {
*p=0;
}
}
int32_t
T_CTEST_EXPORT2
-ctest_xml_testcase(const char *classname, const char *name, const char *time, const char *failMsg) {
+ctest_xml_testcase(const char *classname, const char *name, const char *timeSeconds, const char *failMsg) {
if(!XML_FILE) return 0;
- fprintf(XML_FILE, "\t<testcase classname=\"%s:%s\" name=\"%s:%s\" time=\"%s\"", XML_PREFIX, classname, XML_PREFIX, name, time);
+ fprintf(XML_FILE, "\t<testcase classname=\"%s:%s\" name=\"%s:%s\" time=\"%s\"", XML_PREFIX, classname, XML_PREFIX, name, timeSeconds);
if(failMsg) {
fprintf(XML_FILE, ">\n\t\t<failure type=\"err\" message=\"%s\"/>\n\t</testcase>\n", failMsg);
} else {