diff -r 2c88fd553e5d -r f44c530f80da test/harness/warningsparser.c --- a/test/harness/warningsparser.c Mon Feb 06 23:55:27 2012 +0000 +++ b/test/harness/warningsparser.c Sat Oct 26 18:47:33 2013 +0100 @@ -15,11 +15,12 @@ enum { WARNINGS_INIT, WARNINGS_IN_EXPECTED, + WARNINGS_IN_SUMMARY, WARNINGS_IN_WARNING, WARNINGS_IN_AT, WARNINGS_IN_TEXT, WARNINGS_DONE, - } state; + } state,parent_state; } WarningsBaton; static void warnings_parser_start_element(GMarkupParseContext *context, @@ -30,6 +31,7 @@ guint64 tmp; char *endp; WarningsBaton *baton=user_data; + baton->parent_state=baton->state; switch(baton->state) { case WARNINGS_INIT: @@ -45,20 +47,36 @@ baton->state=WARNINGS_IN_EXPECTED; break; case WARNINGS_IN_EXPECTED: - baton->warning=g_new0(TestcaseWarning,1); - if (!strcmp(element_name,"error")) - baton->warning->is_real=TRUE; - else if (!strcmp(element_name,"false-positive")) - baton->warning->xfail=TRUE; - else if (!strcmp(element_name,"false-negative")) - baton->warning->is_real=baton->warning->xfail=TRUE; + if (!strcmp(element_name,"summary")) + { + if (baton->testcase->summary.texts) + { + g_set_error(error,G_MARKUP_ERROR, + G_MARKUP_ERROR_INVALID_CONTENT,"Multiple summary " + "elements are not valid"); + } + else + baton->state=WARNINGS_IN_SUMMARY; + } else { - g_set_error(error,G_MARKUP_ERROR,G_MARKUP_ERROR_UNKNOWN_ELEMENT, - "Unknown element in 'expected': '%s'",element_name); - g_free(baton->warning); - baton->warning=NULL; - return; + baton->warning=g_new0(TestcaseWarning,1); + if (!strcmp(element_name,"error")) + baton->warning->is_real=TRUE; + else if (!strcmp(element_name,"false-positive")) + baton->warning->xfail=TRUE; + else if (!strcmp(element_name,"false-negative")) + baton->warning->is_real=baton->warning->xfail=TRUE; + else + { + g_set_error(error,G_MARKUP_ERROR, + G_MARKUP_ERROR_UNKNOWN_ELEMENT, + "Unknown element in 'expected': '%s'",element_name); + g_free(baton->warning); + baton->warning=NULL; + return; + } + baton->state=WARNINGS_IN_WARNING; } if (attribute_names[0]) { @@ -66,12 +84,28 @@ G_MARKUP_ERROR_UNKNOWN_ATTRIBUTE, "Unknown attribute on element '%s': '%s'",element_name, attribute_names[0]); - g_free(baton->warning); - baton->warning=NULL; + if (baton->state==WARNINGS_IN_WARNING) + { + g_free(baton->warning); + baton->warning=NULL; + } + baton->state=WARNINGS_IN_EXPECTED; return; } - else - baton->state=WARNINGS_IN_WARNING; + break; + case WARNINGS_IN_SUMMARY: + if (!strcmp(element_name,"text")) + { + if (attribute_names[0]) + { + g_set_error(error,G_MARKUP_ERROR, + G_MARKUP_ERROR_UNKNOWN_ATTRIBUTE, + "Unknown attribute on element 'text': '%s'", + attribute_names[0]); + return; + } + baton->state=WARNINGS_IN_TEXT; + } break; case WARNINGS_IN_WARNING: if (!strcmp(element_name,"at")) @@ -162,6 +196,15 @@ g_slist_reverse(baton->testcase->warnings); baton->state=WARNINGS_DONE; break; + case WARNINGS_IN_SUMMARY: + if (!baton->testcase->summary.texts) + g_set_error(error,G_MARKUP_ERROR,G_MARKUP_ERROR_INVALID_CONTENT, + "Summary element must contain at least one text element"); + else + baton->testcase->summary.texts= + g_slist_reverse(baton->testcase->summary.texts); + baton->state=WARNINGS_IN_EXPECTED; + break; case WARNINGS_IN_WARNING: baton->warning->locations= g_slist_reverse(baton->warning->locations); @@ -177,7 +220,7 @@ baton->state=WARNINGS_IN_WARNING; break; case WARNINGS_IN_TEXT: - baton->state=WARNINGS_IN_WARNING; + baton->state=baton->parent_state; break; default: g_set_error(error,G_MARKUP_ERROR,G_MARKUP_ERROR_UNKNOWN_ELEMENT, @@ -198,6 +241,11 @@ g_set_error(error,G_MARKUP_ERROR,G_MARKUP_ERROR_INVALID_CONTENT, "The 'expected' tag does not take any content"); break; + case WARNINGS_IN_SUMMARY: + if (strspn(text," \t\n")!=text_len) + g_set_error(error,G_MARKUP_ERROR,G_MARKUP_ERROR_INVALID_CONTENT, + "The summary tags do not take any content"); + break; case WARNINGS_IN_WARNING: if (strspn(text," \t\n")!=text_len) g_set_error(error,G_MARKUP_ERROR,G_MARKUP_ERROR_INVALID_CONTENT, @@ -211,7 +259,10 @@ case WARNINGS_IN_TEXT: s=g_strdup(text+strspn(text," \t\n")); g_strchomp(s); - if (baton->warning->text) + if (baton->parent_state==WARNINGS_IN_SUMMARY) + baton->testcase->summary.texts= + g_slist_prepend(baton->testcase->summary.texts,s); + else if (baton->warning->text) { t=g_strconcat(baton->warning->text,s,NULL); g_free(baton->warning->text); @@ -237,6 +288,7 @@ parser.text=warnings_parser_text; baton=g_new0(WarningsBaton,1); baton->testcase=testcase; + baton->parent_state=WARNINGS_INIT; baton->state=WARNINGS_INIT; return g_markup_parse_context_new(&parser, G_MARKUP_TREAT_CDATA_AS_TEXT|G_MARKUP_PREFIX_ERROR_POSITION,