X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=tests%2Fregression%2Ftools%2Fmi%2Fextract_xml.c;h=9c324896e3d18cbe7e9797eb9904180e18d86cca;hb=40f1bcbe2678793744ef1f365c5a7ab25f003121;hp=ddf8c16773331b9786b2018c4cbf2d7fb5a651e5;hpb=41af1adf5100627c2e11565e7d9e4b9c5a8b9fac;p=lttng-tools.git diff --git a/tests/regression/tools/mi/extract_xml.c b/tests/regression/tools/mi/extract_xml.c index ddf8c1677..9c324896e 100644 --- a/tests/regression/tools/mi/extract_xml.c +++ b/tests/regression/tools/mi/extract_xml.c @@ -35,6 +35,7 @@ */ #include #include +#include #include #include #include @@ -48,8 +49,9 @@ #if defined(LIBXML_XPATH_ENABLED) -int opt_verbose; -int node_exist; +static int opt_verbose; +static int node_exist; +static bool result = false; /** * print_xpath_nodes: @@ -86,7 +88,7 @@ static int print_xpath_nodes(xmlDocPtr doc, xmlNodeSetPtr nodes, FILE *output) node_child_value_string = xmlNodeListGetString(doc, cur->children, 1); if (node_exist) { - fprintf(output, "true\n"); + result = true; } else if (opt_verbose) { fprintf(output, "%s;%s;\n", cur->name, node_child_value_string); @@ -98,7 +100,7 @@ static int print_xpath_nodes(xmlDocPtr doc, xmlNodeSetPtr nodes, FILE *output) } else { /* We don't want to print non-final element */ if (node_exist) { - fprintf(output, "true\n"); + result = true; } else { fprintf(stderr, "ERR:%s\n", "Xpath expression return non-final xml element"); @@ -108,7 +110,7 @@ static int print_xpath_nodes(xmlDocPtr doc, xmlNodeSetPtr nodes, FILE *output) } } else { if (node_exist) { - fprintf(output, "true\n"); + result = true; } else { /* We don't want to print non-final element */ fprintf(stderr, "ERR:%s\n", @@ -121,7 +123,7 @@ static int print_xpath_nodes(xmlDocPtr doc, xmlNodeSetPtr nodes, FILE *output) } else { cur = nodes->nodeTab[i]; if (node_exist) { - fprintf(output, "true\n"); + result = true; } else if (opt_verbose) { fprintf(output, "%s;%s;\n", cur->parent->name, cur->content); } else { @@ -221,6 +223,9 @@ static int extract_xpath(const char *xml_path, const xmlChar *xpath) xmlFreeDoc(doc); return -1; } + if (node_exist && result) { + fprintf(stdout, "true\n"); + } /* Cleanup */ xmlXPathFreeObject(xpathObj);