X-Git-Url: https://git.lttng.org/?a=blobdiff_plain;ds=inline;f=tests%2Futils%2Fxml-utils%2Fpretty_xml.c;fp=tests%2Futils%2Fxml-utils%2Fpretty_xml.c;h=ccc1b23f36f36df8fc5ca5490f86c1ec2d2a7fda;hb=bb901ead0aea0fecad53e661ed79067faa4149c8;hp=0000000000000000000000000000000000000000;hpb=208e4eea6509113477abee7e161ca63916bd6d73;p=lttng-tools.git diff --git a/tests/utils/xml-utils/pretty_xml.c b/tests/utils/xml-utils/pretty_xml.c new file mode 100644 index 000000000..ccc1b23f3 --- /dev/null +++ b/tests/utils/xml-utils/pretty_xml.c @@ -0,0 +1,37 @@ +/* + * Copyright (C) 2021 Jonathan Rajotte + * + * SPDX-License-Identifier: GPL-2.0-only + * + */ + +/* + * Prettyfi a xml input from stdin to stddout. + * This allows a more human friendly format for xml testing when problems occur. + */ + +#include + +int main(int argc, char **argv) +{ + xmlDocPtr doc = NULL; + + /* Init libxml. */ + xmlInitParser(); + xmlKeepBlanksDefault(0); + + /* Parse the XML document from stdin. */ + doc = xmlParseFile("-"); + if (!doc) { + fprintf(stderr, "ERR parsing: xml input invalid"); + return -1; + } + + xmlDocFormatDump(stdout, doc, 1); + + xmlFreeDoc(doc); + /* Shutdown libxml. */ + xmlCleanupParser(); + + return 0; +}