+int32_t T_CTEST_EXPORT2
+getTestOption ( int32_t testOption ) {
+ switch (testOption) {
+ case VERBOSITY_OPTION:
+ return VERBOSITY;
+ case WARN_ON_MISSING_DATA_OPTION:
+ return WARN_ON_MISSING_DATA;
+ case QUICK_OPTION:
+ return QUICK;
+ case REPEAT_TESTS_OPTION:
+ return REPEAT_TESTS;
+ case ERR_MSG_OPTION:
+ return ERR_MSG;
+ case ICU_TRACE_OPTION:
+ return ICU_TRACE;
+ default :
+ return 0;
+ }
+}
+
+void T_CTEST_EXPORT2
+setTestOption ( int32_t testOption, int32_t value) {
+ if (value == DECREMENT_OPTION_VALUE) {
+ value = getTestOption(testOption);
+ --value;
+ }
+ switch (testOption) {
+ case VERBOSITY_OPTION:
+ VERBOSITY = value;
+ break;
+ case WARN_ON_MISSING_DATA_OPTION:
+ WARN_ON_MISSING_DATA = value;
+ break;
+ case QUICK_OPTION:
+ QUICK = value;
+ break;
+ case REPEAT_TESTS_OPTION:
+ REPEAT_TESTS = value;
+ break;
+ case ICU_TRACE_OPTION:
+ ICU_TRACE = (UTraceLevel)value;
+ break;
+ default :
+ break;
+ }
+}
+
+
+/*
+ * ================== JUnit support ================================
+ */
+
+int32_t
+T_CTEST_EXPORT2
+ctest_xml_setFileName(const char *name) {
+ XML_FILE_NAME=name;
+ return 0;
+}
+
+
+int32_t
+T_CTEST_EXPORT2
+ctest_xml_init(const char *rootName) {
+ if(!XML_FILE_NAME) return 0;
+ XML_FILE = fopen(XML_FILE_NAME,"w");
+ if(!XML_FILE) {
+ perror("fopen");
+ fprintf(stderr," Error: couldn't open XML output file %s\n", XML_FILE_NAME);
+ return 1;
+ }
+ while(*rootName&&!isalnum((int)*rootName)) {
+ rootName++;
+ }
+ strcpy(XML_PREFIX,rootName);
+ {
+ char *p = XML_PREFIX+strlen(XML_PREFIX);
+ for(p--;*p&&p>XML_PREFIX&&!isalnum((int)*p);p--) {
+ *p=0;
+ }
+ }
+ /* write prefix */
+ fprintf(XML_FILE, "<testsuite name=\"%s\">\n", XML_PREFIX);
+
+ return 0;
+}
+
+int32_t
+T_CTEST_EXPORT2
+ctest_xml_fini(void) {
+ if(!XML_FILE) return 0;
+
+ fprintf(XML_FILE, "</testsuite>\n");
+ fclose(XML_FILE);
+ printf(" ( test results written to %s )\n", XML_FILE_NAME);
+ XML_FILE=0;
+ return 0;
+}
+
+
+int32_t
+T_CTEST_EXPORT2
+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, timeSeconds);
+ if(failMsg) {
+ fprintf(XML_FILE, ">\n\t\t<failure type=\"err\" message=\"%s\"/>\n\t</testcase>\n", failMsg);
+ } else {
+ fprintf(XML_FILE, "/>\n");
+ }
+
+ return 0;
+}
+
+