From 1ec25df269d327e19e8ed876032b11760675a52b Mon Sep 17 00:00:00 2001 From: Daniel Veillard Date: Wed, 11 Apr 2007 16:06:30 +0000 Subject: * src/xend_internal.c src/xml.c: applied patch from Nobuhiro Itou to handle CDRom devices with no device name * tests/sexpr2xmltest.c tests/xml2sexprtest.c tests/sexpr2xmldata/sexpr2xml-no-source-cdrom.sexpr tests/sexpr2xmldata/sexpr2xml-no-source-cdrom.xml tests/xml2sexprdata/xml2sexpr-no-source-cdrom.sexpr tests/xml2sexprdata/xml2sexpr-no-source-cdrom.xml: added regression tests for this case based on Nobuhiro Itou test inputs. Daniel --- .../sexpr2xmldata/sexpr2xml-no-source-cdrom.sexpr | 66 ++++++++++++++++++++++ tests/sexpr2xmldata/sexpr2xml-no-source-cdrom.xml | 36 ++++++++++++ tests/sexpr2xmltest.c | 10 ++++ .../xml2sexprdata/xml2sexpr-no-source-cdrom.sexpr | 1 + tests/xml2sexprdata/xml2sexpr-no-source-cdrom.xml | 36 ++++++++++++ tests/xml2sexprtest.c | 25 ++++++-- 6 files changed, 170 insertions(+), 4 deletions(-) create mode 100644 tests/sexpr2xmldata/sexpr2xml-no-source-cdrom.sexpr create mode 100644 tests/sexpr2xmldata/sexpr2xml-no-source-cdrom.xml create mode 100644 tests/xml2sexprdata/xml2sexpr-no-source-cdrom.sexpr create mode 100644 tests/xml2sexprdata/xml2sexpr-no-source-cdrom.xml (limited to 'tests') diff --git a/tests/sexpr2xmldata/sexpr2xml-no-source-cdrom.sexpr b/tests/sexpr2xmldata/sexpr2xml-no-source-cdrom.sexpr new file mode 100644 index 000000000..f3e4901e4 --- /dev/null +++ b/tests/sexpr2xmldata/sexpr2xml-no-source-cdrom.sexpr @@ -0,0 +1,66 @@ +(domain + (domid 6) + (on_crash destroy) + (memory 350) + (uuid cc2315e7-d26a-307a-438c-6d188ec4c09c) + (bootloader_args ) + (name test) + (maxmem 382) + (on_reboot destroy) + (on_poweroff destroy) + (localtime 0) + (vcpus 1) + (bootloader ) + (shadow_memory 4) + (cpu_weight 256) + (cpu_cap 0) + (features ) + (on_xend_start ignore) + (on_xend_stop ignore) + (start_time 1175165307.38) + (cpu_time 0.956663338) + (online_vcpus 1) + (image + (hvm + (kernel /usr/lib/xen/boot/hvmloader) + (vnc 1) + (vncunused 1) + (device_model /usr/lib/xen/bin/qemu-dm) + (pae 1) + (apic 1) + (acpi 1) + (boot c) + (serial pty) + (vcpus 1) + ) + ) + (status 0) + (memory_dynamic_min 358) + (memory_dynamic_max 382) + (store_mfn 89598) + (device + (vif + (bridge xenbr0) + (mac 00:16:3e:0a:7b:39) + (type ioemu) + (uuid 127fee09-a0c8-c79b-4ee5-6c194efff73a) + ) + ) + (device + (vbd + (uname phy:/dev/sda8) + (driver paravirtualised) + (mode w) + (dev hda:disk) + (uuid df6969ad-d312-deb1-8d36-223d71e4ce95) + ) + ) + (device + (vbd + (driver paravirtualised) + (mode r) + (dev hdc:cdrom) + (uuid fca3aa85-1d1f-2c31-2f0b-f2dff2311f7e) + ) + ) +) diff --git a/tests/sexpr2xmldata/sexpr2xml-no-source-cdrom.xml b/tests/sexpr2xmldata/sexpr2xml-no-source-cdrom.xml new file mode 100644 index 000000000..5b9c7f61f --- /dev/null +++ b/tests/sexpr2xmldata/sexpr2xml-no-source-cdrom.xml @@ -0,0 +1,36 @@ + + test + cc2315e7d26a307a438c6d188ec4c09c + + hvm + /usr/lib/xen/boot/hvmloader + + + 391168 + 358400 + 1 + destroy + destroy + destroy + + + + + + + /usr/lib/xen/bin/qemu-dm + + + + + + + + + + + + + + + diff --git a/tests/sexpr2xmltest.c b/tests/sexpr2xmltest.c index 80403bddf..2c567aaf8 100644 --- a/tests/sexpr2xmltest.c +++ b/tests/sexpr2xmltest.c @@ -124,6 +124,12 @@ static int testCompareNetBridged(void *data ATTRIBUTE_UNUSED) { 1); } +static int testCompareNoSourceCDRom(void *data ATTRIBUTE_UNUSED) { + return testCompareFiles("sexpr2xmldata/sexpr2xml-no-source-cdrom.xml", + "sexpr2xmldata/sexpr2xml-no-source-cdrom.sexpr", + 1); +} + int main(int argc, char **argv) @@ -189,6 +195,10 @@ main(int argc, char **argv) 1, testCompareNetBridged, NULL) != 0) ret = -1; + if (virtTestRun("SEXPR-2-XML no source CDRom", + 1, testCompareNoSourceCDRom, NULL) != 0) + ret = -1; + exit(ret==0 ? EXIT_SUCCESS : EXIT_FAILURE); } #else /* WITHOUT_XEN */ diff --git a/tests/xml2sexprdata/xml2sexpr-no-source-cdrom.sexpr b/tests/xml2sexprdata/xml2sexpr-no-source-cdrom.sexpr new file mode 100644 index 000000000..a027cd02e --- /dev/null +++ b/tests/xml2sexprdata/xml2sexpr-no-source-cdrom.sexpr @@ -0,0 +1 @@ +(vm (name 'test')(memory 350)(maxmem 382)(vcpus 1)(uuid 'cc2315e7d26a307a438c6d188ec4c09c')(on_poweroff 'destroy')(on_reboot 'destroy')(on_crash 'destroy')(image (hvm (kernel '/usr/lib/xen/boot/hvmloader')(device_model '/usr/lib/xen/bin/qemu-dm')(vcpus 1)(boot c)(acpi 1)(apic 1)(pae 1)(vnc 1)(vncdisplay 6)))(device (vbd (dev 'hda:disk:disk')(uname 'phy:/dev/sda8')(mode 'w')))(device (vbd (dev 'hdc:cdrom')(mode 'r')))(device (vif (mac '00:16:3e:0a:7b:39')(type ioemu)))) \ No newline at end of file diff --git a/tests/xml2sexprdata/xml2sexpr-no-source-cdrom.xml b/tests/xml2sexprdata/xml2sexpr-no-source-cdrom.xml new file mode 100644 index 000000000..5b9c7f61f --- /dev/null +++ b/tests/xml2sexprdata/xml2sexpr-no-source-cdrom.xml @@ -0,0 +1,36 @@ + + test + cc2315e7d26a307a438c6d188ec4c09c + + hvm + /usr/lib/xen/boot/hvmloader + + + 391168 + 358400 + 1 + destroy + destroy + destroy + + + + + + + /usr/lib/xen/bin/qemu-dm + + + + + + + + + + + + + + + diff --git a/tests/xml2sexprtest.c b/tests/xml2sexprtest.c index b5657ec6b..069d65f06 100644 --- a/tests/xml2sexprtest.c +++ b/tests/xml2sexprtest.c @@ -1,6 +1,9 @@ #include #include +#include +#include + #include "xml.h" #include "testutils.h" #include "internal.h" @@ -31,11 +34,14 @@ static int testCompareFiles(const char *xml, const char *sexpr, const char *name printf("Expect %d '%s'\n", (int)strlen(sexprData), sexprData); printf("Actual %d '%s'\n", (int)strlen(gotsexpr), gotsexpr); } - if (strcmp(sexprData, gotsexpr)) - goto fail; + if (strcmp(sexprData, gotsexpr)) { + goto fail; + } - if (strcmp(name, gotname)) - goto fail; + if (strcmp(name, gotname)) { + printf("Got wrong name: expected %s, got %s\n", name, gotname); + goto fail; + } ret = 0; @@ -167,6 +173,13 @@ static int testCompareNetBridged(void *data ATTRIBUTE_UNUSED) { 2); } +static int testCompareNoSourceCDRom(void *data ATTRIBUTE_UNUSED) { + return testCompareFiles("xml2sexprdata/xml2sexpr-no-source-cdrom.xml", + "xml2sexprdata/xml2sexpr-no-source-cdrom.sexpr", + "test", + 2); +} + int main(int argc, char **argv) @@ -248,5 +261,9 @@ main(int argc, char **argv) 1, testCompareNetBridged, NULL) != 0) ret = -1; + if (virtTestRun("XML-2-SEXPR No Source CDRom", + 1, testCompareNoSourceCDRom, NULL) != 0) + ret = -1; + exit(ret==0 ? EXIT_SUCCESS : EXIT_FAILURE); } -- cgit v1.2.3-65-gdbad