X-Git-Url: http://git.liburcu.org/?a=blobdiff_plain;f=tests%2Futils%2Fxml-utils%2Fpretty_xml.cpp;fp=tests%2Futils%2Fxml-utils%2Fpretty_xml.cpp;h=3f296f0235342ca17b5c2e032984899b7071f93b;hb=9617033a3a3229daabe17e38fbab802ec2e6e223;hp=0000000000000000000000000000000000000000;hpb=6dee08cf205eb0c5f9edc37eeb5d10ad61abd0e1;p=lttng-tools.git diff --git a/tests/utils/xml-utils/pretty_xml.cpp b/tests/utils/xml-utils/pretty_xml.cpp new file mode 100644 index 000000000..3f296f023 --- /dev/null +++ b/tests/utils/xml-utils/pretty_xml.cpp @@ -0,0 +1,37 @@ +/* + * Copyright (C) 2021 EfficiOS Inc. + * + * 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(void) +{ + 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; +}