[libvirt] [PATCH 1/1] tests: xmconfigtest: Add test for os.cmdline

Add test case for the os cmdline. Check if: 656151bf5dd299322dcf37d06d20534e667a1963 work as expected. Signed-off-by: Filip Alac <filipalac@gmail.com> --- tests/xmconfigdata/test-os-cmdline.cfg | 14 +++++++++ tests/xmconfigdata/test-os-cmdline.xml | 40 ++++++++++++++++++++++++++ tests/xmconfigtest.c | 2 ++ 3 files changed, 56 insertions(+) create mode 100644 tests/xmconfigdata/test-os-cmdline.cfg create mode 100644 tests/xmconfigdata/test-os-cmdline.xml diff --git a/tests/xmconfigdata/test-os-cmdline.cfg b/tests/xmconfigdata/test-os-cmdline.cfg new file mode 100644 index 0000000..8ca8179 --- /dev/null +++ b/tests/xmconfigdata/test-os-cmdline.cfg @@ -0,0 +1,14 @@ +name = "test" +uuid = "ab6eec38-06ad-4fa6-aa50-4bb3dac321ef" +maxmem = 128 +memory = 128 +vcpus = 1 +localtime = 0 +on_poweroff = "destroy" +on_reboot = "restart" +on_crash = "restart" +vif = [ "mac=00:16:3e:70:61:00,bridge=xenbr0,script=vif-bridge" ] +kernel = "/boot/vmlinuz-2.6.26-2-xen-amd64" +ramdisk = "/boot/initrd.img-2.6.26-2-xen-amd64" +extra = "root=/dev/xvda2 ro" +disk = [ "file:/opt/xen/domains/test/swap.img,xvda1,w", "file:/opt/xen/domains/test/disk.img,xvda2,w" ] diff --git a/tests/xmconfigdata/test-os-cmdline.xml b/tests/xmconfigdata/test-os-cmdline.xml new file mode 100644 index 0000000..5f85b2e --- /dev/null +++ b/tests/xmconfigdata/test-os-cmdline.xml @@ -0,0 +1,40 @@ +<domain type='xen'> + <name>test</name> + <uuid>ab6eec38-06ad-4fa6-aa50-4bb3dac321ef</uuid> + <memory unit='KiB'>131072</memory> + <currentMemory unit='KiB'>131072</currentMemory> + <vcpu placement='static'>1</vcpu> + <os> + <type arch='x86_64' machine='xenpv'>linux</type> + <kernel>/boot/vmlinuz-2.6.26-2-xen-amd64</kernel> + <initrd>/boot/initrd.img-2.6.26-2-xen-amd64</initrd> + <cmdline>root=/dev/xvda2 ro</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='file' device='disk'> + <driver name='file' type='raw'/> + <source file='/opt/xen/domains/test/swap.img'/> + <target dev='xvda1' bus='xen'/> + </disk> + <disk type='file' device='disk'> + <driver name='file' type='raw'/> + <source file='/opt/xen/domains/test/disk.img'/> + <target dev='xvda2' bus='xen'/> + </disk> + <interface type='bridge'> + <mac address='00:16:3e:70:61:00'/> + <source bridge='xenbr0'/> + <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/xmconfigtest.c b/tests/xmconfigtest.c index 6851fa7..2820711 100644 --- a/tests/xmconfigtest.c +++ b/tests/xmconfigtest.c @@ -234,6 +234,8 @@ mymain(void) DO_TEST("disk-drv-blktap-raw"); DO_TEST("disk-drv-blktap2-raw"); + DO_TEST("os-cmdline"); + virObjectUnref(caps); virObjectUnref(xmlopt); -- 2.17.0

On 05/21/2018 05:57 AM, Filip Alac wrote:
Add test case for the os cmdline. Check if: 656151bf5dd299322dcf37d06d20534e667a1963 work as expected.
Thanks for taking up Cole's suggestion! I had added it to my todo list. To test the code you fixed in 656151bf, we need to check the following 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 Since all of the existing xmconfig tests have no 'extra=' or 'root=', we've got 1 covered :-). We could be evil and test 2 by adding 'extra=' to an existing paravirt test, e.g. test-paravirt-vcpu. Perhaps less evil would be to add 'extra=' to all the existing paravirt tests, along with <cmdline> in associated .xml file. 3 and 4 need handled a bit differently since the roundtrip xm.cfg to xml to xm.cfg tests will not pass when xm.cfg contains 'root='. The xm.cfg to xml conversion maps 'root=' to <cmdline>, but the reverse maps <cmdline> to 'extra='. The easy solution is to only test the xm.cfg to xml conversion using the DO_TEST_FORMAT macro. E.g attached is a patch that tests xm.cfg to xml conversion of xm.cfg containing both 'extra=' and 'root='. We'd need a similar change for testing only 'root='. Do you have time to tweak the patch to test all conditions and submit a V2? If not I'll get to it. Regards, Jim

It may be worth to take a look at files test-paravirt-cmdline,cmdline-bogus-extra...etc. in tests/xlconfigdata. They look they are testing the same/similiar problem. Feel free to to make v2, Thanks. 2018-05-22 1:57 GMT+02:00 Jim Fehlig <jfehlig@suse.com>:
On 05/21/2018 05:57 AM, Filip Alac wrote:
Add test case for the os cmdline. Check if: 656151bf5dd299322dcf37d06d20534e667a1963 work as expected.
Thanks for taking up Cole's suggestion! I had added it to my todo list.
To test the code you fixed in 656151bf, we need to check the following
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
Since all of the existing xmconfig tests have no 'extra=' or 'root=', we've got 1 covered :-). We could be evil and test 2 by adding 'extra=' to an existing paravirt test, e.g. test-paravirt-vcpu. Perhaps less evil would be to add 'extra=' to all the existing paravirt tests, along with <cmdline> in associated .xml file.
3 and 4 need handled a bit differently since the roundtrip xm.cfg to xml to xm.cfg tests will not pass when xm.cfg contains 'root='. The xm.cfg to xml conversion maps 'root=' to <cmdline>, but the reverse maps <cmdline> to 'extra='. The easy solution is to only test the xm.cfg to xml conversion using the DO_TEST_FORMAT macro. E.g attached is a patch that tests xm.cfg to xml conversion of xm.cfg containing both 'extra=' and 'root='. We'd need a similar change for testing only 'root='.
Do you have time to tweak the patch to test all conditions and submit a V2? If not I'll get to it.
Regards, Jim
participants (3)
-
Filip Alac
-
filip aláč
-
Jim Fehlig