[libvirt] [PATCH V2] tests: xmconfigtest: add tests for cmdline formating

Jim Fehlig posted 1 patch 5 years, 10 months ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/20180523213129.28768-1-jfehlig@suse.com
Test syntax-check passed
tests/xmconfigdata/test-paravirt-extra-root.cfg | 13 ++++++++++
tests/xmconfigdata/test-paravirt-extra-root.xml | 34 +++++++++++++++++++++++++
tests/xmconfigdata/test-paravirt-maxvcpus.cfg   |  1 +
tests/xmconfigdata/test-paravirt-maxvcpus.xml   |  1 +
tests/xmconfigdata/test-paravirt-root.cfg       | 12 +++++++++
tests/xmconfigdata/test-paravirt-root.xml       | 34 +++++++++++++++++++++++++
tests/xmconfigdata/test-paravirt-vcpu.cfg       |  1 +
tests/xmconfigdata/test-paravirt-vcpu.xml       |  1 +
tests/xmconfigtest.c                            |  2 ++
9 files changed, 99 insertions(+)
create mode 100644 tests/xmconfigdata/test-paravirt-extra-root.cfg
create mode 100644 tests/xmconfigdata/test-paravirt-extra-root.xml
create mode 100644 tests/xmconfigdata/test-paravirt-root.cfg
create mode 100644 tests/xmconfigdata/test-paravirt-root.xml
[libvirt] [PATCH V2] tests: xmconfigtest: add tests for cmdline formating
Posted by Jim Fehlig 5 years, 10 months ago
Commit 656151bf fixed formatting of the <cmdline> element. Perhaps it
would have been noticed and fixed earlier if we had a test. With this
change, all possible cases of formating <cmdline> from xmconfig are
covered

1. no 'extra=' or 'root=' in xm.cfg
2. 'extra=' but no 'root=' in xm.cfg
3. 'root=' but no 'extra=' in xm.cfg
4. both 'root=' and 'extra=' in xm.cfg

Case 1 is covered by all existing paravirt tests since they have no
'extra=' or 'root='. Case 2 is covered by adding 'extra=' to a few
of the existing paravirt tests. Cases 3 and 4 are covered by new
tests that only test conversion of xm.cfg to xml.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
---
 tests/xmconfigdata/test-paravirt-extra-root.cfg | 13 ++++++++++
 tests/xmconfigdata/test-paravirt-extra-root.xml | 34 +++++++++++++++++++++++++
 tests/xmconfigdata/test-paravirt-maxvcpus.cfg   |  1 +
 tests/xmconfigdata/test-paravirt-maxvcpus.xml   |  1 +
 tests/xmconfigdata/test-paravirt-root.cfg       | 12 +++++++++
 tests/xmconfigdata/test-paravirt-root.xml       | 34 +++++++++++++++++++++++++
 tests/xmconfigdata/test-paravirt-vcpu.cfg       |  1 +
 tests/xmconfigdata/test-paravirt-vcpu.xml       |  1 +
 tests/xmconfigtest.c                            |  2 ++
 9 files changed, 99 insertions(+)
 create mode 100644 tests/xmconfigdata/test-paravirt-extra-root.cfg
 create mode 100644 tests/xmconfigdata/test-paravirt-extra-root.xml
 create mode 100644 tests/xmconfigdata/test-paravirt-root.cfg
 create mode 100644 tests/xmconfigdata/test-paravirt-root.xml

diff --git a/tests/xmconfigdata/test-paravirt-extra-root.cfg b/tests/xmconfigdata/test-paravirt-extra-root.cfg
new file mode 100644
index 0000000000..2569f2f22c
--- /dev/null
+++ b/tests/xmconfigdata/test-paravirt-extra-root.cfg
@@ -0,0 +1,13 @@
+name = "XenGuest1"
+uuid = "c7a5fdb0-cdaf-9455-926a-d65c16db1809"
+memory = 512
+vcpus = 2
+localtime = 0
+on_poweroff = "destroy"
+on_reboot = "restart"
+on_crash = "restart"
+vif = [ "mac=00:16:3e:66:94:9c,bridge=br0,script=vif-bridge" ]
+bootloader = "/usr/bin/pygrub"
+root = "/dev/xvda2"
+extra = "console=hvc0"
+disk = [ "phy:/dev/HostVG/XenGuest1,xvda,w" ]
diff --git a/tests/xmconfigdata/test-paravirt-extra-root.xml b/tests/xmconfigdata/test-paravirt-extra-root.xml
new file mode 100644
index 0000000000..325b07d8e1
--- /dev/null
+++ b/tests/xmconfigdata/test-paravirt-extra-root.xml
@@ -0,0 +1,34 @@
+<domain type='xen'>
+  <name>XenGuest1</name>
+  <uuid>c7a5fdb0-cdaf-9455-926a-d65c16db1809</uuid>
+  <memory unit='KiB'>524288</memory>
+  <currentMemory unit='KiB'>524288</currentMemory>
+  <vcpu placement='static'>2</vcpu>
+  <bootloader>/usr/bin/pygrub</bootloader>
+  <os>
+    <type arch='x86_64' machine='xenpv'>linux</type>
+    <cmdline>root=/dev/xvda2 console=hvc0</cmdline>
+  </os>
+  <clock offset='utc' adjustment='reset'/>
+  <on_poweroff>destroy</on_poweroff>
+  <on_reboot>restart</on_reboot>
+  <on_crash>restart</on_crash>
+  <devices>
+    <disk type='block' device='disk'>
+      <driver name='phy' type='raw'/>
+      <source dev='/dev/HostVG/XenGuest1'/>
+      <target dev='xvda' bus='xen'/>
+    </disk>
+    <interface type='bridge'>
+      <mac address='00:16:3e:66:94:9c'/>
+      <source bridge='br0'/>
+      <script path='vif-bridge'/>
+    </interface>
+    <console type='pty'>
+      <target type='xen' port='0'/>
+    </console>
+    <input type='mouse' bus='xen'/>
+    <input type='keyboard' bus='xen'/>
+    <memballoon model='xen'/>
+  </devices>
+</domain>
diff --git a/tests/xmconfigdata/test-paravirt-maxvcpus.cfg b/tests/xmconfigdata/test-paravirt-maxvcpus.cfg
index 8d1ac4d786..f06db61171 100644
--- a/tests/xmconfigdata/test-paravirt-maxvcpus.cfg
+++ b/tests/xmconfigdata/test-paravirt-maxvcpus.cfg
@@ -10,4 +10,5 @@ on_reboot = "restart"
 on_crash = "restart"
 vif = [ "mac=00:16:3e:66:94:9c,bridge=br0,script=vif-bridge" ]
 bootloader = "/usr/bin/pygrub"
+extra = "console=hvc0"
 disk = [ "phy:/dev/HostVG/XenGuest1,xvda,w" ]
diff --git a/tests/xmconfigdata/test-paravirt-maxvcpus.xml b/tests/xmconfigdata/test-paravirt-maxvcpus.xml
index ce66503dc5..3012821ad4 100644
--- a/tests/xmconfigdata/test-paravirt-maxvcpus.xml
+++ b/tests/xmconfigdata/test-paravirt-maxvcpus.xml
@@ -7,6 +7,7 @@
   <bootloader>/usr/bin/pygrub</bootloader>
   <os>
     <type arch='x86_64' machine='xenpv'>linux</type>
+    <cmdline>console=hvc0</cmdline>
   </os>
   <clock offset='utc' adjustment='reset'/>
   <on_poweroff>destroy</on_poweroff>
diff --git a/tests/xmconfigdata/test-paravirt-root.cfg b/tests/xmconfigdata/test-paravirt-root.cfg
new file mode 100644
index 0000000000..8cdfbd9384
--- /dev/null
+++ b/tests/xmconfigdata/test-paravirt-root.cfg
@@ -0,0 +1,12 @@
+name = "XenGuest1"
+uuid = "c7a5fdb0-cdaf-9455-926a-d65c16db1809"
+memory = 512
+vcpus = 2
+localtime = 0
+on_poweroff = "destroy"
+on_reboot = "restart"
+on_crash = "restart"
+vif = [ "mac=00:16:3e:66:94:9c,bridge=br0,script=vif-bridge" ]
+bootloader = "/usr/bin/pygrub"
+root = "/dev/xvda2"
+disk = [ "phy:/dev/HostVG/XenGuest1,xvda,w" ]
diff --git a/tests/xmconfigdata/test-paravirt-root.xml b/tests/xmconfigdata/test-paravirt-root.xml
new file mode 100644
index 0000000000..12d1e3bdbd
--- /dev/null
+++ b/tests/xmconfigdata/test-paravirt-root.xml
@@ -0,0 +1,34 @@
+<domain type='xen'>
+  <name>XenGuest1</name>
+  <uuid>c7a5fdb0-cdaf-9455-926a-d65c16db1809</uuid>
+  <memory unit='KiB'>524288</memory>
+  <currentMemory unit='KiB'>524288</currentMemory>
+  <vcpu placement='static'>2</vcpu>
+  <bootloader>/usr/bin/pygrub</bootloader>
+  <os>
+    <type arch='x86_64' machine='xenpv'>linux</type>
+    <cmdline>root=/dev/xvda2</cmdline>
+  </os>
+  <clock offset='utc' adjustment='reset'/>
+  <on_poweroff>destroy</on_poweroff>
+  <on_reboot>restart</on_reboot>
+  <on_crash>restart</on_crash>
+  <devices>
+    <disk type='block' device='disk'>
+      <driver name='phy' type='raw'/>
+      <source dev='/dev/HostVG/XenGuest1'/>
+      <target dev='xvda' bus='xen'/>
+    </disk>
+    <interface type='bridge'>
+      <mac address='00:16:3e:66:94:9c'/>
+      <source bridge='br0'/>
+      <script path='vif-bridge'/>
+    </interface>
+    <console type='pty'>
+      <target type='xen' port='0'/>
+    </console>
+    <input type='mouse' bus='xen'/>
+    <input type='keyboard' bus='xen'/>
+    <memballoon model='xen'/>
+  </devices>
+</domain>
diff --git a/tests/xmconfigdata/test-paravirt-vcpu.cfg b/tests/xmconfigdata/test-paravirt-vcpu.cfg
index 8d1ac4d786..f06db61171 100644
--- a/tests/xmconfigdata/test-paravirt-vcpu.cfg
+++ b/tests/xmconfigdata/test-paravirt-vcpu.cfg
@@ -10,4 +10,5 @@ on_reboot = "restart"
 on_crash = "restart"
 vif = [ "mac=00:16:3e:66:94:9c,bridge=br0,script=vif-bridge" ]
 bootloader = "/usr/bin/pygrub"
+extra = "console=hvc0"
 disk = [ "phy:/dev/HostVG/XenGuest1,xvda,w" ]
diff --git a/tests/xmconfigdata/test-paravirt-vcpu.xml b/tests/xmconfigdata/test-paravirt-vcpu.xml
index ce66503dc5..3012821ad4 100644
--- a/tests/xmconfigdata/test-paravirt-vcpu.xml
+++ b/tests/xmconfigdata/test-paravirt-vcpu.xml
@@ -7,6 +7,7 @@
   <bootloader>/usr/bin/pygrub</bootloader>
   <os>
     <type arch='x86_64' machine='xenpv'>linux</type>
+    <cmdline>console=hvc0</cmdline>
   </os>
   <clock offset='utc' adjustment='reset'/>
   <on_poweroff>destroy</on_poweroff>
diff --git a/tests/xmconfigtest.c b/tests/xmconfigtest.c
index 6851fa73cd..eaec7c3a5c 100644
--- a/tests/xmconfigtest.c
+++ b/tests/xmconfigtest.c
@@ -200,6 +200,8 @@ mymain(void)
     DO_TEST("paravirt-net-vifname");
     DO_TEST("paravirt-vcpu");
     DO_TEST("paravirt-maxvcpus");
+    DO_TEST_FORMAT("paravirt-root");
+    DO_TEST_FORMAT("paravirt-extra-root");
     DO_TEST("fullvirt-new-cdrom");
     DO_TEST("fullvirt-utc");
     DO_TEST("fullvirt-localtime");
-- 
2.16.3

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH V2] tests: xmconfigtest: add tests for cmdline formating
Posted by John Ferlan 5 years, 9 months ago

On 05/23/2018 05:31 PM, Jim Fehlig wrote:
> Commit 656151bf fixed formatting of the <cmdline> element. Perhaps it
> would have been noticed and fixed earlier if we had a test. With this
> change, all possible cases of formating <cmdline> from xmconfig are

formatting

> covered
> 
> 1. no 'extra=' or 'root=' in xm.cfg
> 2. 'extra=' but no 'root=' in xm.cfg
> 3. 'root=' but no 'extra=' in xm.cfg
> 4. both 'root=' and 'extra=' in xm.cfg
> 
> Case 1 is covered by all existing paravirt tests since they have no
> 'extra=' or 'root='. Case 2 is covered by adding 'extra=' to a few
> of the existing paravirt tests. Cases 3 and 4 are covered by new
> tests that only test conversion of xm.cfg to xml.
> 
> Signed-off-by: Jim Fehlig <jfehlig@suse.com>
> ---
>  tests/xmconfigdata/test-paravirt-extra-root.cfg | 13 ++++++++++
>  tests/xmconfigdata/test-paravirt-extra-root.xml | 34 +++++++++++++++++++++++++
>  tests/xmconfigdata/test-paravirt-maxvcpus.cfg   |  1 +
>  tests/xmconfigdata/test-paravirt-maxvcpus.xml   |  1 +
>  tests/xmconfigdata/test-paravirt-root.cfg       | 12 +++++++++
>  tests/xmconfigdata/test-paravirt-root.xml       | 34 +++++++++++++++++++++++++
>  tests/xmconfigdata/test-paravirt-vcpu.cfg       |  1 +
>  tests/xmconfigdata/test-paravirt-vcpu.xml       |  1 +
>  tests/xmconfigtest.c                            |  2 ++
>  9 files changed, 99 insertions(+)
>  create mode 100644 tests/xmconfigdata/test-paravirt-extra-root.cfg
>  create mode 100644 tests/xmconfigdata/test-paravirt-extra-root.xml
>  create mode 100644 tests/xmconfigdata/test-paravirt-root.cfg
>  create mode 100644 tests/xmconfigdata/test-paravirt-root.xml
> 

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

John

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH V2] tests: xmconfigtest: add tests for cmdline formating
Posted by Jim Fehlig 5 years, 9 months ago
On 06/04/2018 12:29 PM, John Ferlan wrote:
> 
> 
> On 05/23/2018 05:31 PM, Jim Fehlig wrote:
>> Commit 656151bf fixed formatting of the <cmdline> element. Perhaps it
>> would have been noticed and fixed earlier if we had a test. With this
>> change, all possible cases of formating <cmdline> from xmconfig are
> 
> formatting
> 
>> covered
>>
>> 1. no 'extra=' or 'root=' in xm.cfg
>> 2. 'extra=' but no 'root=' in xm.cfg
>> 3. 'root=' but no 'extra=' in xm.cfg
>> 4. both 'root=' and 'extra=' in xm.cfg
>>
>> Case 1 is covered by all existing paravirt tests since they have no
>> 'extra=' or 'root='. Case 2 is covered by adding 'extra=' to a few
>> of the existing paravirt tests. Cases 3 and 4 are covered by new
>> tests that only test conversion of xm.cfg to xml.
>>
>> Signed-off-by: Jim Fehlig <jfehlig@suse.com>
>> ---
>>   tests/xmconfigdata/test-paravirt-extra-root.cfg | 13 ++++++++++
>>   tests/xmconfigdata/test-paravirt-extra-root.xml | 34 +++++++++++++++++++++++++
>>   tests/xmconfigdata/test-paravirt-maxvcpus.cfg   |  1 +
>>   tests/xmconfigdata/test-paravirt-maxvcpus.xml   |  1 +
>>   tests/xmconfigdata/test-paravirt-root.cfg       | 12 +++++++++
>>   tests/xmconfigdata/test-paravirt-root.xml       | 34 +++++++++++++++++++++++++
>>   tests/xmconfigdata/test-paravirt-vcpu.cfg       |  1 +
>>   tests/xmconfigdata/test-paravirt-vcpu.xml       |  1 +
>>   tests/xmconfigtest.c                            |  2 ++
>>   9 files changed, 99 insertions(+)
>>   create mode 100644 tests/xmconfigdata/test-paravirt-extra-root.cfg
>>   create mode 100644 tests/xmconfigdata/test-paravirt-extra-root.xml
>>   create mode 100644 tests/xmconfigdata/test-paravirt-root.cfg
>>   create mode 100644 tests/xmconfigdata/test-paravirt-root.xml
>>
> 
> Reviewed-by: John Ferlan <jferlan@redhat.com>

Thanks for the review - and reminding me about this patch :-). Pushed now.

Regards,
Jim

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