This util reads on stdin and outputs an indented/formatted xml.
It is equivalent to "xmllint --format -".
It will be used for MI trigger testing. For testing we will essentially
diff the output of the command against the expected output. While a
nicely formatted multi-line output is not necessary for a machine to
do the diff, the human that will have to debug it will surely appreciate
it.
Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: Ie1597644941c55ce3e59f7ff16f196ac36325179
/tests/utils/testapp/gen-kernel-test-events/gen-kernel-test-events
/tests/utils/xml-utils/extract_xml
/tests/utils/xml-utils/validate_xml
+/tests/utils/xml-utils/pretty_xml
/tests/regression/tools/live/live_test
/tests/unit/ini_config/ini_config
/tests/perf/find_event
# SPDX-License-Identifier: GPL-2.0-only
-noinst_PROGRAMS = validate_xml extract_xml
+noinst_PROGRAMS = validate_xml extract_xml pretty_xml
validate_xml_SOURCES = validate_xml.c
validate_xml_CPPFLAGS = $(libxml2_CFLAGS) $(AM_CPPFLAGS)
validate_xml_LDADD = $(libxml2_LIBS)
extract_xml_CPPFLAGS = $(libxml2_CFLAGS) $(AM_CPPFLAGS)
extract_xml_LDADD = $(libxml2_LIBS)
+pretty_xml_SOURCES = pretty_xml.c
+pretty_xml_CPPFLAGS = $(libxml2_CFLAGS) $(AM_CPPFLAGS)
+pretty_xml_LDADD = $(libxml2_LIBS)
+
all-local:
@if [ x"$(srcdir)" != x"$(builddir)" ]; then \
for script in $(EXTRA_DIST); do \
--- /dev/null
+/*
+ * Copyright (C) 2021 Jonathan Rajotte <jonathan.r.julien@gmail.com>
+ *
+ * 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 <libxml/parser.h>
+
+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;
+}