X-Git-Url: https://git.lttng.org/?p=lttng-tools.git;a=blobdiff_plain;f=tests%2Fregression%2Ftools%2Fmi%2Fextract_xml.c;h=eb1fc02b4b2b9dc2a452d31f4938996d0596c300;hp=ae07689e239f4a44168d91b396f4a649fc68d134;hb=83d6d6c4496e692df39843142cb8cf96279eaa20;hpb=55c9e7cac24318259d4f2549c97f7577b7b52db4 diff --git a/tests/regression/tools/mi/extract_xml.c b/tests/regression/tools/mi/extract_xml.c index ae07689e2..eb1fc02b4 100644 --- a/tests/regression/tools/mi/extract_xml.c +++ b/tests/regression/tools/mi/extract_xml.c @@ -33,10 +33,11 @@ * node;b; * node;c; */ -#include +#include +#include #include +#include #include -#include #include #include @@ -47,9 +48,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 +87,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 +99,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 +109,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 +122,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 +222,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);