From: Simon Marchi Date: Tue, 30 Apr 2024 19:22:15 +0000 (-0400) Subject: tests: convert pretty_xml.c to C++ X-Git-Url: http://git.liburcu.org/?a=commitdiff_plain;h=9617033a3a3229daabe17e38fbab802ec2e6e223;p=lttng-tools.git tests: convert pretty_xml.c to C++ Change-Id: I40e0aa849193e789bf6634068a92b55484ab17af Signed-off-by: Simon Marchi Signed-off-by: Jérémie Galarneau --- diff --git a/tests/utils/xml-utils/Makefile.am b/tests/utils/xml-utils/Makefile.am index 7997d94e1..eec519d31 100644 --- a/tests/utils/xml-utils/Makefile.am +++ b/tests/utils/xml-utils/Makefile.am @@ -9,7 +9,7 @@ extract_xml_SOURCES = extract_xml.cpp extract_xml_CPPFLAGS = $(libxml2_CFLAGS) $(AM_CPPFLAGS) extract_xml_LDADD = $(libxml2_LIBS) -pretty_xml_SOURCES = pretty_xml.c +pretty_xml_SOURCES = pretty_xml.cpp pretty_xml_CPPFLAGS = $(libxml2_CFLAGS) $(AM_CPPFLAGS) pretty_xml_LDADD = $(libxml2_LIBS) diff --git a/tests/utils/xml-utils/pretty_xml.c b/tests/utils/xml-utils/pretty_xml.c deleted file mode 100644 index 3f296f023..000000000 --- a/tests/utils/xml-utils/pretty_xml.c +++ /dev/null @@ -1,37 +0,0 @@ -/* - * 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; -} 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; +}