Skip to content

Commit b0b274b

Browse files
Make ICU ptest output compatible with Automake format
Update ICU ptest output so that each test prints in the Automake "simple test" format required by Yocto[1]: result: testname Where `result` is one of PASS, FAIL, or SKIP. [1] https://wiki.yoctoproject.org/wiki/Ptest Signed-off-by: Jiaying Song <[email protected]>
1 parent 9407fad commit b0b274b

File tree

3 files changed

+34
-2
lines changed

3 files changed

+34
-2
lines changed

icu4c/source/configure.ac

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1103,6 +1103,21 @@ If set, it will REPLACE any automatic list of libraries.],
11031103
*) AC_MSG_ERROR(bad value ${enableval} for --enable-samples) ;;
11041104
esac],
11051105
samples=true)
1106+
1107+
# Enable Automake-compatible ptest output format (for Yocto/OpenEmbedded)
1108+
AC_ARG_ENABLE([ptest-automake-format],
1109+
AS_HELP_STRING([--enable-ptest-automake-format],
1110+
[Emit ptest output in Automake format (PASS:/FAIL:) for Yocto ptest]),
1111+
[
1112+
if test "x$enableval" = "xyes"; then
1113+
UCONFIG_CPPFLAGS="${UCONFIG_CPPFLAGS} -DU_PTEST_AUTOMAKE_FORMAT=1"
1114+
AC_MSG_RESULT([enabling Automake ptest format])
1115+
else
1116+
AC_MSG_RESULT([disabling Automake ptest format])
1117+
fi
1118+
],
1119+
[enable_ptest_automake_format=no])
1120+
11061121
ICU_CONDITIONAL(SAMPLES, test "$samples" = true)
11071122

11081123
ICUDATA_CHAR=$U_ENDIAN_CHAR
@@ -1366,3 +1381,5 @@ then
13661381
fi
13671382

13681383
$as_unset _CXX_CXXSUFFIX
1384+
1385+

icu4c/source/test/intltest/intltest.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -824,11 +824,19 @@ UBool IntlTest::runTestLoop( char* testname, char* par, char *baseName )
824824
saveBaseLoc[0]=0; /* reset path */
825825

826826
if (lastErrorCount == errorCount) {
827-
snprintf( msg, sizeof(msg), " } OK: %s ", name );
827+
#ifdef U_PTEST_AUTOMAKE_FORMAT
828+
snprintf(msg, sizeof(msg), "PASS: %s\n }", name);
829+
#else
830+
snprintf(msg, sizeof(msg), " } OK: %s ", name );
831+
#endif
828832
if(!no_time) str_timeDelta(msg+strlen(msg),timeStop-timeStart);
829833
lastTestFailed = false;
830834
}else{
835+
#ifdef U_PTEST_AUTOMAKE_FORMAT
836+
snprintf(msg, sizeof(msg), "FAIL: %s\n } (ERRORS: %li)", name, static_cast<long>(errorCount - lastErrorCount));
837+
#else
831838
snprintf(msg, sizeof(msg), " } ERRORS (%li) in %s", static_cast<long>(errorCount - lastErrorCount), name);
839+
#endif
832840
if(!no_time) str_timeDelta(msg+strlen(msg),timeStop-timeStart);
833841

834842
for(int i=0;i<LL_indentlevel;i++) {

icu4c/source/tools/ctestfw/ctest.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -413,9 +413,16 @@ static void iterateTestsWithLevel ( const TestNode* root,
413413
ctest_xml_testcase(pathToFunction, pathToFunction, timeSeconds, (myERROR_COUNT!=ERROR_COUNT)?"error":NULL);
414414

415415
if (myERROR_COUNT != ERROR_COUNT) {
416-
log_testinfo_i("} ---[%d ERRORS in %s] ", ERROR_COUNT - myERROR_COUNT, pathToFunction);
416+
#ifdef U_PTEST_AUTOMAKE_FORMAT
417+
log_testinfo_i("\nFAIL: %s\n} ---[ERRORS: %d]", root->name,ERROR_COUNT - myERROR_COUNT);
418+
#else
419+
log_testinfo_i("} ---[%d ERRORS in %s] ", ERROR_COUNT - myERROR_COUNT,pathToFunction);
420+
#endif
417421
strcpy(ERROR_LOG[ERRONEOUS_FUNCTION_COUNT++], pathToFunction);
418422
} else {
423+
#ifdef U_PTEST_AUTOMAKE_FORMAT
424+
log_testinfo_i("\nPASS: %s\n", root->name);
425+
#endif
419426
if(!ON_LINE) { /* had some output */
420427
int spaces = FLAG_INDENT-(depth-1);
421428
log_testinfo_i("} %*s[OK] ", spaces, "---");

0 commit comments

Comments
 (0)