From 7802f4a73b1e5c9d41c2ce35b481245b65bd608a Mon Sep 17 00:00:00 2001 From: "Steven R. Loomis" Date: Mon, 16 Sep 2013 22:07:02 +0000 Subject: [PATCH] ICU-9744 logKnownIssue and log_knownIssue for ICU4C X-SVN-Rev: 34335 --- icu4c/source/test/cintltst/cintltst.c | 8 +++- icu4c/source/test/cintltst/cintltst.h | 5 +- icu4c/source/test/intltest/intltest.cpp | 56 +++++++++++++++++++++- icu4c/source/test/intltest/intltest.h | 16 +++++-- icu4c/source/test/intltest/rbbitst.cpp | 2 +- icu4c/source/test/intltest/ssearch.cpp | 2 +- icu4c/source/tools/ctestfw/ctest.c | 32 +++++++++++++ icu4c/source/tools/ctestfw/unicode/ctest.h | 13 ++++- icu4c/source/tools/toolutil/udbgutil.cpp | 19 ++++++++ icu4c/source/tools/toolutil/udbgutil.h | 16 ++++++- 10 files changed, 158 insertions(+), 11 deletions(-) diff --git a/icu4c/source/test/cintltst/cintltst.c b/icu4c/source/test/cintltst/cintltst.c index 24e1069ca13..de4007ae8b5 100644 --- a/icu4c/source/test/cintltst/cintltst.c +++ b/icu4c/source/test/cintltst/cintltst.c @@ -696,6 +696,9 @@ U_CFUNC UBool assertEquals(const char* message, const char* expected, */ U_CFUNC UBool isICUVersionBefore(int major, int minor, int milli) { + log_knownIssue("9744", "fix call to isICUVersionBefore()"); + return TRUE; + /* UVersionInfo iv; UVersionInfo ov; ov[0] = (uint8_t)major; @@ -704,10 +707,13 @@ U_CFUNC UBool isICUVersionBefore(int major, int minor, int milli) { ov[3] = 0; u_getVersion(iv); return uprv_memcmp(iv, ov, U_MAX_VERSION_LENGTH) < 0; + */ } U_CFUNC UBool isICUVersionAtLeast(int major, int minor, int milli) { - return !isICUVersionBefore(major, minor, milli); + log_knownIssue("9744", "fix call to isICUVersionAtLeast()"); + return FALSE; + //return !isICUVersionBefore(major, minor, milli); } #endif diff --git a/icu4c/source/test/cintltst/cintltst.h b/icu4c/source/test/cintltst/cintltst.h index 6e6d1614f0a..6c7cf023dc1 100644 --- a/icu4c/source/test/cintltst/cintltst.h +++ b/icu4c/source/test/cintltst/cintltst.h @@ -1,6 +1,6 @@ /******************************************************************** * COPYRIGHT: - * Copyright (c) 1997-2012, International Business Machines Corporation and + * Copyright (c) 1997-2013, International Business Machines Corporation and * others. All Rights Reserved. ********************************************************************/ /******************************************************************************** @@ -134,12 +134,15 @@ U_CFUNC UBool assertEquals(const char* msg, const char* expectedString, /** * Returns true if u_getVersion() < major.minor.milli. + * @deprecated use log_KnownIssue */ U_CFUNC UBool isICUVersionBefore(int major, int minor, int milli); /** * Returns true if u_getVersion() >= major.minor.milli. + * @deprecated use log_KnownIssue */ U_CFUNC UBool isICUVersionAtLeast(int major, int minor, int milli); + #endif diff --git a/icu4c/source/test/intltest/intltest.cpp b/icu4c/source/test/intltest/intltest.cpp index a918cadfa50..e8063835f1b 100644 --- a/icu4c/source/test/intltest/intltest.cpp +++ b/icu4c/source/test/intltest/intltest.cpp @@ -38,6 +38,7 @@ #include "putilimp.h" // for uprv_getRawUTCtime() #include "unicode/locid.h" #include "unicode/ctest.h" // for str_timeDelta +#include "udbgutil.h" #ifdef XP_MAC_CONSOLE #include @@ -49,6 +50,7 @@ static char* _testDataPath=NULL; // Static list of errors found static UnicodeString errorList; +static UnicodeString knownList; //----------------------------------------------------------------------------- //convenience classes to ease porting code that uses the Java @@ -547,6 +549,7 @@ IntlTest::IntlTest() LL_indentlevel = indentLevel_offset; numProps = 0; strcpy(basePath, "/"); + currName[0]=0; } void IntlTest::setCaller( IntlTest* callingTest ) @@ -741,7 +744,9 @@ UBool IntlTest::runTestLoop( char* testname, char* par, char *baseName ) strcpy(saveBaseLoc,name); strcat(saveBaseLoc,"/"); + strcpy(currName, name); // set this->runIndexedTest( index, TRUE, name, par ); + currName[0]=0; // reset UDate timeStop = uprv_getRawUTCtime(); rval = TRUE; // at least one test has been called @@ -941,6 +946,37 @@ void IntlTest::logln(const char *fmt, ...) } } +UBool IntlTest::logKnownIssue(const char *ticket, const char *fmt, ...) +{ + char buffer[4000]; + va_list ap; + + va_start(ap, fmt); + /* sprintf it just to make sure that the information is valid */ + vsprintf(buffer, fmt, ap); + va_end(ap); + return logKnownIssue(ticket, UnicodeString(buffer, "")); +} + +UBool IntlTest::logKnownIssue(const char *ticket) { + return logKnownIssue(ticket, UnicodeString()); +} + +UBool IntlTest::logKnownIssue(const char *ticket, const UnicodeString &msg) { + knownList.append(UnicodeString(ticket, "")); + knownList.append(UnicodeString(" ","")); + knownList.append(UnicodeString(basePath, "")); + knownList.append(UnicodeString(currName, "")); + knownList.append(UnicodeString(" ","")); + char URL[UDBG_KNOWNISSUE_LEN]; + knownList.append(UnicodeString(udbg_knownIssueURLFrom(ticket, URL), "")); + knownList.append(UnicodeString(" ","")); + knownList.append(msg); + knownList.append(UnicodeString("\n", "")); + + return true; +} + /* convenience functions that include sprintf formatting */ void IntlTest::info(const char *fmt, ...) { @@ -1020,6 +1056,17 @@ void IntlTest::printErrors() IntlTest::LL_message(errorList, TRUE); } +UBool IntlTest::printKnownIssues() +{ + if(knownList.length()>0) { + IntlTest::LL_message( UnicodeString("KNOWN ISSUES:\n", ""), TRUE ); + IntlTest::LL_message( knownList, TRUE ); + return TRUE; + } else { + return FALSE; + } +} + void IntlTest::LL_message( UnicodeString message, UBool newline ) { // string that starts with a LineFeed character and continues @@ -1423,6 +1470,7 @@ main(int argc, char* argv[]) } fprintf(stdout, "\n--------------------------------------\n"); + major.printKnownIssues(); if (major.getErrors() == 0) { /* Call it twice to make sure that the defaults were reset. */ /* Call it before the OK message to verify proper cleanup. */ @@ -1908,7 +1956,13 @@ UBool IntlTest::isICUVersionBefore(int major, int minor, int milli) { UVersionInfo iv; UVersionInfo ov = { (uint8_t)major, (uint8_t)minor, (uint8_t)milli, 0 }; u_getVersion(iv); - return uprv_memcmp(iv, ov, U_MAX_VERSION_LENGTH) < 0; + logKnownIssue("9744", "fix call to isICUVersionBefore"); + return TRUE; + if( uprv_memcmp(iv, ov, U_MAX_VERSION_LENGTH) < 0 ) { + return FALSE; + } else { + return FALSE; + } } #if !UCONFIG_NO_FORMATTING diff --git a/icu4c/source/test/intltest/intltest.h b/icu4c/source/test/intltest/intltest.h index af630ccadf1..b5d2a0c0f76 100644 --- a/icu4c/source/test/intltest/intltest.h +++ b/icu4c/source/test/intltest/intltest.h @@ -156,6 +156,10 @@ public: virtual void logln( void ); + UBool logKnownIssue( const char *ticket, const UnicodeString &message ); + UBool logKnownIssue( const char *ticket ); + UBool logKnownIssue( const char *ticket, const char *fmt, ...); + virtual void info( const UnicodeString &message ); virtual void infoln( const UnicodeString &message ); @@ -194,6 +198,9 @@ public: // Print ALL named errors encountered so far void printErrors(); + + // print known issues. return TRUE if there were any. + UBool printKnownIssues(); virtual void usage( void ) ; @@ -216,26 +223,26 @@ public: /** * Returns true if u_getVersion() < major.minor. */ - static UBool isICUVersionBefore(int major, int minor) { + UBool isICUVersionBefore(int major, int minor) { return isICUVersionBefore(major, minor, 0); } /** * Returns true if u_getVersion() < major.minor.milli. */ - static UBool isICUVersionBefore(int major, int minor, int milli); + UBool isICUVersionBefore(int major, int minor, int milli); /** * Returns true if u_getVersion() >= major.minor. */ - static UBool isICUVersionAtLeast(int major, int minor) { + UBool isICUVersionAtLeast(int major, int minor) { return isICUVersionAtLeast(major, minor, 0); } /** * Returns true if u_getVersion() >= major.minor.milli. */ - static UBool isICUVersionAtLeast(int major, int minor, int milli) { + UBool isICUVersionAtLeast(int major, int minor, int milli) { return !isICUVersionBefore(major, minor, milli); } @@ -307,6 +314,7 @@ private: char* testPath; // specifies subtests char basePath[1024]; + char currName[1024]; // current test name //FILE *testoutfp; void *testoutfp; diff --git a/icu4c/source/test/intltest/rbbitst.cpp b/icu4c/source/test/intltest/rbbitst.cpp index 51cd6d3757c..95bf8dde4df 100644 --- a/icu4c/source/test/intltest/rbbitst.cpp +++ b/icu4c/source/test/intltest/rbbitst.cpp @@ -1570,7 +1570,7 @@ void RBBITest::TestUnicodeFiles() { void RBBITest::runUnicodeTestData(const char *fileName, RuleBasedBreakIterator *bi) { #if !UCONFIG_NO_REGULAR_EXPRESSIONS // TODO(andy): Match line break behavior to Unicode 6.0 and remove this time bomb. Ticket #7270 - UBool isTicket7270Fixed = isICUVersionAtLeast(52, 1); + UBool isTicket7270Fixed = !logKnownIssue("7270"); UBool isLineBreak = 0 == strcmp(fileName, "LineBreakTest.txt"); UErrorCode status = U_ZERO_ERROR; diff --git a/icu4c/source/test/intltest/ssearch.cpp b/icu4c/source/test/intltest/ssearch.cpp index 64b1fe659a9..fbbbd86e4eb 100644 --- a/icu4c/source/test/intltest/ssearch.cpp +++ b/icu4c/source/test/intltest/ssearch.cpp @@ -629,7 +629,7 @@ void SSearchTest::offsetTest() col->setAttribute(UCOL_NORMALIZATION_MODE, UCOL_ON, status); for(int32_t i = 0; i < testCount; i += 1) { - if (!isICUVersionAtLeast(52, 0, 2) && i>=4 && i<=6) { + if (i>=4 && i<=6 && logKnownIssue("9156")) { continue; // timebomb until ticket #9156 (was #8081) is resolved } UnicodeString ts = CharsToUnicodeString(test[i]); diff --git a/icu4c/source/tools/ctestfw/ctest.c b/icu4c/source/tools/ctestfw/ctest.c index 59995ff7a32..45cc8632c61 100644 --- a/icu4c/source/tools/ctestfw/ctest.c +++ b/icu4c/source/tools/ctestfw/ctest.c @@ -88,6 +88,7 @@ static void help ( const char *argv0 ); */ 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 @@ -679,6 +680,30 @@ static void vlog_err(const char *prefix, const char *pattern, va_list ap) GLOBAL_PRINT_COUNT++; } +static UBool vlog_knownIssue(const char *ticket, const char *pattern, va_list ap) +{ + /* fputs("!", stdout); /\* col 1 - bang *\/ */ + /* fprintf(stdout, "%-*s", INDENT_LEVEL,"" ); */ + /* if(prefix) { */ + /* fputs(prefix, stdout); */ + /* } */ + char buf[2048], url[1024]; + vsprintf(buf, pattern, ap); + + printf("KNOWN ISSUE: #%s %s\n", ticket, buf); + + /* fflush(stdout); */ + /* va_end(ap); */ + /* if((*pattern==0) || (pattern[strlen(pattern)-1]!='\n')) { */ + /* HANGING_OUTPUT=1; */ + /* } else { */ + /* HANGING_OUTPUT=0; */ + /* } */ + /* GLOBAL_PRINT_COUNT++; */ + return TRUE; +} + + void T_CTEST_EXPORT2 vlog_info(const char *prefix, const char *pattern, va_list ap) { @@ -766,6 +791,13 @@ log_err(const char* pattern, ...) 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, ...) { diff --git a/icu4c/source/tools/ctestfw/unicode/ctest.h b/icu4c/source/tools/ctestfw/unicode/ctest.h index bbff5a0bef4..97f4289de96 100644 --- a/icu4c/source/tools/ctestfw/unicode/ctest.h +++ b/icu4c/source/tools/ctestfw/unicode/ctest.h @@ -1,7 +1,7 @@ /* ******************************************************************************** * - * Copyright (C) 1996-2010, International Business Machines + * Copyright (C) 1996-2013, International Business Machines * Corporation and others. All Rights Reserved. * ******************************************************************************** @@ -299,4 +299,15 @@ T_CTEST_API int32_t T_CTEST_EXPORT2 ctest_xml_testcase(const char *classname, const char *name, const char *time, const char *failMsg); + +/** + * Log a known issue. + * @param ticket ticket number such as "12345" for ICU tickets or "cldr:6636" for CLDR tickets. + * @param fmt ... sprintf-style format, optional message. can be NULL. + * @return TRUE unless known issues should be tested + */ +T_CTEST_API UBool +T_CTEST_EXPORT2 +log_knownIssue(const char *ticket, const char *fmt, ...); + #endif diff --git a/icu4c/source/tools/toolutil/udbgutil.cpp b/icu4c/source/tools/toolutil/udbgutil.cpp index 46c14c05779..945828ec5de 100644 --- a/icu4c/source/tools/toolutil/udbgutil.cpp +++ b/icu4c/source/tools/toolutil/udbgutil.cpp @@ -580,3 +580,22 @@ U_CAPI void udbg_writeIcuInfo(FILE *out) { } fprintf(out, " \n"); } + +#define ICU_TRAC_URL "http://bugs.icu-project.org/trac/ticket/" +#define CLDR_TRAC_URL "http://unicode.org/cldr/trac/ticket/" +#define CLDR_TICKET_PREFIX "cldrbug:" + +U_CAPI char *udbg_knownIssueURLFrom(const char *ticket, char *buf) { + if( ticket==NULL ) { + return NULL; + } + + if( !strncmp(ticket, CLDR_TICKET_PREFIX, strlen(CLDR_TICKET_PREFIX)) ) { + strcpy( buf, CLDR_TRAC_URL ); + strcat( buf, ticket+strlen(CLDR_TICKET_PREFIX) ); + } else { + strcpy( buf, ICU_TRAC_URL ); + strcat( buf, ticket ); + } + return buf; +} diff --git a/icu4c/source/tools/toolutil/udbgutil.h b/icu4c/source/tools/toolutil/udbgutil.h index 0f4da6cbd7f..dec4d5b2f9f 100644 --- a/icu4c/source/tools/toolutil/udbgutil.h +++ b/icu4c/source/tools/toolutil/udbgutil.h @@ -1,6 +1,6 @@ /* ************************************************************************ -* Copyright (c) 2008-2011, International Business Machines +* Copyright (c) 2008-2013, International Business Machines * Corporation and others. All Rights Reserved. ************************************************************************ */ @@ -103,4 +103,18 @@ U_CAPI int32_t udbg_getSystemParameterValueByIndex(int32_t i, char *buffer, int3 */ U_CAPI void udbg_writeIcuInfo(FILE *f); +/** + * \def UDBG_KNOWNISSUE_LEN + * Length of output buffer for udbg_knownIssueURLFrom + */ +#define UDBG_KNOWNISSUE_LEN 255 + +/** + * Convert a "known issue" string into a URL + * @param ticket ticket string such as "10245" or "cldrbug:5013" + * @param buf output buffer - must be UDBG_KNOWNISSUE_LEN in size + * @return pointer to output buffer, or NULL on err + */ +U_CAPI char *udbg_knownIssueURLFrom(const char *ticket, char *buf); + #endif -- 2.40.0