[libvirt] [PATCH 4/6] tests: qemuxml2xml: Simplify adding to the status XML expect string generator

Peter Krempa posted 6 patches 7 years, 7 months ago
There is a newer version of this series
[libvirt] [PATCH 4/6] tests: qemuxml2xml: Simplify adding to the status XML expect string generator
Posted by Peter Krempa 7 years, 7 months ago
Unindent the static XML block and move around the autoindent calls so
that further additions don't have to add more of them.

Also rename the string holding the static XML section.
---
 tests/qemuxml2xmltest.c | 37 +++++++++++++++++++------------------
 1 file changed, 19 insertions(+), 18 deletions(-)

diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c
index 2dba3607c..4e21f5825 100644
--- a/tests/qemuxml2xmltest.c
+++ b/tests/qemuxml2xmltest.c
@@ -81,23 +81,23 @@ static const char testStatusXMLPrefixHeader[] =
 "  <taint flag='high-privileges'/>\n"
 "  <monitor path='/var/lib/libvirt/qemu/test.monitor' json='1' type='unix'/>\n";

-static const char testStatusXMLPrefixFooter[] =
-"  <qemuCaps>\n"
-"    <flag name='vnet-hdr'/>\n"
-"    <flag name='qxl.vgamem_mb'/>\n"
-"    <flag name='qxl-vga.vgamem_mb'/>\n"
-"    <flag name='pc-dimm'/>\n"
-"  </qemuCaps>\n"
-"  <devices>\n"
-"    <device alias='balloon0'/>\n"
-"    <device alias='video0'/>\n"
-"    <device alias='serial0'/>\n"
-"    <device alias='net0'/>\n"
-"    <device alias='usb'/>\n"
-"  </devices>\n"
-"  <numad nodeset='0-2' cpuset='1,3'/>\n"
-"  <libDir path='/tmp'/>\n"
-"  <channelTargetDir path='/tmp/channel'/>\n";
+static const char testStatusXMLPrefixBodyStatic[] =
+"<qemuCaps>\n"
+"  <flag name='vnet-hdr'/>\n"
+"  <flag name='qxl.vgamem_mb'/>\n"
+"  <flag name='qxl-vga.vgamem_mb'/>\n"
+"  <flag name='pc-dimm'/>\n"
+"</qemuCaps>\n"
+"<devices>\n"
+"  <device alias='balloon0'/>\n"
+"  <device alias='video0'/>\n"
+"  <device alias='serial0'/>\n"
+"  <device alias='net0'/>\n"
+"  <device alias='usb'/>\n"
+"</devices>\n"
+"<numad nodeset='0-2' cpuset='1,3'/>\n"
+"<libDir path='/tmp'/>\n"
+"<channelTargetDir path='/tmp/channel'/>\n";

 static const char testStatusXMLSuffix[] =
 "</domstatus>\n";
@@ -134,8 +134,9 @@ testGetStatusXMLPrefix(const struct testInfo *data)

     testGetStatuXMLPrefixVcpus(&buf, data);

+    virBufferAddStr(&buf, testStatusXMLPrefixBodyStatic);
+
     virBufferAdjustIndent(&buf, -2);
-    virBufferAdd(&buf, testStatusXMLPrefixFooter, -1);

     return virBufferContentAndReset(&buf);
 }
-- 
2.14.1

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 4/6] tests: qemuxml2xml: Simplify adding to the status XML expect string generator
Posted by John Ferlan 7 years, 7 months ago

On 10/04/2017 07:59 AM, Peter Krempa wrote:
> Unindent the static XML block and move around the autoindent calls so
> that further additions don't have to add more of them.
> 
> Also rename the string holding the static XML section.
> ---
>  tests/qemuxml2xmltest.c | 37 +++++++++++++++++++------------------
>  1 file changed, 19 insertions(+), 18 deletions(-)
> 

Reviewed-by: John Ferlan <jferlan@redhat.com>

John

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list