[libvirt] [PATCH 00/10] tests: More XML 2 XML tests and cleanups

In attempting to refactor some storage pool XML parsing, I wanted some unit tests to ensure I wasn't causing regressions. So, the following series adds XML 2 XML tests for storage pools (and virtual networks and storage vols). Also included are several cleanups in tests/, and bug fixes needed to make the new tests actually pass. Cole Robinson (10): tests: Fix text output for interface XML 2 XML tests: Document VIR_TEST_DEBUG environment variable. tests: Break out duplicate schema verification functionality. storage: Fix generating iscsi 'auth' xml schema: Update storage pool schema. tests: Add XML 2 XML tests for storage pools. network: Fix reading 'forwardDelay' attribute. schema: Update network schema. tests: Add network XML to XML tests. tests: Add storage volume XML 2 XML tests. HACKING | 10 ++ docs/schemas/network.rng | 41 ++++++- docs/schemas/storagepool.rng | 51 ++++++++- src/conf/network_conf.c | 10 ++- src/conf/storage_conf.c | 2 +- tests/.gitignore | 3 + tests/Makefile.am | 33 +++++- tests/capabilityschematest | 34 +----- tests/domainschematest | 33 +----- tests/interfaceschematest | 31 +----- tests/interfacexml2xmltest.c | 4 +- tests/networkschemadata/netboot-network.xml | 12 -- tests/networkschematest | 33 +----- tests/networkxml2xmlin/forward-delay-network.xml | 13 ++ tests/networkxml2xmlin/isolated-network.xml | 10 ++ tests/networkxml2xmlin/nat-network.xml | 13 ++ tests/networkxml2xmlin/netboot-network.xml | 14 +++ tests/networkxml2xmlin/routed-network.xml | 11 ++ tests/networkxml2xmlout/forward-delay-network.xml | 13 ++ tests/networkxml2xmlout/isolated-network.xml | 10 ++ tests/networkxml2xmlout/nat-network.xml | 13 ++ tests/networkxml2xmlout/netboot-network.xml | 14 +++ tests/networkxml2xmlout/routed-network.xml | 11 ++ tests/networkxml2xmltest.c | 97 +++++++++++++++ tests/nodedevschematest | 31 +----- tests/schematestutils.sh | 39 ++++++ tests/statstest.c | 2 +- tests/storagepoolschemadata/pool-dir.xml | 17 --- tests/storagepoolschemadata/pool-disk.xml | 22 ---- tests/storagepoolschemadata/pool-fs.xml | 19 --- tests/storagepoolschemadata/pool-iscsi.xml | 10 -- tests/storagepoolschemadata/pool-logical.xml | 19 --- tests/storagepoolschemadata/pool-netfs.xml | 20 --- tests/storagepoolschematest | 33 +----- tests/storagepoolxml2xmlin/pool-dir.xml | 18 +++ tests/storagepoolxml2xmlin/pool-disk.xml | 22 ++++ tests/storagepoolxml2xmlin/pool-fs.xml | 19 +++ tests/storagepoolxml2xmlin/pool-iscsi-auth.xml | 17 +++ tests/storagepoolxml2xmlin/pool-iscsi.xml | 16 +++ tests/storagepoolxml2xmlin/pool-logical-create.xml | 20 +++ tests/storagepoolxml2xmlin/pool-logical.xml | 19 +++ tests/storagepoolxml2xmlin/pool-mpath.xml | 12 ++ tests/storagepoolxml2xmlin/pool-netfs.xml | 20 +++ tests/storagepoolxml2xmlin/pool-scsi.xml | 15 +++ tests/storagepoolxml2xmlout/pool-dir.xml | 18 +++ tests/storagepoolxml2xmlout/pool-disk.xml | 19 +++ tests/storagepoolxml2xmlout/pool-fs.xml | 19 +++ tests/storagepoolxml2xmlout/pool-iscsi-auth.xml | 20 +++ tests/storagepoolxml2xmlout/pool-iscsi.xml | 19 +++ .../storagepoolxml2xmlout/pool-logical-create.xml | 22 ++++ tests/storagepoolxml2xmlout/pool-logical.xml | 19 +++ tests/storagepoolxml2xmlout/pool-mpath.xml | 17 +++ tests/storagepoolxml2xmlout/pool-netfs.xml | 20 +++ tests/storagepoolxml2xmlout/pool-scsi.xml | 18 +++ tests/storagepoolxml2xmltest.c | 102 ++++++++++++++++ tests/storagevolschemadata/vol-logical.xml | 20 --- tests/storagevolschemadata/vol-partition.xml | 21 ---- tests/storagevolschemadata/vol-qcow2.xml | 31 ----- tests/storagevolschematest | 33 +----- tests/storagevolxml2xmlin/vol-file-backing.xml | 24 ++++ tests/storagevolxml2xmlin/vol-file.xml | 15 +++ tests/storagevolxml2xmlin/vol-logical-backing.xml | 29 +++++ tests/storagevolxml2xmlin/vol-logical.xml | 20 +++ tests/storagevolxml2xmlin/vol-partition.xml | 21 ++++ tests/storagevolxml2xmlin/vol-qcow2.xml | 31 +++++ tests/storagevolxml2xmlout/vol-file-backing.xml | 27 +++++ tests/storagevolxml2xmlout/vol-file.xml | 18 +++ tests/storagevolxml2xmlout/vol-logical-backing.xml | 26 ++++ tests/storagevolxml2xmlout/vol-logical.xml | 17 +++ tests/storagevolxml2xmlout/vol-partition.xml | 18 +++ tests/storagevolxml2xmlout/vol-qcow2.xml | 31 +++++ tests/storagevolxml2xmltest.c | 123 ++++++++++++++++++++ 72 files changed, 1291 insertions(+), 413 deletions(-) delete mode 100644 tests/networkschemadata/netboot-network.xml create mode 100644 tests/networkxml2xmlin/forward-delay-network.xml create mode 100644 tests/networkxml2xmlin/isolated-network.xml create mode 100644 tests/networkxml2xmlin/nat-network.xml create mode 100644 tests/networkxml2xmlin/netboot-network.xml create mode 100644 tests/networkxml2xmlin/routed-network.xml create mode 100644 tests/networkxml2xmlout/forward-delay-network.xml create mode 100644 tests/networkxml2xmlout/isolated-network.xml create mode 100644 tests/networkxml2xmlout/nat-network.xml create mode 100644 tests/networkxml2xmlout/netboot-network.xml create mode 100644 tests/networkxml2xmlout/routed-network.xml create mode 100644 tests/networkxml2xmltest.c create mode 100644 tests/schematestutils.sh delete mode 100644 tests/storagepoolschemadata/pool-dir.xml delete mode 100644 tests/storagepoolschemadata/pool-disk.xml delete mode 100644 tests/storagepoolschemadata/pool-fs.xml delete mode 100644 tests/storagepoolschemadata/pool-iscsi.xml delete mode 100644 tests/storagepoolschemadata/pool-logical.xml delete mode 100644 tests/storagepoolschemadata/pool-netfs.xml create mode 100644 tests/storagepoolxml2xmlin/pool-dir.xml create mode 100644 tests/storagepoolxml2xmlin/pool-disk.xml create mode 100644 tests/storagepoolxml2xmlin/pool-fs.xml create mode 100644 tests/storagepoolxml2xmlin/pool-iscsi-auth.xml create mode 100644 tests/storagepoolxml2xmlin/pool-iscsi.xml create mode 100644 tests/storagepoolxml2xmlin/pool-logical-create.xml create mode 100644 tests/storagepoolxml2xmlin/pool-logical.xml create mode 100644 tests/storagepoolxml2xmlin/pool-mpath.xml create mode 100644 tests/storagepoolxml2xmlin/pool-netfs.xml create mode 100644 tests/storagepoolxml2xmlin/pool-scsi.xml create mode 100644 tests/storagepoolxml2xmlout/pool-dir.xml create mode 100644 tests/storagepoolxml2xmlout/pool-disk.xml create mode 100644 tests/storagepoolxml2xmlout/pool-fs.xml create mode 100644 tests/storagepoolxml2xmlout/pool-iscsi-auth.xml create mode 100644 tests/storagepoolxml2xmlout/pool-iscsi.xml create mode 100644 tests/storagepoolxml2xmlout/pool-logical-create.xml create mode 100644 tests/storagepoolxml2xmlout/pool-logical.xml create mode 100644 tests/storagepoolxml2xmlout/pool-mpath.xml create mode 100644 tests/storagepoolxml2xmlout/pool-netfs.xml create mode 100644 tests/storagepoolxml2xmlout/pool-scsi.xml create mode 100644 tests/storagepoolxml2xmltest.c delete mode 100644 tests/storagevolschemadata/vol-logical.xml delete mode 100644 tests/storagevolschemadata/vol-partition.xml delete mode 100644 tests/storagevolschemadata/vol-qcow2.xml create mode 100644 tests/storagevolxml2xmlin/vol-file-backing.xml create mode 100644 tests/storagevolxml2xmlin/vol-file.xml create mode 100644 tests/storagevolxml2xmlin/vol-logical-backing.xml create mode 100644 tests/storagevolxml2xmlin/vol-logical.xml create mode 100644 tests/storagevolxml2xmlin/vol-partition.xml create mode 100644 tests/storagevolxml2xmlin/vol-qcow2.xml create mode 100644 tests/storagevolxml2xmlout/vol-file-backing.xml create mode 100644 tests/storagevolxml2xmlout/vol-file.xml create mode 100644 tests/storagevolxml2xmlout/vol-logical-backing.xml create mode 100644 tests/storagevolxml2xmlout/vol-logical.xml create mode 100644 tests/storagevolxml2xmlout/vol-partition.xml create mode 100644 tests/storagevolxml2xmlout/vol-qcow2.xml create mode 100644 tests/storagevolxml2xmltest.c

Signed-off-by: Cole Robinson <crobinso@redhat.com> --- tests/interfacexml2xmltest.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/tests/interfacexml2xmltest.c b/tests/interfacexml2xmltest.c index 6e6c5e8..5ffebad 100644 --- a/tests/interfacexml2xmltest.c +++ b/tests/interfacexml2xmltest.c @@ -76,7 +76,7 @@ mymain(int argc, char **argv) abs_srcdir = getcwd(cwd, sizeof(cwd)); #define DO_TEST(name) \ - if (virtTestRun("Node device XML-2-XML " name, \ + if (virtTestRun("Interface XML-2-XML " name, \ 1, testCompareXMLToXMLHelper, (name)) < 0) \ ret = -1 -- 1.6.5.rc2

On Mon, Oct 12, 2009 at 10:45:06AM -0400, Cole Robinson wrote:
Signed-off-by: Cole Robinson <crobinso@redhat.com> --- tests/interfacexml2xmltest.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/tests/interfacexml2xmltest.c b/tests/interfacexml2xmltest.c index 6e6c5e8..5ffebad 100644 --- a/tests/interfacexml2xmltest.c +++ b/tests/interfacexml2xmltest.c @@ -76,7 +76,7 @@ mymain(int argc, char **argv) abs_srcdir = getcwd(cwd, sizeof(cwd));
#define DO_TEST(name) \ - if (virtTestRun("Node device XML-2-XML " name, \ + if (virtTestRun("Interface XML-2-XML " name, \ 1, testCompareXMLToXMLHelper, (name)) < 0) \ ret = -1
ACK Daniel -- |: Red Hat, Engineering, London -o- http://people.redhat.com/berrange/ :| |: http://libvirt.org -o- http://virt-manager.org -o- http://ovirt.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|

Daniel P. Berrange wrote:
On Mon, Oct 12, 2009 at 10:45:06AM -0400, Cole Robinson wrote:
Signed-off-by: Cole Robinson <crobinso@redhat.com> --- tests/interfacexml2xmltest.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/tests/interfacexml2xmltest.c b/tests/interfacexml2xmltest.c index 6e6c5e8..5ffebad 100644 --- a/tests/interfacexml2xmltest.c +++ b/tests/interfacexml2xmltest.c @@ -76,7 +76,7 @@ mymain(int argc, char **argv) abs_srcdir = getcwd(cwd, sizeof(cwd));
#define DO_TEST(name) \ - if (virtTestRun("Node device XML-2-XML " name, \ + if (virtTestRun("Interface XML-2-XML " name, \ 1, testCompareXMLToXMLHelper, (name)) < 0) \ ret = -1
ACK
Pushed now. Thanks, Cole

Signed-off-by: Cole Robinson <crobinso@redhat.com> --- HACKING | 10 ++++++++++ tests/interfacexml2xmltest.c | 2 -- tests/statstest.c | 2 +- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/HACKING b/HACKING index bcff8c6..fba7778 100644 --- a/HACKING +++ b/HACKING @@ -37,6 +37,16 @@ and run the tests: The latter test checks for memory leaks. +If you encounter any failing tests, the VIR_TEST_DEBUG environment variable +may help: + + VIR_TEST_DEBUG=1 make check (or) + VIR_TEST_DEBUG=2 make check + +Also, individual tests can be run from inside the 'tests/' directory, like: + + ./qemuxml2xmltest + (6) Update tests and/or documentation, particularly if you are adding a new feature or changing the output of a program. diff --git a/tests/interfacexml2xmltest.c b/tests/interfacexml2xmltest.c index 5ffebad..ed3093c 100644 --- a/tests/interfacexml2xmltest.c +++ b/tests/interfacexml2xmltest.c @@ -43,8 +43,6 @@ static int testCompareXMLToXMLFiles(const char *xml) { ret = 0; fail: - if (ret != 0) - fprintf(stderr, "expected: -------\n%s", actual); free(actual); virInterfaceDefFree(dev); return ret; diff --git a/tests/statstest.c b/tests/statstest.c index 82c0daa..819d395 100644 --- a/tests/statstest.c +++ b/tests/statstest.c @@ -25,7 +25,7 @@ static int testDevice(const char *path, int expect) if (actual == expect) { return 0; } else { - if (getenv("DEBUG_TESTS")) + if (getenv("VIR_TEST_DEBUG")) fprintf(stderr, "Expect %-6d Actual %-6d\n", expect, actual); return -1; } -- 1.6.5.rc2

On Mon, Oct 12, 2009 at 10:45:07AM -0400, Cole Robinson wrote:
Signed-off-by: Cole Robinson <crobinso@redhat.com> --- HACKING | 10 ++++++++++ tests/interfacexml2xmltest.c | 2 -- tests/statstest.c | 2 +- 3 files changed, 11 insertions(+), 3 deletions(-)
diff --git a/HACKING b/HACKING index bcff8c6..fba7778 100644 --- a/HACKING +++ b/HACKING @@ -37,6 +37,16 @@ and run the tests:
The latter test checks for memory leaks.
+If you encounter any failing tests, the VIR_TEST_DEBUG environment variable +may help: + + VIR_TEST_DEBUG=1 make check (or) + VIR_TEST_DEBUG=2 make check + +Also, individual tests can be run from inside the 'tests/' directory, like: + + ./qemuxml2xmltest + (6) Update tests and/or documentation, particularly if you are adding a new feature or changing the output of a program.
diff --git a/tests/interfacexml2xmltest.c b/tests/interfacexml2xmltest.c index 5ffebad..ed3093c 100644 --- a/tests/interfacexml2xmltest.c +++ b/tests/interfacexml2xmltest.c @@ -43,8 +43,6 @@ static int testCompareXMLToXMLFiles(const char *xml) { ret = 0;
fail: - if (ret != 0) - fprintf(stderr, "expected: -------\n%s", actual); free(actual); virInterfaceDefFree(dev); return ret; diff --git a/tests/statstest.c b/tests/statstest.c index 82c0daa..819d395 100644 --- a/tests/statstest.c +++ b/tests/statstest.c @@ -25,7 +25,7 @@ static int testDevice(const char *path, int expect) if (actual == expect) { return 0; } else { - if (getenv("DEBUG_TESTS")) + if (getenv("VIR_TEST_DEBUG")) fprintf(stderr, "Expect %-6d Actual %-6d\n", expect, actual); return -1; }
ACK though I wonder if we should change the VIR_* env names to LIBVIRT_*, to match the env naming we semi-standardized on in the main library code Daniel -- |: Red Hat, Engineering, London -o- http://people.redhat.com/berrange/ :| |: http://libvirt.org -o- http://virt-manager.org -o- http://ovirt.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|

Daniel P. Berrange wrote:
On Mon, Oct 12, 2009 at 10:45:07AM -0400, Cole Robinson wrote:
Signed-off-by: Cole Robinson <crobinso@redhat.com> --- HACKING | 10 ++++++++++ tests/interfacexml2xmltest.c | 2 -- tests/statstest.c | 2 +- 3 files changed, 11 insertions(+), 3 deletions(-)
diff --git a/HACKING b/HACKING index bcff8c6..fba7778 100644 --- a/HACKING +++ b/HACKING @@ -37,6 +37,16 @@ and run the tests:
The latter test checks for memory leaks.
+If you encounter any failing tests, the VIR_TEST_DEBUG environment variable +may help: + + VIR_TEST_DEBUG=1 make check (or) + VIR_TEST_DEBUG=2 make check + +Also, individual tests can be run from inside the 'tests/' directory, like: + + ./qemuxml2xmltest + (6) Update tests and/or documentation, particularly if you are adding a new feature or changing the output of a program.
diff --git a/tests/interfacexml2xmltest.c b/tests/interfacexml2xmltest.c index 5ffebad..ed3093c 100644 --- a/tests/interfacexml2xmltest.c +++ b/tests/interfacexml2xmltest.c @@ -43,8 +43,6 @@ static int testCompareXMLToXMLFiles(const char *xml) { ret = 0;
fail: - if (ret != 0) - fprintf(stderr, "expected: -------\n%s", actual); free(actual); virInterfaceDefFree(dev); return ret; diff --git a/tests/statstest.c b/tests/statstest.c index 82c0daa..819d395 100644 --- a/tests/statstest.c +++ b/tests/statstest.c @@ -25,7 +25,7 @@ static int testDevice(const char *path, int expect) if (actual == expect) { return 0; } else { - if (getenv("DEBUG_TESTS")) + if (getenv("VIR_TEST_DEBUG")) fprintf(stderr, "Expect %-6d Actual %-6d\n", expect, actual); return -1; }
ACK
though I wonder if we should change the VIR_* env names to LIBVIRT_*, to match the env naming we semi-standardized on in the main library code
Daniel
I've sent an updated patch that centralizes the debug level lookup. If we want to change the env variable it should be a simple additive change. Thanks, Cole

All schema tests have identical functionality, so avoid the duplication. Signed-off-by: Cole Robinson <crobinso@redhat.com> --- tests/Makefile.am | 1 + tests/capabilityschematest | 34 ++++------------------------------ tests/domainschematest | 33 ++++----------------------------- tests/interfaceschematest | 31 +++---------------------------- tests/networkschematest | 30 +++--------------------------- tests/nodedevschematest | 31 +++---------------------------- tests/schematestutils.sh | 39 +++++++++++++++++++++++++++++++++++++++ tests/storagepoolschematest | 31 +++---------------------------- tests/storagevolschematest | 30 +++--------------------------- 9 files changed, 63 insertions(+), 197 deletions(-) create mode 100644 tests/schematestutils.sh diff --git a/tests/Makefile.am b/tests/Makefile.am index 7882e52..b67df5d 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -52,6 +52,7 @@ EXTRA_DIST = \ test-lib.sh \ qemuxml2argvdata \ nodeinfodata \ + schematestutils.sh \ capabilityschematest \ capabilityschemadata \ networkschematest \ diff --git a/tests/capabilityschematest b/tests/capabilityschematest index a166724..651e23e 100755 --- a/tests/capabilityschematest +++ b/tests/capabilityschematest @@ -1,34 +1,8 @@ #!/bin/sh -test -z "$srcdir" && srcdir=`pwd` -test -z "$abs_srcdir" && abs_srcdir=`pwd` +source ./schematestutils.sh -DOMAINDIRS="capabilityschemadata xencapsdata" +DIRS="capabilityschemadata xencapsdata" +SCHEMA="capability.rng" - -n=0 -f=0 -for dir in $DOMAINDIRS -do - XML=`find $abs_srcdir/$dir -name '*.xml'` || exit 1 - - for xml in $XML - do - n=`expr $n + 1` - printf "%4d) %.60s " $n $(basename $(dirname $xml))"/"$(basename $xml) - result=`xmllint --relaxng $srcdir/../docs/schemas/capability.rng --noout $xml 2>&1` - ret=$? - if test $ret = 0; then - echo "OK" - else - echo "FAILED" - echo $result - f=`expr $f + 1` - fi - done -done -echo "Validated $n files, $f failed" - -ret=0 -test $f != 0 && ret=255 -exit $ret +check_schema "$DIRS" "$SCHEMA" diff --git a/tests/domainschematest b/tests/domainschematest index 0a7d4a1..bd58a30 100755 --- a/tests/domainschematest +++ b/tests/domainschematest @@ -1,33 +1,8 @@ #!/bin/sh -test -z "$srcdir" && srcdir=`pwd` -test -z "$abs_srcdir" && abs_srcdir=`pwd` +source ./schematestutils.sh -DOMAINDIRS="domainschemadata qemuxml2argvdata sexpr2xmldata xmconfigdata xml2sexprdata" +DIRS="domainschemadata qemuxml2argvdata sexpr2xmldata xmconfigdata xml2sexprdata" +SCHEMA="domain.rng" -n=0 -f=0 -for dir in $DOMAINDIRS -do - XML=`find $abs_srcdir/$dir -name '*.xml'` || exit 1 - - for xml in $XML - do - n=`expr $n + 1` - printf "%4d) %.60s " $n $(basename $(dirname $xml))"/"$(basename $xml) - result=`xmllint --relaxng $srcdir/../docs/schemas/domain.rng --noout $xml 2>&1` - ret=$? - if test $ret = 0; then - echo "OK" - else - echo "FAILED" - echo $result - f=`expr $f + 1` - fi - done -done -echo "Validated $n files, $f failed" - -ret=0 -test $f != 0 && ret=255 -exit $ret +check_schema "$DIRS" "$SCHEMA" diff --git a/tests/interfaceschematest b/tests/interfaceschematest index 3e4105c..e7bd4e5 100755 --- a/tests/interfaceschematest +++ b/tests/interfaceschematest @@ -1,33 +1,8 @@ #!/bin/sh -test -z "$srcdir" && srcdir=`pwd` -test -z "$abs_srcdir" && abs_srcdir=`pwd` +source ./schematestutils.sh DIRS="interfaceschemadata" +SCHEMA="interface.rng" -n=0 -f=0 -for dir in $DIRS -do - XML=`find $abs_srcdir/$dir -name '*.xml'` || exit 1 - - for xml in $XML - do - n=`expr $n + 1` - printf "%4d) %.60s " $n $(basename $(dirname $xml))"/"$(basename $xml) - result=`xmllint --relaxng $srcdir/../docs/schemas/interface.rng --noout $xml 2>&1` - ret=$? - if test $ret = 0; then - echo "OK" - else - echo "FAILED" - echo $result - f=`expr $f + 1` - fi - done -done -echo "Validated $n files, $f failed" - -ret=0 -test $f != 0 && ret=255 -exit $ret +check_schema "$DIRS" "$SCHEMA" diff --git a/tests/networkschematest b/tests/networkschematest index 3fc0f27..8bb24cd 100755 --- a/tests/networkschematest +++ b/tests/networkschematest @@ -1,33 +1,9 @@ #!/bin/sh -test -z "$srcdir" && srcdir=`pwd` -test -z "$abs_srcdir" && abs_srcdir=`pwd` +source ./schematestutils.sh DIRS="../src/network networkschemadata" +SCHEMA="network.rng" -n=0 -f=0 -for dir in $DIRS -do - XML=`find $abs_srcdir/$dir -name '*.xml'` || exit 1 +check_schema "$DIRS" "$SCHEMA" - for xml in $XML - do - n=`expr $n + 1` - printf "%4d) %.60s " $n $(basename $(dirname $xml))"/"$(basename $xml) - result=`xmllint --relaxng $srcdir/../docs/schemas/network.rng --noout $xml 2>&1` - ret=$? - if test $ret = 0; then - echo "OK" - else - echo "FAILED" - echo $result - f=`expr $f + 1` - fi - done -done -echo "Validated $n files, $f failed" - -ret=0 -test $f != 0 && ret=255 -exit $ret diff --git a/tests/nodedevschematest b/tests/nodedevschematest index 23e9e57..e676660 100755 --- a/tests/nodedevschematest +++ b/tests/nodedevschematest @@ -1,33 +1,8 @@ #!/bin/sh -test -z "$srcdir" && srcdir=`pwd` -test -z "$abs_srcdir" && abs_srcdir=`pwd` +source ./schematestutils.sh DIRS="nodedevschemadata" +SCHEMA="nodedev.rng" -n=0 -f=0 -for dir in $DIRS -do - XML=`find $abs_srcdir/$dir -name '*.xml'` || exit 1 - - for xml in $XML - do - n=`expr $n + 1` - printf "%4d) %.60s " $n $(basename $(dirname $xml))"/"$(basename $xml) - result=`xmllint --relaxng $srcdir/../docs/schemas/nodedev.rng --noout $xml 2>&1` - ret=$? - if test $ret = 0; then - echo "OK" - else - echo "FAILED" - echo $result - f=`expr $f + 1` - fi - done -done -echo "Validated $n files, $f failed" - -ret=0 -test $f != 0 && ret=255 -exit $ret +check_schema "$DIRS" "$SCHEMA" diff --git a/tests/schematestutils.sh b/tests/schematestutils.sh new file mode 100644 index 0000000..4b5f266 --- /dev/null +++ b/tests/schematestutils.sh @@ -0,0 +1,39 @@ +#!/bin/sh + +test -z "$srcdir" && srcdir=`pwd` +test -z "$abs_srcdir" && abs_srcdir=`pwd` + +function check_schema { + +DIRS=$1 +SCHEMA="$srcdir/../docs/schemas/$2" + +n=0 +f=0 +for dir in $DIRS +do + XML=`find $abs_srcdir/$dir -name '*.xml'` || exit 1 + + for xml in $XML + do + n=`expr $n + 1` + printf "%4d) %.60s " $n $(basename $(dirname $xml))"/"$(basename $xml) + cmd="xmllint --relaxng $SCHEMA --noout $xml" + result=`$cmd 2>&1` + ret=$? + if test $ret = 0; then + echo "OK" + else + echo "FAILED" + echo -e "$cmd\n$result" + f=`expr $f + 1` + fi + done +done +echo "Validated $n files, $f failed" + +ret=0 +test $f != 0 && ret=255 +exit $ret + +} diff --git a/tests/storagepoolschematest b/tests/storagepoolschematest index f6a973d..d04b83b 100755 --- a/tests/storagepoolschematest +++ b/tests/storagepoolschematest @@ -1,33 +1,8 @@ #!/bin/sh -test -z "$srcdir" && srcdir=`pwd` -test -z "$abs_srcdir" && abs_srcdir=`pwd` +source ./schematestutils.sh DIRS="storagepoolschemadata" +SCHEMA="storagepool.rng" -n=0 -f=0 -for dir in $DIRS -do - XML=`find $abs_srcdir/$dir -name '*.xml'` || exit 1 - - for xml in $XML - do - n=`expr $n + 1` - printf "%4d) %.60s " $n $(basename $(dirname $xml))"/"$(basename $xml) - result=`xmllint --relaxng $srcdir/../docs/schemas/storagepool.rng --noout $xml 2>&1` - ret=$? - if test $ret = 0; then - echo "OK" - else - echo "FAILED" - echo $result - f=`expr $f + 1` - fi - done -done -echo "Validated $n files, $f failed" - -ret=0 -test $f != 0 && ret=255 -exit $ret +check_schema "$DIRS" "$SCHEMA" diff --git a/tests/storagevolschematest b/tests/storagevolschematest index 7865102..8b5559a 100755 --- a/tests/storagevolschematest +++ b/tests/storagevolschematest @@ -1,33 +1,9 @@ #!/bin/sh -test -z "$srcdir" && srcdir=`pwd` -test -z "$abs_srcdir" && abs_srcdir=`pwd` +source ./schematestutils.sh DIRS="storagevolschemadata" +SCHEMA="storagevol.rng" -n=0 -f=0 -for dir in $DIRS -do - XML=`find $abs_srcdir/$dir -name '*.xml'` || exit 1 +check_schema "$DIRS" "$SCHEMA" - for xml in $XML - do - n=`expr $n + 1` - printf "%4d) %.60s " $n $(basename $(dirname $xml))"/"$(basename $xml) - result=`xmllint --relaxng $srcdir/../docs/schemas/storagevol.rng --noout $xml 2>&1` - ret=$? - if test $ret = 0; then - echo "OK" - else - echo "FAILED" - echo $result - f=`expr $f + 1` - fi - done -done -echo "Validated $n files, $f failed" - -ret=0 -test $f != 0 && ret=255 -exit $ret -- 1.6.5.rc2

We were missing a closing tag, so the XML wasn't proper. Signed-off-by: Cole Robinson <crobinso@redhat.com> --- src/conf/storage_conf.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/src/conf/storage_conf.c b/src/conf/storage_conf.c index 788de15..1633aac 100644 --- a/src/conf/storage_conf.c +++ b/src/conf/storage_conf.c @@ -799,7 +799,7 @@ virStoragePoolSourceFormat(virConnectPtr conn, if (src->authType == VIR_STORAGE_POOL_AUTH_CHAP) - virBufferVSprintf(buf," <auth type='chap' login='%s' passwd='%s'>\n", + virBufferVSprintf(buf," <auth type='chap' login='%s' passwd='%s'/>\n", src->auth.chap.login, src->auth.chap.passwd); virBufferAddLit(buf," </source>\n"); -- 1.6.5.rc2

On Mon, Oct 12, 2009 at 10:46:48AM -0400, Cole Robinson wrote:
We were missing a closing tag, so the XML wasn't proper.
Signed-off-by: Cole Robinson <crobinso@redhat.com> --- src/conf/storage_conf.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
ACK, shows how many people have used this code :-) Daniel -- |: Red Hat, Engineering, London -o- http://people.redhat.com/berrange/ :| |: http://libvirt.org -o- http://virt-manager.org -o- http://ovirt.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|

On Mon, Oct 12, 2009 at 10:46:48AM -0400, Cole Robinson wrote:
We were missing a closing tag, so the XML wasn't proper.
Signed-off-by: Cole Robinson <crobinso@redhat.com> --- src/conf/storage_conf.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/src/conf/storage_conf.c b/src/conf/storage_conf.c index 788de15..1633aac 100644 --- a/src/conf/storage_conf.c +++ b/src/conf/storage_conf.c @@ -799,7 +799,7 @@ virStoragePoolSourceFormat(virConnectPtr conn,
if (src->authType == VIR_STORAGE_POOL_AUTH_CHAP) - virBufferVSprintf(buf," <auth type='chap' login='%s' passwd='%s'>\n", + virBufferVSprintf(buf," <auth type='chap' login='%s' passwd='%s'/>\n", src->auth.chap.login, src->auth.chap.passwd); virBufferAddLit(buf," </source>\n");
ACK ! Could you please push this now ? Daniel -- Daniel Veillard | libxml Gnome XML XSLT toolkit http://xmlsoft.org/ daniel@veillard.com | Rpmfind RPM search engine http://rpmfind.net/ http://veillard.com/ | virtualization library http://libvirt.org/

On 10/13/2009 10:50 AM, Daniel Veillard wrote:
On Mon, Oct 12, 2009 at 10:46:48AM -0400, Cole Robinson wrote:
We were missing a closing tag, so the XML wasn't proper.
Signed-off-by: Cole Robinson <crobinso@redhat.com> --- src/conf/storage_conf.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/src/conf/storage_conf.c b/src/conf/storage_conf.c index 788de15..1633aac 100644 --- a/src/conf/storage_conf.c +++ b/src/conf/storage_conf.c @@ -799,7 +799,7 @@ virStoragePoolSourceFormat(virConnectPtr conn,
if (src->authType == VIR_STORAGE_POOL_AUTH_CHAP) - virBufferVSprintf(buf," <auth type='chap' login='%s' passwd='%s'>\n", + virBufferVSprintf(buf," <auth type='chap' login='%s' passwd='%s'/>\n", src->auth.chap.login, src->auth.chap.passwd); virBufferAddLit(buf," </source>\n");
ACK ! Could you please push this now ?
Daniel
Pushed now. Thanks, Cole

- mpath pools weren't listed - scsi pools were missing an adapter section - iscsi pools were missing an auth section - Logical pools do not require a source name to be specified Signed-off-by: Cole Robinson <crobinso@redhat.com> --- docs/schemas/storagepool.rng | 51 +++++++++++++++++++++++++++++++++++++---- 1 files changed, 46 insertions(+), 5 deletions(-) diff --git a/docs/schemas/storagepool.rng b/docs/schemas/storagepool.rng index d225f97..7ab0187 100644 --- a/docs/schemas/storagepool.rng +++ b/docs/schemas/storagepool.rng @@ -16,6 +16,7 @@ <ref name='pooldisk'/> <ref name='pooliscsi'/> <ref name='poolscsi'/> + <ref name='poolmpath'/> </choice> </element> </define> @@ -90,6 +91,18 @@ <ref name='target'/> </define> + <define name='poolmpath'> + <attribute name='type'> + <value>mpath</value> + </attribute> + <ref name='commonmetadata'/> + <ref name='sizing'/> + <optional> + <ref name='sourcempath'/> + </optional> + <ref name='target'/> + </define> + <define name='commonmetadata'> <element name='name'> <ref name='name'/> @@ -212,6 +225,22 @@ </element> </define> + <define name='sourceinfoauth'> + <element name='auth'> + <attribute name='type'> + <choice> + <value>chap</value> + </choice> + </attribute> + <attribute name='login'> + <text/> + </attribute> + <attribute name='passwd'> + <text/> + </attribute> + </element> + </define> + <define name='sourcefmtfs'> <optional> <element name='format'> @@ -309,10 +338,14 @@ <define name='sourcelogical'> <element name='source'> - <ref name='sourceinfoname'/> - <optional> - <ref name='sourceinfodev'/> - </optional> + <oneOrMore> + <optional> + <ref name='sourceinfoname'/> + </optional> + <optional> + <ref name='sourceinfodev'/> + </optional> + </oneOrMore> <ref name='sourcefmtlogical'/> </element> </define> @@ -328,15 +361,23 @@ <element name='source'> <ref name='sourceinfohost'/> <ref name='sourceinfodev'/> + <optional> + <ref name='sourceinfoauth'/> + </optional> </element> </define> <define name='sourcescsi'> <element name='source'> - <ref name='sourceinfoname'/> + <ref name='sourceinfoadapter'/> </element> </define> + <define name='sourcempath'> + <element name='source'> + <empty/> + </element> + </define> <define name='name'> <data type='string'> -- 1.6.5.rc2

On Mon, Oct 12, 2009 at 10:46:49AM -0400, Cole Robinson wrote:
- mpath pools weren't listed - scsi pools were missing an adapter section - iscsi pools were missing an auth section - Logical pools do not require a source name to be specified
Signed-off-by: Cole Robinson <crobinso@redhat.com> --- docs/schemas/storagepool.rng | 51 +++++++++++++++++++++++++++++++++++++---- 1 files changed, 46 insertions(+), 5 deletions(-)
ACK Daniel -- |: Red Hat, Engineering, London -o- http://people.redhat.com/berrange/ :| |: http://libvirt.org -o- http://virt-manager.org -o- http://ovirt.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|

On Mon, Oct 12, 2009 at 10:46:49AM -0400, Cole Robinson wrote:
- mpath pools weren't listed - scsi pools were missing an adapter section - iscsi pools were missing an auth section - Logical pools do not require a source name to be specified
Signed-off-by: Cole Robinson <crobinso@redhat.com> --- docs/schemas/storagepool.rng | 51 +++++++++++++++++++++++++++++++++++++---- 1 files changed, 46 insertions(+), 5 deletions(-)
diff --git a/docs/schemas/storagepool.rng b/docs/schemas/storagepool.rng index d225f97..7ab0187 100644 --- a/docs/schemas/storagepool.rng +++ b/docs/schemas/storagepool.rng @@ -16,6 +16,7 @@ <ref name='pooldisk'/> <ref name='pooliscsi'/> <ref name='poolscsi'/> + <ref name='poolmpath'/> </choice> </element> </define> @@ -90,6 +91,18 @@ <ref name='target'/> </define>
+ <define name='poolmpath'> + <attribute name='type'> + <value>mpath</value> + </attribute> + <ref name='commonmetadata'/> + <ref name='sizing'/> + <optional> + <ref name='sourcempath'/> + </optional> + <ref name='target'/> + </define> + <define name='commonmetadata'> <element name='name'> <ref name='name'/> @@ -212,6 +225,22 @@ </element> </define>
+ <define name='sourceinfoauth'> + <element name='auth'> + <attribute name='type'> + <choice> + <value>chap</value> + </choice> + </attribute> + <attribute name='login'> + <text/> + </attribute> + <attribute name='passwd'> + <text/> + </attribute> + </element> + </define> + <define name='sourcefmtfs'> <optional> <element name='format'> @@ -309,10 +338,14 @@
<define name='sourcelogical'> <element name='source'> - <ref name='sourceinfoname'/> - <optional> - <ref name='sourceinfodev'/> - </optional> + <oneOrMore> + <optional> + <ref name='sourceinfoname'/> + </optional> + <optional> + <ref name='sourceinfodev'/> + </optional> + </oneOrMore> <ref name='sourcefmtlogical'/> </element> </define> @@ -328,15 +361,23 @@ <element name='source'> <ref name='sourceinfohost'/> <ref name='sourceinfodev'/> + <optional> + <ref name='sourceinfoauth'/> + </optional> </element> </define>
<define name='sourcescsi'> <element name='source'> - <ref name='sourceinfoname'/> + <ref name='sourceinfoadapter'/> </element> </define>
+ <define name='sourcempath'> + <element name='source'> + <empty/> + </element> + </define>
<define name='name'> <data type='string'>
ACK, please push :-) Daniel -- Daniel Veillard | libxml Gnome XML XSLT toolkit http://xmlsoft.org/ daniel@veillard.com | Rpmfind RPM search engine http://rpmfind.net/ http://veillard.com/ | virtualization library http://libvirt.org/

On 10/13/2009 10:51 AM, Daniel Veillard wrote:
On Mon, Oct 12, 2009 at 10:46:49AM -0400, Cole Robinson wrote:
- mpath pools weren't listed - scsi pools were missing an adapter section - iscsi pools were missing an auth section - Logical pools do not require a source name to be specified
Signed-off-by: Cole Robinson <crobinso@redhat.com> --- docs/schemas/storagepool.rng | 51 +++++++++++++++++++++++++++++++++++++---- 1 files changed, 46 insertions(+), 5 deletions(-)
diff --git a/docs/schemas/storagepool.rng b/docs/schemas/storagepool.rng index d225f97..7ab0187 100644 --- a/docs/schemas/storagepool.rng +++ b/docs/schemas/storagepool.rng @@ -16,6 +16,7 @@ <ref name='pooldisk'/> <ref name='pooliscsi'/> <ref name='poolscsi'/> + <ref name='poolmpath'/> </choice> </element> </define> @@ -90,6 +91,18 @@ <ref name='target'/> </define>
+ <define name='poolmpath'> + <attribute name='type'> + <value>mpath</value> + </attribute> + <ref name='commonmetadata'/> + <ref name='sizing'/> + <optional> + <ref name='sourcempath'/> + </optional> + <ref name='target'/> + </define> + <define name='commonmetadata'> <element name='name'> <ref name='name'/> @@ -212,6 +225,22 @@ </element> </define>
+ <define name='sourceinfoauth'> + <element name='auth'> + <attribute name='type'> + <choice> + <value>chap</value> + </choice> + </attribute> + <attribute name='login'> + <text/> + </attribute> + <attribute name='passwd'> + <text/> + </attribute> + </element> + </define> + <define name='sourcefmtfs'> <optional> <element name='format'> @@ -309,10 +338,14 @@
<define name='sourcelogical'> <element name='source'> - <ref name='sourceinfoname'/> - <optional> - <ref name='sourceinfodev'/> - </optional> + <oneOrMore> + <optional> + <ref name='sourceinfoname'/> + </optional> + <optional> + <ref name='sourceinfodev'/> + </optional> + </oneOrMore> <ref name='sourcefmtlogical'/> </element> </define> @@ -328,15 +361,23 @@ <element name='source'> <ref name='sourceinfohost'/> <ref name='sourceinfodev'/> + <optional> + <ref name='sourceinfoauth'/> + </optional> </element> </define>
<define name='sourcescsi'> <element name='source'> - <ref name='sourceinfoname'/> + <ref name='sourceinfoadapter'/> </element> </define>
+ <define name='sourcempath'> + <element name='source'> + <empty/> + </element> + </define>
<define name='name'> <data type='string'>
ACK, please push :-)
Daniel
Pushed now. Thanks, Cole

Move existing schema data to an input directory. Add extra files for more thorough XML testing. Signed-off-by: Cole Robinson <crobinso@redhat.com> --- tests/.gitignore | 1 + tests/Makefile.am | 12 ++- tests/storagepoolschemadata/pool-dir.xml | 17 ---- tests/storagepoolschemadata/pool-disk.xml | 22 ---- tests/storagepoolschemadata/pool-fs.xml | 19 ---- tests/storagepoolschemadata/pool-iscsi.xml | 10 -- tests/storagepoolschemadata/pool-logical.xml | 19 ---- tests/storagepoolschemadata/pool-netfs.xml | 20 ---- tests/storagepoolschematest | 2 +- tests/storagepoolxml2xmlin/pool-dir.xml | 18 ++++ tests/storagepoolxml2xmlin/pool-disk.xml | 22 ++++ tests/storagepoolxml2xmlin/pool-fs.xml | 19 ++++ tests/storagepoolxml2xmlin/pool-iscsi-auth.xml | 17 ++++ tests/storagepoolxml2xmlin/pool-iscsi.xml | 16 +++ tests/storagepoolxml2xmlin/pool-logical-create.xml | 20 ++++ tests/storagepoolxml2xmlin/pool-logical.xml | 19 ++++ tests/storagepoolxml2xmlin/pool-mpath.xml | 12 +++ tests/storagepoolxml2xmlin/pool-netfs.xml | 20 ++++ tests/storagepoolxml2xmlin/pool-scsi.xml | 15 +++ tests/storagepoolxml2xmlout/pool-dir.xml | 18 ++++ tests/storagepoolxml2xmlout/pool-disk.xml | 19 ++++ tests/storagepoolxml2xmlout/pool-fs.xml | 19 ++++ tests/storagepoolxml2xmlout/pool-iscsi-auth.xml | 20 ++++ tests/storagepoolxml2xmlout/pool-iscsi.xml | 19 ++++ .../storagepoolxml2xmlout/pool-logical-create.xml | 22 ++++ tests/storagepoolxml2xmlout/pool-logical.xml | 19 ++++ tests/storagepoolxml2xmlout/pool-mpath.xml | 17 ++++ tests/storagepoolxml2xmlout/pool-netfs.xml | 20 ++++ tests/storagepoolxml2xmlout/pool-scsi.xml | 18 ++++ tests/storagepoolxml2xmltest.c | 102 ++++++++++++++++++++ 30 files changed, 484 insertions(+), 109 deletions(-) delete mode 100644 tests/storagepoolschemadata/pool-dir.xml delete mode 100644 tests/storagepoolschemadata/pool-disk.xml delete mode 100644 tests/storagepoolschemadata/pool-fs.xml delete mode 100644 tests/storagepoolschemadata/pool-iscsi.xml delete mode 100644 tests/storagepoolschemadata/pool-logical.xml delete mode 100644 tests/storagepoolschemadata/pool-netfs.xml create mode 100644 tests/storagepoolxml2xmlin/pool-dir.xml create mode 100644 tests/storagepoolxml2xmlin/pool-disk.xml create mode 100644 tests/storagepoolxml2xmlin/pool-fs.xml create mode 100644 tests/storagepoolxml2xmlin/pool-iscsi-auth.xml create mode 100644 tests/storagepoolxml2xmlin/pool-iscsi.xml create mode 100644 tests/storagepoolxml2xmlin/pool-logical-create.xml create mode 100644 tests/storagepoolxml2xmlin/pool-logical.xml create mode 100644 tests/storagepoolxml2xmlin/pool-mpath.xml create mode 100644 tests/storagepoolxml2xmlin/pool-netfs.xml create mode 100644 tests/storagepoolxml2xmlin/pool-scsi.xml create mode 100644 tests/storagepoolxml2xmlout/pool-dir.xml create mode 100644 tests/storagepoolxml2xmlout/pool-disk.xml create mode 100644 tests/storagepoolxml2xmlout/pool-fs.xml create mode 100644 tests/storagepoolxml2xmlout/pool-iscsi-auth.xml create mode 100644 tests/storagepoolxml2xmlout/pool-iscsi.xml create mode 100644 tests/storagepoolxml2xmlout/pool-logical-create.xml create mode 100644 tests/storagepoolxml2xmlout/pool-logical.xml create mode 100644 tests/storagepoolxml2xmlout/pool-mpath.xml create mode 100644 tests/storagepoolxml2xmlout/pool-netfs.xml create mode 100644 tests/storagepoolxml2xmlout/pool-scsi.xml create mode 100644 tests/storagepoolxml2xmltest.c diff --git a/tests/.gitignore b/tests/.gitignore index 6d67c2a..41f8454 100644 --- a/tests/.gitignore +++ b/tests/.gitignore @@ -15,6 +15,7 @@ qemuargv2xmltest qemuhelptest nodedevxml2xmltest interfacexml2xmltest +storagepoolxml2xmltest nodeinfotest statstest qparamtest diff --git a/tests/Makefile.am b/tests/Makefile.am index b67df5d..a62c01b 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -61,7 +61,8 @@ EXTRA_DIST = \ domainschemadata \ interfaceschemadata \ storagepoolschematest \ - storagepoolschemadata \ + storagepoolxml2xmlout \ + storagepoolxml2xmlin \ storagevolschematest \ storagevolschemadata \ nodedevschematest \ @@ -95,6 +96,8 @@ if WITH_CIL noinst_PROGRAMS += object-locking endif +noinst_PROGRAMS += storagepoolxml2xmltest + noinst_PROGRAMS += nodedevxml2xmltest noinst_PROGRAMS += interfacexml2xmltest @@ -168,6 +171,8 @@ noinst_PROGRAMS += eventtest TESTS += eventtest endif +TESTS += storagepoolxml2xmltest + TESTS += nodedevxml2xmltest TESTS += interfacexml2xmltest @@ -264,6 +269,11 @@ else EXTRA_DIST += esxutilstest.c vmx2xmltest.c xml2vmxtest.c endif +storagepoolxml2xmltest_SOURCES = \ + storagepoolxml2xmltest.c \ + testutils.c testutils.h +storagepoolxml2xmltest_LDADD = $(LDADDS) + nodedevxml2xmltest_SOURCES = \ nodedevxml2xmltest.c \ testutils.c testutils.h diff --git a/tests/storagepoolschemadata/pool-dir.xml b/tests/storagepoolschemadata/pool-dir.xml deleted file mode 100644 index 2b8735c..0000000 --- a/tests/storagepoolschemadata/pool-dir.xml +++ /dev/null @@ -1,17 +0,0 @@ -<pool type='dir'> - <name>virtimages</name> - <uuid>70a7eb15-6c34-ee9c-bf57-69e8e5ff3fb2</uuid> - <capacity>0</capacity> - <allocation>0</allocation> - <available>0</available> - <source> - </source> - <target> - <path>/var/lib/libvirt/images</path> - <permissions> - <mode>0700</mode> - <owner>0</owner> - <group>0</group> - </permissions> - </target> -</pool> diff --git a/tests/storagepoolschemadata/pool-disk.xml b/tests/storagepoolschemadata/pool-disk.xml deleted file mode 100644 index 4c27c54..0000000 --- a/tests/storagepoolschemadata/pool-disk.xml +++ /dev/null @@ -1,22 +0,0 @@ -<pool type='disk'> - <name>sda</name> - <uuid>e3509a62-1b4c-e20b-94bd-9168963f9b97</uuid> - <capacity>100027630080</capacity> - <allocation>100027597824</allocation> - <available>0</available> - <source> - <device path='/dev/sda'> - <freeExtent start='370137600' end='567544320'/> - <freeExtent start='987033600' end='1044610560'/> - </device> - <format type='dos'/> - </source> - <target> - <path>/dev</path> - <permissions> - <mode>0700</mode> - <owner>0</owner> - <group>0</group> - </permissions> - </target> -</pool> diff --git a/tests/storagepoolschemadata/pool-fs.xml b/tests/storagepoolschemadata/pool-fs.xml deleted file mode 100644 index ee2bb55..0000000 --- a/tests/storagepoolschemadata/pool-fs.xml +++ /dev/null @@ -1,19 +0,0 @@ -<pool type='fs'> - <name>images</name> - <uuid>7641d5a8-af11-f730-a34e-0a7dfcede71f</uuid> - <capacity>0</capacity> - <allocation>0</allocation> - <available>0</available> - <source> - <device path='/dev/sda6'/> - <format type='ext3'/> - </source> - <target> - <path>/mnt</path> - <permissions> - <mode>0700</mode> - <owner>0</owner> - <group>0</group> - </permissions> - </target> -</pool> diff --git a/tests/storagepoolschemadata/pool-iscsi.xml b/tests/storagepoolschemadata/pool-iscsi.xml deleted file mode 100644 index 8d60f38..0000000 --- a/tests/storagepoolschemadata/pool-iscsi.xml +++ /dev/null @@ -1,10 +0,0 @@ -<pool type='iscsi'> - <name>virtimages</name> - <source> - <host name="iscsi.example.com"/> - <device path="demo-target"/> - </source> - <target> - <path>/dev/disk/by-path</path> - </target> -</pool> diff --git a/tests/storagepoolschemadata/pool-logical.xml b/tests/storagepoolschemadata/pool-logical.xml deleted file mode 100644 index c4bfa07..0000000 --- a/tests/storagepoolschemadata/pool-logical.xml +++ /dev/null @@ -1,19 +0,0 @@ -<pool type='logical'> - <name>HostVG</name> - <uuid>1c13165a-d0f4-3aee-b447-30fb38789091</uuid> - <capacity>99891544064</capacity> - <allocation>99220455424</allocation> - <available>671088640</available> - <source> - <name>HostVG</name> - <format type='lvm2'/> - </source> - <target> - <path>/dev/HostVG</path> - <permissions> - <mode>0700</mode> - <owner>0</owner> - <group>0</group> - </permissions> - </target> -</pool> diff --git a/tests/storagepoolschemadata/pool-netfs.xml b/tests/storagepoolschemadata/pool-netfs.xml deleted file mode 100644 index 4bd18c5..0000000 --- a/tests/storagepoolschemadata/pool-netfs.xml +++ /dev/null @@ -1,20 +0,0 @@ -<pool type='netfs'> - <name>nfsimages</name> - <uuid>7641d5a8-af11-f730-a34e-0a7dfcede71f</uuid> - <capacity>0</capacity> - <allocation>0</allocation> - <available>0</available> - <source> - <host name='localhost'/> - <dir path='/var/lib/libvirt/images'/> - <format type='nfs'/> - </source> - <target> - <path>/mnt</path> - <permissions> - <mode>0700</mode> - <owner>0</owner> - <group>0</group> - </permissions> - </target> -</pool> diff --git a/tests/storagepoolschematest b/tests/storagepoolschematest index d04b83b..be4767d 100755 --- a/tests/storagepoolschematest +++ b/tests/storagepoolschematest @@ -2,7 +2,7 @@ source ./schematestutils.sh -DIRS="storagepoolschemadata" +DIRS="storagepoolxml2xmlin storagepoolxml2xmlout" SCHEMA="storagepool.rng" check_schema "$DIRS" "$SCHEMA" diff --git a/tests/storagepoolxml2xmlin/pool-dir.xml b/tests/storagepoolxml2xmlin/pool-dir.xml new file mode 100644 index 0000000..361e383 --- /dev/null +++ b/tests/storagepoolxml2xmlin/pool-dir.xml @@ -0,0 +1,18 @@ +<pool type='dir'> + <name>virtimages</name> + <uuid>70a7eb15-6c34-ee9c-bf57-69e8e5ff3fb2</uuid> + <capacity>0</capacity> + <allocation>0</allocation> + <available>0</available> + <source> + </source> + <target> + <path>/var/lib/libvirt/images</path> + <permissions> + <mode>0700</mode> + <owner>0</owner> + <group>0</group> + <label>some_label_t</label> + </permissions> + </target> +</pool> diff --git a/tests/storagepoolxml2xmlin/pool-disk.xml b/tests/storagepoolxml2xmlin/pool-disk.xml new file mode 100644 index 0000000..4c27c54 --- /dev/null +++ b/tests/storagepoolxml2xmlin/pool-disk.xml @@ -0,0 +1,22 @@ +<pool type='disk'> + <name>sda</name> + <uuid>e3509a62-1b4c-e20b-94bd-9168963f9b97</uuid> + <capacity>100027630080</capacity> + <allocation>100027597824</allocation> + <available>0</available> + <source> + <device path='/dev/sda'> + <freeExtent start='370137600' end='567544320'/> + <freeExtent start='987033600' end='1044610560'/> + </device> + <format type='dos'/> + </source> + <target> + <path>/dev</path> + <permissions> + <mode>0700</mode> + <owner>0</owner> + <group>0</group> + </permissions> + </target> +</pool> diff --git a/tests/storagepoolxml2xmlin/pool-fs.xml b/tests/storagepoolxml2xmlin/pool-fs.xml new file mode 100644 index 0000000..ee2bb55 --- /dev/null +++ b/tests/storagepoolxml2xmlin/pool-fs.xml @@ -0,0 +1,19 @@ +<pool type='fs'> + <name>images</name> + <uuid>7641d5a8-af11-f730-a34e-0a7dfcede71f</uuid> + <capacity>0</capacity> + <allocation>0</allocation> + <available>0</available> + <source> + <device path='/dev/sda6'/> + <format type='ext3'/> + </source> + <target> + <path>/mnt</path> + <permissions> + <mode>0700</mode> + <owner>0</owner> + <group>0</group> + </permissions> + </target> +</pool> diff --git a/tests/storagepoolxml2xmlin/pool-iscsi-auth.xml b/tests/storagepoolxml2xmlin/pool-iscsi-auth.xml new file mode 100644 index 0000000..f7d4d52 --- /dev/null +++ b/tests/storagepoolxml2xmlin/pool-iscsi-auth.xml @@ -0,0 +1,17 @@ +<pool type='iscsi'> + <name>virtimages</name> + <uuid>e9392370-2917-565e-692b-d057f46512d6</uuid> + <source> + <host name="iscsi.example.com"/> + <device path="demo-target"/> + <auth type='chap' login='foobar' passwd='frobbar'/> + </source> + <target> + <path>/dev/disk/by-path</path> + <permissions> + <mode>0700</mode> + <owner>0</owner> + <group>0</group> + </permissions> + </target> +</pool> diff --git a/tests/storagepoolxml2xmlin/pool-iscsi.xml b/tests/storagepoolxml2xmlin/pool-iscsi.xml new file mode 100644 index 0000000..37a16f7 --- /dev/null +++ b/tests/storagepoolxml2xmlin/pool-iscsi.xml @@ -0,0 +1,16 @@ +<pool type='iscsi'> + <name>virtimages</name> + <uuid>e9392370-2917-565e-692b-d057f46512d6</uuid> + <source> + <host name="iscsi.example.com"/> + <device path="demo-target"/> + </source> + <target> + <path>/dev/disk/by-path</path> + <permissions> + <mode>0700</mode> + <owner>0</owner> + <group>0</group> + </permissions> + </target> +</pool> diff --git a/tests/storagepoolxml2xmlin/pool-logical-create.xml b/tests/storagepoolxml2xmlin/pool-logical-create.xml new file mode 100644 index 0000000..4c67089 --- /dev/null +++ b/tests/storagepoolxml2xmlin/pool-logical-create.xml @@ -0,0 +1,20 @@ +<pool type='logical'> + <name>HostVG</name> + <uuid>1c13165a-d0f4-3aee-b447-30fb38789091</uuid> + <capacity>99891544064</capacity> + <allocation>99220455424</allocation> + <available>671088640</available> + <source> + <device path="/dev/sdb1"/> + <device path="/dev/sdb2"/> + <device path="/dev/sdb3"/> + </source> + <target> + <path>/dev/HostVG</path> + <permissions> + <mode>0700</mode> + <owner>0</owner> + <group>0</group> + </permissions> + </target> +</pool> diff --git a/tests/storagepoolxml2xmlin/pool-logical.xml b/tests/storagepoolxml2xmlin/pool-logical.xml new file mode 100644 index 0000000..c4bfa07 --- /dev/null +++ b/tests/storagepoolxml2xmlin/pool-logical.xml @@ -0,0 +1,19 @@ +<pool type='logical'> + <name>HostVG</name> + <uuid>1c13165a-d0f4-3aee-b447-30fb38789091</uuid> + <capacity>99891544064</capacity> + <allocation>99220455424</allocation> + <available>671088640</available> + <source> + <name>HostVG</name> + <format type='lvm2'/> + </source> + <target> + <path>/dev/HostVG</path> + <permissions> + <mode>0700</mode> + <owner>0</owner> + <group>0</group> + </permissions> + </target> +</pool> diff --git a/tests/storagepoolxml2xmlin/pool-mpath.xml b/tests/storagepoolxml2xmlin/pool-mpath.xml new file mode 100644 index 0000000..a5fbbcb --- /dev/null +++ b/tests/storagepoolxml2xmlin/pool-mpath.xml @@ -0,0 +1,12 @@ +<pool type="mpath"> + <name>mpath</name> + <uuid>e9392370-2917-565e-692b-d057f46512d6</uuid> + <target> + <path>/dev/mapper</path> + <permissions> + <mode>0700</mode> + <owner>0</owner> + <group>0</group> + </permissions> + </target> +</pool> diff --git a/tests/storagepoolxml2xmlin/pool-netfs.xml b/tests/storagepoolxml2xmlin/pool-netfs.xml new file mode 100644 index 0000000..4bd18c5 --- /dev/null +++ b/tests/storagepoolxml2xmlin/pool-netfs.xml @@ -0,0 +1,20 @@ +<pool type='netfs'> + <name>nfsimages</name> + <uuid>7641d5a8-af11-f730-a34e-0a7dfcede71f</uuid> + <capacity>0</capacity> + <allocation>0</allocation> + <available>0</available> + <source> + <host name='localhost'/> + <dir path='/var/lib/libvirt/images'/> + <format type='nfs'/> + </source> + <target> + <path>/mnt</path> + <permissions> + <mode>0700</mode> + <owner>0</owner> + <group>0</group> + </permissions> + </target> +</pool> diff --git a/tests/storagepoolxml2xmlin/pool-scsi.xml b/tests/storagepoolxml2xmlin/pool-scsi.xml new file mode 100644 index 0000000..3650e43 --- /dev/null +++ b/tests/storagepoolxml2xmlin/pool-scsi.xml @@ -0,0 +1,15 @@ +<pool type="scsi"> + <name>hba0</name> + <uuid>e9392370-2917-565e-692b-d057f46512d6</uuid> + <source> + <adapter name="host0"/> + </source> + <target> + <path>/dev/disk/by-path</path> + <permissions> + <mode>0700</mode> + <owner>0</owner> + <group>0</group> + </permissions> + </target> +</pool> diff --git a/tests/storagepoolxml2xmlout/pool-dir.xml b/tests/storagepoolxml2xmlout/pool-dir.xml new file mode 100644 index 0000000..361e383 --- /dev/null +++ b/tests/storagepoolxml2xmlout/pool-dir.xml @@ -0,0 +1,18 @@ +<pool type='dir'> + <name>virtimages</name> + <uuid>70a7eb15-6c34-ee9c-bf57-69e8e5ff3fb2</uuid> + <capacity>0</capacity> + <allocation>0</allocation> + <available>0</available> + <source> + </source> + <target> + <path>/var/lib/libvirt/images</path> + <permissions> + <mode>0700</mode> + <owner>0</owner> + <group>0</group> + <label>some_label_t</label> + </permissions> + </target> +</pool> diff --git a/tests/storagepoolxml2xmlout/pool-disk.xml b/tests/storagepoolxml2xmlout/pool-disk.xml new file mode 100644 index 0000000..d6c595f --- /dev/null +++ b/tests/storagepoolxml2xmlout/pool-disk.xml @@ -0,0 +1,19 @@ +<pool type='disk'> + <name>sda</name> + <uuid>e3509a62-1b4c-e20b-94bd-9168963f9b97</uuid> + <capacity>0</capacity> + <allocation>0</allocation> + <available>0</available> + <source> + <device path='/dev/sda'/> + <format type='dos'/> + </source> + <target> + <path>/dev</path> + <permissions> + <mode>0700</mode> + <owner>0</owner> + <group>0</group> + </permissions> + </target> +</pool> diff --git a/tests/storagepoolxml2xmlout/pool-fs.xml b/tests/storagepoolxml2xmlout/pool-fs.xml new file mode 100644 index 0000000..ee2bb55 --- /dev/null +++ b/tests/storagepoolxml2xmlout/pool-fs.xml @@ -0,0 +1,19 @@ +<pool type='fs'> + <name>images</name> + <uuid>7641d5a8-af11-f730-a34e-0a7dfcede71f</uuid> + <capacity>0</capacity> + <allocation>0</allocation> + <available>0</available> + <source> + <device path='/dev/sda6'/> + <format type='ext3'/> + </source> + <target> + <path>/mnt</path> + <permissions> + <mode>0700</mode> + <owner>0</owner> + <group>0</group> + </permissions> + </target> +</pool> diff --git a/tests/storagepoolxml2xmlout/pool-iscsi-auth.xml b/tests/storagepoolxml2xmlout/pool-iscsi-auth.xml new file mode 100644 index 0000000..557295d --- /dev/null +++ b/tests/storagepoolxml2xmlout/pool-iscsi-auth.xml @@ -0,0 +1,20 @@ +<pool type='iscsi'> + <name>virtimages</name> + <uuid>e9392370-2917-565e-692b-d057f46512d6</uuid> + <capacity>0</capacity> + <allocation>0</allocation> + <available>0</available> + <source> + <host name='iscsi.example.com'/> + <device path='demo-target'/> + <auth type='chap' login='foobar' passwd='frobbar'/> + </source> + <target> + <path>/dev/disk/by-path</path> + <permissions> + <mode>0700</mode> + <owner>0</owner> + <group>0</group> + </permissions> + </target> +</pool> diff --git a/tests/storagepoolxml2xmlout/pool-iscsi.xml b/tests/storagepoolxml2xmlout/pool-iscsi.xml new file mode 100644 index 0000000..774bdd3 --- /dev/null +++ b/tests/storagepoolxml2xmlout/pool-iscsi.xml @@ -0,0 +1,19 @@ +<pool type='iscsi'> + <name>virtimages</name> + <uuid>e9392370-2917-565e-692b-d057f46512d6</uuid> + <capacity>0</capacity> + <allocation>0</allocation> + <available>0</available> + <source> + <host name='iscsi.example.com'/> + <device path='demo-target'/> + </source> + <target> + <path>/dev/disk/by-path</path> + <permissions> + <mode>0700</mode> + <owner>0</owner> + <group>0</group> + </permissions> + </target> +</pool> diff --git a/tests/storagepoolxml2xmlout/pool-logical-create.xml b/tests/storagepoolxml2xmlout/pool-logical-create.xml new file mode 100644 index 0000000..c30359b --- /dev/null +++ b/tests/storagepoolxml2xmlout/pool-logical-create.xml @@ -0,0 +1,22 @@ +<pool type='logical'> + <name>HostVG</name> + <uuid>1c13165a-d0f4-3aee-b447-30fb38789091</uuid> + <capacity>0</capacity> + <allocation>0</allocation> + <available>0</available> + <source> + <device path='/dev/sdb1'/> + <device path='/dev/sdb2'/> + <device path='/dev/sdb3'/> + <name>HostVG</name> + <format type='lvm2'/> + </source> + <target> + <path>/dev/HostVG</path> + <permissions> + <mode>0700</mode> + <owner>0</owner> + <group>0</group> + </permissions> + </target> +</pool> diff --git a/tests/storagepoolxml2xmlout/pool-logical.xml b/tests/storagepoolxml2xmlout/pool-logical.xml new file mode 100644 index 0000000..6ce41e1 --- /dev/null +++ b/tests/storagepoolxml2xmlout/pool-logical.xml @@ -0,0 +1,19 @@ +<pool type='logical'> + <name>HostVG</name> + <uuid>1c13165a-d0f4-3aee-b447-30fb38789091</uuid> + <capacity>0</capacity> + <allocation>0</allocation> + <available>0</available> + <source> + <name>HostVG</name> + <format type='lvm2'/> + </source> + <target> + <path>/dev/HostVG</path> + <permissions> + <mode>0700</mode> + <owner>0</owner> + <group>0</group> + </permissions> + </target> +</pool> diff --git a/tests/storagepoolxml2xmlout/pool-mpath.xml b/tests/storagepoolxml2xmlout/pool-mpath.xml new file mode 100644 index 0000000..8f5d2c7 --- /dev/null +++ b/tests/storagepoolxml2xmlout/pool-mpath.xml @@ -0,0 +1,17 @@ +<pool type='mpath'> + <name>mpath</name> + <uuid>e9392370-2917-565e-692b-d057f46512d6</uuid> + <capacity>0</capacity> + <allocation>0</allocation> + <available>0</available> + <source> + </source> + <target> + <path>/dev/mapper</path> + <permissions> + <mode>0700</mode> + <owner>0</owner> + <group>0</group> + </permissions> + </target> +</pool> diff --git a/tests/storagepoolxml2xmlout/pool-netfs.xml b/tests/storagepoolxml2xmlout/pool-netfs.xml new file mode 100644 index 0000000..4bd18c5 --- /dev/null +++ b/tests/storagepoolxml2xmlout/pool-netfs.xml @@ -0,0 +1,20 @@ +<pool type='netfs'> + <name>nfsimages</name> + <uuid>7641d5a8-af11-f730-a34e-0a7dfcede71f</uuid> + <capacity>0</capacity> + <allocation>0</allocation> + <available>0</available> + <source> + <host name='localhost'/> + <dir path='/var/lib/libvirt/images'/> + <format type='nfs'/> + </source> + <target> + <path>/mnt</path> + <permissions> + <mode>0700</mode> + <owner>0</owner> + <group>0</group> + </permissions> + </target> +</pool> diff --git a/tests/storagepoolxml2xmlout/pool-scsi.xml b/tests/storagepoolxml2xmlout/pool-scsi.xml new file mode 100644 index 0000000..b24a9f2 --- /dev/null +++ b/tests/storagepoolxml2xmlout/pool-scsi.xml @@ -0,0 +1,18 @@ +<pool type='scsi'> + <name>hba0</name> + <uuid>e9392370-2917-565e-692b-d057f46512d6</uuid> + <capacity>0</capacity> + <allocation>0</allocation> + <available>0</available> + <source> + <adapter name='host0'/> + </source> + <target> + <path>/dev/disk/by-path</path> + <permissions> + <mode>0700</mode> + <owner>0</owner> + <group>0</group> + </permissions> + </target> +</pool> diff --git a/tests/storagepoolxml2xmltest.c b/tests/storagepoolxml2xmltest.c new file mode 100644 index 0000000..a7370c7 --- /dev/null +++ b/tests/storagepoolxml2xmltest.c @@ -0,0 +1,102 @@ +#include <config.h> + +#include <stdio.h> +#include <stdlib.h> +#include <unistd.h> +#include <string.h> + +#include <sys/types.h> +#include <fcntl.h> + +#include "internal.h" +#include "testutils.h" +#include "storage_conf.h" +#include "testutilsqemu.h" + +static char *progname; +static char *abs_srcdir; + +#define MAX_FILE 4096 + + +static int testCompareXMLToXMLFiles(const char *inxml, const char *outxml) { + char inXmlData[MAX_FILE]; + char *inXmlPtr = &(inXmlData[0]); + char outXmlData[MAX_FILE]; + char *outXmlPtr = &(outXmlData[0]); + char *actual = NULL; + int ret = -1; + virStoragePoolDefPtr dev = NULL; + + if (virtTestLoadFile(inxml, &inXmlPtr, MAX_FILE) < 0) + goto fail; + if (virtTestLoadFile(outxml, &outXmlPtr, MAX_FILE) < 0) + goto fail; + + if (!(dev = virStoragePoolDefParseString(NULL, inXmlData))) + goto fail; + + if (!(actual = virStoragePoolDefFormat(NULL, dev))) + goto fail; + + if (STRNEQ(outXmlData, actual)) { + virtTestDifference(stderr, outXmlData, actual); + goto fail; + } + + ret = 0; + + fail: + free(actual); + virStoragePoolDefFree(dev); + return ret; +} + +static int testCompareXMLToXMLHelper(const void *data) { + char inxml[PATH_MAX]; + char outxml[PATH_MAX]; + snprintf(inxml, PATH_MAX, "%s/storagepoolxml2xmlin/%s.xml", + abs_srcdir, (const char*)data); + snprintf(outxml, PATH_MAX, "%s/storagepoolxml2xmlout/%s.xml", + abs_srcdir, (const char*)data); + return testCompareXMLToXMLFiles(inxml, outxml); +} + + +static int +mymain(int argc, char **argv) +{ + int ret = 0; + char cwd[PATH_MAX]; + + progname = argv[0]; + + if (argc > 1) { + fprintf(stderr, "Usage: %s\n", progname); + return (EXIT_FAILURE); + } + + abs_srcdir = getenv("abs_srcdir"); + if (!abs_srcdir) + abs_srcdir = getcwd(cwd, sizeof(cwd)); + +#define DO_TEST(name) \ + if (virtTestRun("Storage Pool XML-2-XML " name, \ + 1, testCompareXMLToXMLHelper, (name)) < 0) \ + ret = -1 + + DO_TEST("pool-dir"); + DO_TEST("pool-fs"); + DO_TEST("pool-logical"); + DO_TEST("pool-logical-create"); + DO_TEST("pool-disk"); + DO_TEST("pool-iscsi"); + DO_TEST("pool-iscsi-auth"); + DO_TEST("pool-netfs"); + DO_TEST("pool-scsi"); + DO_TEST("pool-mpath"); + + return (ret==0 ? EXIT_SUCCESS : EXIT_FAILURE); +} + +VIRT_TEST_MAIN(mymain) -- 1.6.5.rc2

On Mon, Oct 12, 2009 at 10:46:50AM -0400, Cole Robinson wrote:
Move existing schema data to an input directory. Add extra files for more thorough XML testing.
Signed-off-by: Cole Robinson <crobinso@redhat.com>
ACK Daniel -- |: Red Hat, Engineering, London -o- http://people.redhat.com/berrange/ :| |: http://libvirt.org -o- http://virt-manager.org -o- http://ovirt.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|

Daniel P. Berrange wrote:
On Mon, Oct 12, 2009 at 10:46:50AM -0400, Cole Robinson wrote:
Move existing schema data to an input directory. Add extra files for more thorough XML testing.
Signed-off-by: Cole Robinson <crobinso@redhat.com>
ACK
Daniel
I've pushed this and the other XML 2 XML tests (network and storage vols). Thanks, Cole

When reading network XML, we were looking for a 'delay' attribute, but this value was being dumped as 'forwardDelay'. Support reading both names on input, but continue to only dump 'forwardDelay' Signed-off-by: Cole Robinson <crobinso@redhat.com> --- src/conf/network_conf.c | 10 ++++++++-- 1 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/conf/network_conf.c b/src/conf/network_conf.c index 14eb543..220f313 100644 --- a/src/conf/network_conf.c +++ b/src/conf/network_conf.c @@ -398,8 +398,14 @@ virNetworkDefParseXML(virConnectPtr conn, def->stp = (tmp && STREQ(tmp, "off")) ? 0 : 1; VIR_FREE(tmp); - if (virXPathULong(conn, "string(./bridge[1]/@delay)", ctxt, &def->delay) < 0) - def->delay = 0; + if (virXPathULong(conn, "string(./bridge[1]/@forwardDelay)", + ctxt, &def->delay) < 0) { + /* We erroneously checked 'delay' before, so check it for back + * compat */ + if (virXPathULong(conn, "string(./bridge[1]/@delay)", + ctxt, &def->delay) < 0) + def->delay = 0; + } def->ipAddress = virXPathString(conn, "string(./ip[1]/@address)", ctxt); def->netmask = virXPathString(conn, "string(./ip[1]/@netmask)", ctxt); -- 1.6.5.rc2

On Mon, Oct 12, 2009 at 10:46:51AM -0400, Cole Robinson wrote:
When reading network XML, we were looking for a 'delay' attribute, but this value was being dumped as 'forwardDelay'. Support reading both names on input, but continue to only dump 'forwardDelay'
Rather a no-win situation, but the schema still says 'delay', so I'd be more inclined to just fix the XML printing code to s/forwardDelay/delay/ and leave the parsing as is. Daniel -- |: Red Hat, Engineering, London -o- http://people.redhat.com/berrange/ :| |: http://libvirt.org -o- http://virt-manager.org -o- http://ovirt.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|

On Tue, Oct 13, 2009 at 02:27:09PM +0100, Daniel P. Berrange wrote:
On Mon, Oct 12, 2009 at 10:46:51AM -0400, Cole Robinson wrote:
When reading network XML, we were looking for a 'delay' attribute, but this value was being dumped as 'forwardDelay'. Support reading both names on input, but continue to only dump 'forwardDelay'
Rather a no-win situation, but the schema still says 'delay', so I'd be more inclined to just fix the XML printing code to s/forwardDelay/delay/ and leave the parsing as is.
Agreed, it tends to prove people were either not using the option or not dumping the XML to reimport it. I would stick to the original syntax. This should turn into a trivial fix, and I'm fine with pushing it now. Daniel -- Daniel Veillard | libxml Gnome XML XSLT toolkit http://xmlsoft.org/ daniel@veillard.com | Rpmfind RPM search engine http://rpmfind.net/ http://veillard.com/ | virtualization library http://libvirt.org/

On 10/13/2009 10:54 AM, Daniel Veillard wrote:
On Tue, Oct 13, 2009 at 02:27:09PM +0100, Daniel P. Berrange wrote:
On Mon, Oct 12, 2009 at 10:46:51AM -0400, Cole Robinson wrote:
When reading network XML, we were looking for a 'delay' attribute, but this value was being dumped as 'forwardDelay'. Support reading both names on input, but continue to only dump 'forwardDelay'
Rather a no-win situation, but the schema still says 'delay', so I'd be more inclined to just fix the XML printing code to s/forwardDelay/delay/ and leave the parsing as is.
Agreed, it tends to prove people were either not using the option or not dumping the XML to reimport it. I would stick to the original syntax. This should turn into a trivial fix, and I'm fine with pushing it now.
Daniel
Okay, I'll tweak this patch and push. Thanks, Cole

On 10/13/2009 10:54 AM, Daniel Veillard wrote:
On Tue, Oct 13, 2009 at 02:27:09PM +0100, Daniel P. Berrange wrote:
On Mon, Oct 12, 2009 at 10:46:51AM -0400, Cole Robinson wrote:
When reading network XML, we were looking for a 'delay' attribute, but this value was being dumped as 'forwardDelay'. Support reading both names on input, but continue to only dump 'forwardDelay'
Rather a no-win situation, but the schema still says 'delay', so I'd be more inclined to just fix the XML printing code to s/forwardDelay/delay/ and leave the parsing as is.
Agreed, it tends to prove people were either not using the option or not dumping the XML to reimport it. I would stick to the original syntax. This should turn into a trivial fix, and I'm fine with pushing it now.
Daniel
Okay, I've pushed this change: diff --git a/src/conf/network_conf.c b/src/conf/network_conf.c index 14eb543..40f5fdd 100644 --- a/src/conf/network_conf.c +++ b/src/conf/network_conf.c @@ -632,7 +632,7 @@ char *virNetworkDefFormat(virConnectPtr conn, virBufferAddLit(&buf, " <bridge"); if (def->bridge) virBufferEscapeString(&buf, " name='%s'", def->bridge); - virBufferVSprintf(&buf, " stp='%s' forwardDelay='%ld' />\n", + virBufferVSprintf(&buf, " stp='%s' delay='%ld' />\n", def->stp ? "on" : "off", def->delay); Thanks, Cole

Fix issue with delay/forwardDelay attribute, and add 'none' as a valid forward type. Signed-off-by: Cole Robinson <crobinso@redhat.com> --- docs/schemas/network.rng | 41 ++++++++++++++++++++++++++++++++++++----- 1 files changed, 36 insertions(+), 5 deletions(-) diff --git a/docs/schemas/network.rng b/docs/schemas/network.rng index 042e013..cf334b6 100644 --- a/docs/schemas/network.rng +++ b/docs/schemas/network.rng @@ -2,19 +2,29 @@ <element name="network" xmlns="http://relaxng.org/ns/structure/1.0" datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes"> <interleave> + <!-- The name of the network, used to refer to it through the API and in virsh --> - <element name="name"><text/></element> + <element name="name"> + <text/> + </element> + + <!-- <uuid> element --> <optional> <element name="uuid"><text/></element> </optional> + + <!-- <bridge> element --> <optional> <!-- The name of the network to be set up; this will back the network on the host --> <element name="bridge"> <optional> - <attribute name="name"><text/></attribute> + <attribute name="name"> + <text/> + </attribute> </optional> + <optional> <attribute name="stp"> <choice> @@ -23,31 +33,52 @@ </choice> </attribute> </optional> + <optional> - <attribute name="delay"><data type="integer"/></attribute> + <choice> + <attribute name="forwardDelay"> + <data type="integer"/> + </attribute> + <attribute name="delay"> + <data type="integer"/> + </attribute> + </choice> </optional> + </element> </optional> + + <!-- <forward> element --> <optional> <!-- The device through which the bridge is connected to the rest of the network --> <element name="forward"> - <optional><attribute name="dev"><text/></attribute></optional> + <optional> + <attribute name="dev"> + <text/> + </attribute> + </optional> + <optional> <attribute name="mode"> <choice> <value>nat</value> - <value>routed</value> + <value>route</value> + <value>none</value> </choice> </attribute> </optional> </element> </optional> + + <!-- <domain> element --> <optional> <element name="domain"> <attribute name="name"><text/></attribute> </element> </optional> + + <!-- <ip> element --> <optional> <!-- The IP element sets up NAT'ing and an optional DHCP server local to the host. --> -- 1.6.5.rc2

On Mon, Oct 12, 2009 at 10:46:52AM -0400, Cole Robinson wrote:
Fix issue with delay/forwardDelay attribute, and add 'none' as a valid forward type.
'none' isn't a actually valid forward type. For disabling forwarding, the <forward> element is omitted entirely. Daniel -- |: Red Hat, Engineering, London -o- http://people.redhat.com/berrange/ :| |: http://libvirt.org -o- http://virt-manager.org -o- http://ovirt.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|

On 10/13/2009 09:29 AM, Daniel P. Berrange wrote:
On Mon, Oct 12, 2009 at 10:46:52AM -0400, Cole Robinson wrote:
Fix issue with delay/forwardDelay attribute, and add 'none' as a valid forward type.
'none' isn't a actually valid forward type. For disabling forwarding, the <forward> element is omitted entirely.
Daniel
'none' is handled by the code though, and has the same effect as omitting the <forward> block. Should that mean it belongs in the schema? - Cole

Cole Robinson wrote:
On 10/13/2009 09:29 AM, Daniel P. Berrange wrote:
On Mon, Oct 12, 2009 at 10:46:52AM -0400, Cole Robinson wrote:
Fix issue with delay/forwardDelay attribute, and add 'none' as a valid forward type. 'none' isn't a actually valid forward type. For disabling forwarding, the <forward> element is omitted entirely.
Daniel
'none' is handled by the code though, and has the same effect as omitting the <forward> block. Should that mean it belongs in the schema?
- Cole
I dropped the 'none' change, and pushed the cleanups and s/routed/route change. Thanks, Cole

Signed-off-by: Cole Robinson <crobinso@redhat.com> --- tests/.gitignore | 1 + tests/Makefile.am | 12 +++- tests/networkschemadata/netboot-network.xml | 12 --- tests/networkschematest | 3 +- tests/networkxml2xmlin/forward-delay-network.xml | 13 +++ tests/networkxml2xmlin/isolated-network.xml | 10 ++ tests/networkxml2xmlin/nat-network.xml | 13 +++ tests/networkxml2xmlin/netboot-network.xml | 14 +++ tests/networkxml2xmlin/routed-network.xml | 11 +++ tests/networkxml2xmlout/forward-delay-network.xml | 13 +++ tests/networkxml2xmlout/isolated-network.xml | 10 ++ tests/networkxml2xmlout/nat-network.xml | 13 +++ tests/networkxml2xmlout/netboot-network.xml | 14 +++ tests/networkxml2xmlout/routed-network.xml | 11 +++ tests/networkxml2xmltest.c | 97 +++++++++++++++++++++ 15 files changed, 232 insertions(+), 15 deletions(-) delete mode 100644 tests/networkschemadata/netboot-network.xml create mode 100644 tests/networkxml2xmlin/forward-delay-network.xml create mode 100644 tests/networkxml2xmlin/isolated-network.xml create mode 100644 tests/networkxml2xmlin/nat-network.xml create mode 100644 tests/networkxml2xmlin/netboot-network.xml create mode 100644 tests/networkxml2xmlin/routed-network.xml create mode 100644 tests/networkxml2xmlout/forward-delay-network.xml create mode 100644 tests/networkxml2xmlout/isolated-network.xml create mode 100644 tests/networkxml2xmlout/nat-network.xml create mode 100644 tests/networkxml2xmlout/netboot-network.xml create mode 100644 tests/networkxml2xmlout/routed-network.xml create mode 100644 tests/networkxml2xmltest.c diff --git a/tests/.gitignore b/tests/.gitignore index 41f8454..c202141 100644 --- a/tests/.gitignore +++ b/tests/.gitignore @@ -13,6 +13,7 @@ qemuxml2xmltest qemuxml2argvtest qemuargv2xmltest qemuhelptest +networkxml2xmltest nodedevxml2xmltest interfacexml2xmltest storagepoolxml2xmltest diff --git a/tests/Makefile.am b/tests/Makefile.am index a62c01b..b6acfa4 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -56,7 +56,8 @@ EXTRA_DIST = \ capabilityschematest \ capabilityschemadata \ networkschematest \ - networkschemadata \ + networkpoolxml2xmlout \ + networkpoolxml2xmlin \ domainschematest \ domainschemadata \ interfaceschemadata \ @@ -96,6 +97,8 @@ if WITH_CIL noinst_PROGRAMS += object-locking endif +noinst_PROGRAMS += networkxml2xmltest + noinst_PROGRAMS += storagepoolxml2xmltest noinst_PROGRAMS += nodedevxml2xmltest @@ -171,6 +174,8 @@ noinst_PROGRAMS += eventtest TESTS += eventtest endif +TESTS += networkxml2xmltest + TESTS += storagepoolxml2xmltest TESTS += nodedevxml2xmltest @@ -269,6 +274,11 @@ else EXTRA_DIST += esxutilstest.c vmx2xmltest.c xml2vmxtest.c endif +networkxml2xmltest_SOURCES = \ + networkxml2xmltest.c \ + testutils.c testutils.h +networkxml2xmltest_LDADD = $(LDADDS) + storagepoolxml2xmltest_SOURCES = \ storagepoolxml2xmltest.c \ testutils.c testutils.h diff --git a/tests/networkschemadata/netboot-network.xml b/tests/networkschemadata/netboot-network.xml deleted file mode 100644 index 7274ee6..0000000 --- a/tests/networkschemadata/netboot-network.xml +++ /dev/null @@ -1,12 +0,0 @@ -<network> - <name>netboot</name> - <bridge name="virbr1" /> - <forward/> - <ip address="192.168.122.1" netmask="255.255.255.0"> - <tftp root="/var/lib/tftproot" /> - <dhcp> - <range start="192.168.122.2" end="192.168.122.254" /> - <bootp file="pxeboot.img" /> - </dhcp> - </ip> -</network> diff --git a/tests/networkschematest b/tests/networkschematest index 8bb24cd..6305576 100755 --- a/tests/networkschematest +++ b/tests/networkschematest @@ -2,8 +2,7 @@ source ./schematestutils.sh -DIRS="../src/network networkschemadata" +DIRS="../src/network networkxml2xmlin networkxml2xmlout" SCHEMA="network.rng" check_schema "$DIRS" "$SCHEMA" - diff --git a/tests/networkxml2xmlin/forward-delay-network.xml b/tests/networkxml2xmlin/forward-delay-network.xml new file mode 100644 index 0000000..d97e185 --- /dev/null +++ b/tests/networkxml2xmlin/forward-delay-network.xml @@ -0,0 +1,13 @@ +<network> + <name>default</name> + <uuid>81ff0d90-c91e-6742-64da-4a736edb9a9b</uuid> + <bridge name="virbr0" forwardDelay='2'/> + <forward mode="nat" dev="eth1"/> + <ip address="192.168.122.1" netmask="255.255.255.0"> + <dhcp> + <range start="192.168.122.2" end="192.168.122.254" /> + <host mac="00:16:3e:77:e2:ed" name="a.example.com" ip="192.168.122.10" /> + <host mac="00:16:3e:3e:a9:1a" name="b.example.com" ip="192.168.122.11" /> + </dhcp> + </ip> +</network> diff --git a/tests/networkxml2xmlin/isolated-network.xml b/tests/networkxml2xmlin/isolated-network.xml new file mode 100644 index 0000000..507e3bb --- /dev/null +++ b/tests/networkxml2xmlin/isolated-network.xml @@ -0,0 +1,10 @@ +<network> + <name>private</name> + <uuid>81ff0d90-c91e-6742-64da-4a736edb9a9b</uuid> + <bridge name="virbr2" /> + <ip address="192.168.152.1" netmask="255.255.255.0"> + <dhcp> + <range start="192.168.152.2" end="192.168.152.254" /> + </dhcp> + </ip> +</network> diff --git a/tests/networkxml2xmlin/nat-network.xml b/tests/networkxml2xmlin/nat-network.xml new file mode 100644 index 0000000..93ab186 --- /dev/null +++ b/tests/networkxml2xmlin/nat-network.xml @@ -0,0 +1,13 @@ +<network> + <name>default</name> + <uuid>81ff0d90-c91e-6742-64da-4a736edb9a9b</uuid> + <bridge name="virbr0" /> + <forward mode="nat" dev="eth1"/> + <ip address="192.168.122.1" netmask="255.255.255.0"> + <dhcp> + <range start="192.168.122.2" end="192.168.122.254" /> + <host mac="00:16:3e:77:e2:ed" name="a.example.com" ip="192.168.122.10" /> + <host mac="00:16:3e:3e:a9:1a" name="b.example.com" ip="192.168.122.11" /> + </dhcp> + </ip> +</network> diff --git a/tests/networkxml2xmlin/netboot-network.xml b/tests/networkxml2xmlin/netboot-network.xml new file mode 100644 index 0000000..ed75663 --- /dev/null +++ b/tests/networkxml2xmlin/netboot-network.xml @@ -0,0 +1,14 @@ +<network> + <name>netboot</name> + <uuid>81ff0d90-c91e-6742-64da-4a736edb9a9b</uuid> + <bridge name="virbr1" stp='off' delay='1'/> + <domain name="example.com"/> + <forward/> + <ip address="192.168.122.1" netmask="255.255.255.0"> + <tftp root="/var/lib/tftproot" /> + <dhcp> + <range start="192.168.122.2" end="192.168.122.254" /> + <bootp file="pxeboot.img" /> + </dhcp> + </ip> +</network> diff --git a/tests/networkxml2xmlin/routed-network.xml b/tests/networkxml2xmlin/routed-network.xml new file mode 100644 index 0000000..824ad75 --- /dev/null +++ b/tests/networkxml2xmlin/routed-network.xml @@ -0,0 +1,11 @@ +<network> + <name>local</name> + <uuid>81ff0d90-c91e-6742-64da-4a736edb9a9b</uuid> + <bridge name="virbr1" /> + <forward mode="route" dev="eth1"/> + <ip address="192.168.122.1" netmask="255.255.255.0"> + <dhcp> + <range start="192.168.122.2" end="192.168.122.254" /> + </dhcp> + </ip> +</network> diff --git a/tests/networkxml2xmlout/forward-delay-network.xml b/tests/networkxml2xmlout/forward-delay-network.xml new file mode 100644 index 0000000..54c62c4 --- /dev/null +++ b/tests/networkxml2xmlout/forward-delay-network.xml @@ -0,0 +1,13 @@ +<network> + <name>default</name> + <uuid>81ff0d90-c91e-6742-64da-4a736edb9a9b</uuid> + <forward dev='eth1' mode='nat'/> + <bridge name='virbr0' stp='on' forwardDelay='2' /> + <ip address='192.168.122.1' netmask='255.255.255.0'> + <dhcp> + <range start='192.168.122.2' end='192.168.122.254' /> + <host mac='00:16:3e:77:e2:ed' name='a.example.com' ip='192.168.122.10' /> + <host mac='00:16:3e:3e:a9:1a' name='b.example.com' ip='192.168.122.11' /> + </dhcp> + </ip> +</network> diff --git a/tests/networkxml2xmlout/isolated-network.xml b/tests/networkxml2xmlout/isolated-network.xml new file mode 100644 index 0000000..b21ead0 --- /dev/null +++ b/tests/networkxml2xmlout/isolated-network.xml @@ -0,0 +1,10 @@ +<network> + <name>private</name> + <uuid>81ff0d90-c91e-6742-64da-4a736edb9a9b</uuid> + <bridge name='virbr2' stp='on' forwardDelay='0' /> + <ip address='192.168.152.1' netmask='255.255.255.0'> + <dhcp> + <range start='192.168.152.2' end='192.168.152.254' /> + </dhcp> + </ip> +</network> diff --git a/tests/networkxml2xmlout/nat-network.xml b/tests/networkxml2xmlout/nat-network.xml new file mode 100644 index 0000000..35914d2 --- /dev/null +++ b/tests/networkxml2xmlout/nat-network.xml @@ -0,0 +1,13 @@ +<network> + <name>default</name> + <uuid>81ff0d90-c91e-6742-64da-4a736edb9a9b</uuid> + <forward dev='eth1' mode='nat'/> + <bridge name='virbr0' stp='on' forwardDelay='0' /> + <ip address='192.168.122.1' netmask='255.255.255.0'> + <dhcp> + <range start='192.168.122.2' end='192.168.122.254' /> + <host mac='00:16:3e:77:e2:ed' name='a.example.com' ip='192.168.122.10' /> + <host mac='00:16:3e:3e:a9:1a' name='b.example.com' ip='192.168.122.11' /> + </dhcp> + </ip> +</network> diff --git a/tests/networkxml2xmlout/netboot-network.xml b/tests/networkxml2xmlout/netboot-network.xml new file mode 100644 index 0000000..773cb86 --- /dev/null +++ b/tests/networkxml2xmlout/netboot-network.xml @@ -0,0 +1,14 @@ +<network> + <name>netboot</name> + <uuid>81ff0d90-c91e-6742-64da-4a736edb9a9b</uuid> + <forward mode='nat'/> + <bridge name='virbr1' stp='off' forwardDelay='1' /> + <domain name='example.com'/> + <ip address='192.168.122.1' netmask='255.255.255.0'> + <tftp root='/var/lib/tftproot' /> + <dhcp> + <range start='192.168.122.2' end='192.168.122.254' /> + <bootp file='pxeboot.img' /> + </dhcp> + </ip> +</network> diff --git a/tests/networkxml2xmlout/routed-network.xml b/tests/networkxml2xmlout/routed-network.xml new file mode 100644 index 0000000..e9b873e --- /dev/null +++ b/tests/networkxml2xmlout/routed-network.xml @@ -0,0 +1,11 @@ +<network> + <name>local</name> + <uuid>81ff0d90-c91e-6742-64da-4a736edb9a9b</uuid> + <forward dev='eth1' mode='route'/> + <bridge name='virbr1' stp='on' forwardDelay='0' /> + <ip address='192.168.122.1' netmask='255.255.255.0'> + <dhcp> + <range start='192.168.122.2' end='192.168.122.254' /> + </dhcp> + </ip> +</network> diff --git a/tests/networkxml2xmltest.c b/tests/networkxml2xmltest.c new file mode 100644 index 0000000..569809d --- /dev/null +++ b/tests/networkxml2xmltest.c @@ -0,0 +1,97 @@ +#include <config.h> + +#include <stdio.h> +#include <stdlib.h> +#include <unistd.h> +#include <string.h> + +#include <sys/types.h> +#include <fcntl.h> + +#include "internal.h" +#include "testutils.h" +#include "network_conf.h" +#include "testutilsqemu.h" + +static char *progname; +static char *abs_srcdir; + +#define MAX_FILE 4096 + + +static int testCompareXMLToXMLFiles(const char *inxml, const char *outxml) { + char inXmlData[MAX_FILE]; + char *inXmlPtr = &(inXmlData[0]); + char outXmlData[MAX_FILE]; + char *outXmlPtr = &(outXmlData[0]); + char *actual = NULL; + int ret = -1; + virNetworkDefPtr dev = NULL; + + if (virtTestLoadFile(inxml, &inXmlPtr, MAX_FILE) < 0) + goto fail; + if (virtTestLoadFile(outxml, &outXmlPtr, MAX_FILE) < 0) + goto fail; + + if (!(dev = virNetworkDefParseString(NULL, inXmlData))) + goto fail; + + if (!(actual = virNetworkDefFormat(NULL, dev))) + goto fail; + + if (STRNEQ(outXmlData, actual)) { + virtTestDifference(stderr, outXmlData, actual); + goto fail; + } + + ret = 0; + + fail: + free(actual); + virNetworkDefFree(dev); + return ret; +} + +static int testCompareXMLToXMLHelper(const void *data) { + char inxml[PATH_MAX]; + char outxml[PATH_MAX]; + snprintf(inxml, PATH_MAX, "%s/networkxml2xmlin/%s.xml", + abs_srcdir, (const char*)data); + snprintf(outxml, PATH_MAX, "%s/networkxml2xmlout/%s.xml", + abs_srcdir, (const char*)data); + return testCompareXMLToXMLFiles(inxml, outxml); +} + + +static int +mymain(int argc, char **argv) +{ + int ret = 0; + char cwd[PATH_MAX]; + + progname = argv[0]; + + if (argc > 1) { + fprintf(stderr, "Usage: %s\n", progname); + return (EXIT_FAILURE); + } + + abs_srcdir = getenv("abs_srcdir"); + if (!abs_srcdir) + abs_srcdir = getcwd(cwd, sizeof(cwd)); + +#define DO_TEST(name) \ + if (virtTestRun("Network XML-2-XML " name, \ + 1, testCompareXMLToXMLHelper, (name)) < 0) \ + ret = -1 + + DO_TEST("isolated-network"); + DO_TEST("routed-network"); + DO_TEST("nat-network"); + DO_TEST("netboot-network"); + DO_TEST("forward-delay-network"); + + return (ret==0 ? EXIT_SUCCESS : EXIT_FAILURE); +} + +VIRT_TEST_MAIN(mymain) -- 1.6.5.rc2

On Mon, Oct 12, 2009 at 10:46:53AM -0400, Cole Robinson wrote:
Signed-off-by: Cole Robinson <crobinso@redhat.com> --- tests/.gitignore | 1 + tests/Makefile.am | 12 +++- tests/networkschemadata/netboot-network.xml | 12 --- tests/networkschematest | 3 +- tests/networkxml2xmlin/forward-delay-network.xml | 13 +++ tests/networkxml2xmlin/isolated-network.xml | 10 ++ tests/networkxml2xmlin/nat-network.xml | 13 +++ tests/networkxml2xmlin/netboot-network.xml | 14 +++ tests/networkxml2xmlin/routed-network.xml | 11 +++ tests/networkxml2xmlout/forward-delay-network.xml | 13 +++ tests/networkxml2xmlout/isolated-network.xml | 10 ++ tests/networkxml2xmlout/nat-network.xml | 13 +++ tests/networkxml2xmlout/netboot-network.xml | 14 +++ tests/networkxml2xmlout/routed-network.xml | 11 +++ tests/networkxml2xmltest.c | 97 +++++++++++++++++++++ 15 files changed, 232 insertions(+), 15 deletions(-) delete mode 100644 tests/networkschemadata/netboot-network.xml create mode 100644 tests/networkxml2xmlin/forward-delay-network.xml create mode 100644 tests/networkxml2xmlin/isolated-network.xml create mode 100644 tests/networkxml2xmlin/nat-network.xml create mode 100644 tests/networkxml2xmlin/netboot-network.xml create mode 100644 tests/networkxml2xmlin/routed-network.xml create mode 100644 tests/networkxml2xmlout/forward-delay-network.xml create mode 100644 tests/networkxml2xmlout/isolated-network.xml create mode 100644 tests/networkxml2xmlout/nat-network.xml create mode 100644 tests/networkxml2xmlout/netboot-network.xml create mode 100644 tests/networkxml2xmlout/routed-network.xml create mode 100644 tests/networkxml2xmltest.c
ACK Daniel -- |: Red Hat, Engineering, London -o- http://people.redhat.com/berrange/ :| |: http://libvirt.org -o- http://virt-manager.org -o- http://ovirt.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|

Signed-off-by: Cole Robinson <crobinso@redhat.com> --- tests/.gitignore | 1 + tests/Makefile.am | 12 +++- tests/networkschemadata/netboot-network.xml | 12 --- tests/networkschematest | 3 +- tests/networkxml2xmlin/forward-delay-network.xml | 13 +++ tests/networkxml2xmlin/isolated-network.xml | 10 ++ tests/networkxml2xmlin/nat-network.xml | 13 +++ tests/networkxml2xmlin/netboot-network.xml | 14 +++ tests/networkxml2xmlin/routed-network.xml | 11 +++ tests/networkxml2xmlout/forward-delay-network.xml | 13 +++ tests/networkxml2xmlout/isolated-network.xml | 10 ++ tests/networkxml2xmlout/nat-network.xml | 13 +++ tests/networkxml2xmlout/netboot-network.xml | 14 +++ tests/networkxml2xmlout/routed-network.xml | 11 +++ tests/networkxml2xmltest.c | 97 +++++++++++++++++++++ 15 files changed, 232 insertions(+), 15 deletions(-) delete mode 100644 tests/networkschemadata/netboot-network.xml create mode 100644 tests/networkxml2xmlin/forward-delay-network.xml create mode 100644 tests/networkxml2xmlin/isolated-network.xml create mode 100644 tests/networkxml2xmlin/nat-network.xml create mode 100644 tests/networkxml2xmlin/netboot-network.xml create mode 100644 tests/networkxml2xmlin/routed-network.xml create mode 100644 tests/networkxml2xmlout/forward-delay-network.xml create mode 100644 tests/networkxml2xmlout/isolated-network.xml create mode 100644 tests/networkxml2xmlout/nat-network.xml create mode 100644 tests/networkxml2xmlout/netboot-network.xml create mode 100644 tests/networkxml2xmlout/routed-network.xml create mode 100644 tests/networkxml2xmltest.c diff --git a/tests/.gitignore b/tests/.gitignore index 41f8454..c202141 100644 --- a/tests/.gitignore +++ b/tests/.gitignore @@ -13,6 +13,7 @@ qemuxml2xmltest qemuxml2argvtest qemuargv2xmltest qemuhelptest +networkxml2xmltest nodedevxml2xmltest interfacexml2xmltest storagepoolxml2xmltest diff --git a/tests/Makefile.am b/tests/Makefile.am index a62c01b..b6acfa4 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -56,7 +56,8 @@ EXTRA_DIST = \ capabilityschematest \ capabilityschemadata \ networkschematest \ - networkschemadata \ + networkpoolxml2xmlout \ + networkpoolxml2xmlin \ domainschematest \ domainschemadata \ interfaceschemadata \ @@ -96,6 +97,8 @@ if WITH_CIL noinst_PROGRAMS += object-locking endif +noinst_PROGRAMS += networkxml2xmltest + noinst_PROGRAMS += storagepoolxml2xmltest noinst_PROGRAMS += nodedevxml2xmltest @@ -171,6 +174,8 @@ noinst_PROGRAMS += eventtest TESTS += eventtest endif +TESTS += networkxml2xmltest + TESTS += storagepoolxml2xmltest TESTS += nodedevxml2xmltest @@ -269,6 +274,11 @@ else EXTRA_DIST += esxutilstest.c vmx2xmltest.c xml2vmxtest.c endif +networkxml2xmltest_SOURCES = \ + networkxml2xmltest.c \ + testutils.c testutils.h +networkxml2xmltest_LDADD = $(LDADDS) + storagepoolxml2xmltest_SOURCES = \ storagepoolxml2xmltest.c \ testutils.c testutils.h diff --git a/tests/networkschemadata/netboot-network.xml b/tests/networkschemadata/netboot-network.xml deleted file mode 100644 index 7274ee6..0000000 --- a/tests/networkschemadata/netboot-network.xml +++ /dev/null @@ -1,12 +0,0 @@ -<network> - <name>netboot</name> - <bridge name="virbr1" /> - <forward/> - <ip address="192.168.122.1" netmask="255.255.255.0"> - <tftp root="/var/lib/tftproot" /> - <dhcp> - <range start="192.168.122.2" end="192.168.122.254" /> - <bootp file="pxeboot.img" /> - </dhcp> - </ip> -</network> diff --git a/tests/networkschematest b/tests/networkschematest index 8bb24cd..6305576 100755 --- a/tests/networkschematest +++ b/tests/networkschematest @@ -2,8 +2,7 @@ source ./schematestutils.sh -DIRS="../src/network networkschemadata" +DIRS="../src/network networkxml2xmlin networkxml2xmlout" SCHEMA="network.rng" check_schema "$DIRS" "$SCHEMA" - diff --git a/tests/networkxml2xmlin/forward-delay-network.xml b/tests/networkxml2xmlin/forward-delay-network.xml new file mode 100644 index 0000000..d97e185 --- /dev/null +++ b/tests/networkxml2xmlin/forward-delay-network.xml @@ -0,0 +1,13 @@ +<network> + <name>default</name> + <uuid>81ff0d90-c91e-6742-64da-4a736edb9a9b</uuid> + <bridge name="virbr0" forwardDelay='2'/> + <forward mode="nat" dev="eth1"/> + <ip address="192.168.122.1" netmask="255.255.255.0"> + <dhcp> + <range start="192.168.122.2" end="192.168.122.254" /> + <host mac="00:16:3e:77:e2:ed" name="a.example.com" ip="192.168.122.10" /> + <host mac="00:16:3e:3e:a9:1a" name="b.example.com" ip="192.168.122.11" /> + </dhcp> + </ip> +</network> diff --git a/tests/networkxml2xmlin/isolated-network.xml b/tests/networkxml2xmlin/isolated-network.xml new file mode 100644 index 0000000..507e3bb --- /dev/null +++ b/tests/networkxml2xmlin/isolated-network.xml @@ -0,0 +1,10 @@ +<network> + <name>private</name> + <uuid>81ff0d90-c91e-6742-64da-4a736edb9a9b</uuid> + <bridge name="virbr2" /> + <ip address="192.168.152.1" netmask="255.255.255.0"> + <dhcp> + <range start="192.168.152.2" end="192.168.152.254" /> + </dhcp> + </ip> +</network> diff --git a/tests/networkxml2xmlin/nat-network.xml b/tests/networkxml2xmlin/nat-network.xml new file mode 100644 index 0000000..93ab186 --- /dev/null +++ b/tests/networkxml2xmlin/nat-network.xml @@ -0,0 +1,13 @@ +<network> + <name>default</name> + <uuid>81ff0d90-c91e-6742-64da-4a736edb9a9b</uuid> + <bridge name="virbr0" /> + <forward mode="nat" dev="eth1"/> + <ip address="192.168.122.1" netmask="255.255.255.0"> + <dhcp> + <range start="192.168.122.2" end="192.168.122.254" /> + <host mac="00:16:3e:77:e2:ed" name="a.example.com" ip="192.168.122.10" /> + <host mac="00:16:3e:3e:a9:1a" name="b.example.com" ip="192.168.122.11" /> + </dhcp> + </ip> +</network> diff --git a/tests/networkxml2xmlin/netboot-network.xml b/tests/networkxml2xmlin/netboot-network.xml new file mode 100644 index 0000000..ed75663 --- /dev/null +++ b/tests/networkxml2xmlin/netboot-network.xml @@ -0,0 +1,14 @@ +<network> + <name>netboot</name> + <uuid>81ff0d90-c91e-6742-64da-4a736edb9a9b</uuid> + <bridge name="virbr1" stp='off' delay='1'/> + <domain name="example.com"/> + <forward/> + <ip address="192.168.122.1" netmask="255.255.255.0"> + <tftp root="/var/lib/tftproot" /> + <dhcp> + <range start="192.168.122.2" end="192.168.122.254" /> + <bootp file="pxeboot.img" /> + </dhcp> + </ip> +</network> diff --git a/tests/networkxml2xmlin/routed-network.xml b/tests/networkxml2xmlin/routed-network.xml new file mode 100644 index 0000000..824ad75 --- /dev/null +++ b/tests/networkxml2xmlin/routed-network.xml @@ -0,0 +1,11 @@ +<network> + <name>local</name> + <uuid>81ff0d90-c91e-6742-64da-4a736edb9a9b</uuid> + <bridge name="virbr1" /> + <forward mode="route" dev="eth1"/> + <ip address="192.168.122.1" netmask="255.255.255.0"> + <dhcp> + <range start="192.168.122.2" end="192.168.122.254" /> + </dhcp> + </ip> +</network> diff --git a/tests/networkxml2xmlout/forward-delay-network.xml b/tests/networkxml2xmlout/forward-delay-network.xml new file mode 100644 index 0000000..54c62c4 --- /dev/null +++ b/tests/networkxml2xmlout/forward-delay-network.xml @@ -0,0 +1,13 @@ +<network> + <name>default</name> + <uuid>81ff0d90-c91e-6742-64da-4a736edb9a9b</uuid> + <forward dev='eth1' mode='nat'/> + <bridge name='virbr0' stp='on' forwardDelay='2' /> + <ip address='192.168.122.1' netmask='255.255.255.0'> + <dhcp> + <range start='192.168.122.2' end='192.168.122.254' /> + <host mac='00:16:3e:77:e2:ed' name='a.example.com' ip='192.168.122.10' /> + <host mac='00:16:3e:3e:a9:1a' name='b.example.com' ip='192.168.122.11' /> + </dhcp> + </ip> +</network> diff --git a/tests/networkxml2xmlout/isolated-network.xml b/tests/networkxml2xmlout/isolated-network.xml new file mode 100644 index 0000000..b21ead0 --- /dev/null +++ b/tests/networkxml2xmlout/isolated-network.xml @@ -0,0 +1,10 @@ +<network> + <name>private</name> + <uuid>81ff0d90-c91e-6742-64da-4a736edb9a9b</uuid> + <bridge name='virbr2' stp='on' forwardDelay='0' /> + <ip address='192.168.152.1' netmask='255.255.255.0'> + <dhcp> + <range start='192.168.152.2' end='192.168.152.254' /> + </dhcp> + </ip> +</network> diff --git a/tests/networkxml2xmlout/nat-network.xml b/tests/networkxml2xmlout/nat-network.xml new file mode 100644 index 0000000..35914d2 --- /dev/null +++ b/tests/networkxml2xmlout/nat-network.xml @@ -0,0 +1,13 @@ +<network> + <name>default</name> + <uuid>81ff0d90-c91e-6742-64da-4a736edb9a9b</uuid> + <forward dev='eth1' mode='nat'/> + <bridge name='virbr0' stp='on' forwardDelay='0' /> + <ip address='192.168.122.1' netmask='255.255.255.0'> + <dhcp> + <range start='192.168.122.2' end='192.168.122.254' /> + <host mac='00:16:3e:77:e2:ed' name='a.example.com' ip='192.168.122.10' /> + <host mac='00:16:3e:3e:a9:1a' name='b.example.com' ip='192.168.122.11' /> + </dhcp> + </ip> +</network> diff --git a/tests/networkxml2xmlout/netboot-network.xml b/tests/networkxml2xmlout/netboot-network.xml new file mode 100644 index 0000000..773cb86 --- /dev/null +++ b/tests/networkxml2xmlout/netboot-network.xml @@ -0,0 +1,14 @@ +<network> + <name>netboot</name> + <uuid>81ff0d90-c91e-6742-64da-4a736edb9a9b</uuid> + <forward mode='nat'/> + <bridge name='virbr1' stp='off' forwardDelay='1' /> + <domain name='example.com'/> + <ip address='192.168.122.1' netmask='255.255.255.0'> + <tftp root='/var/lib/tftproot' /> + <dhcp> + <range start='192.168.122.2' end='192.168.122.254' /> + <bootp file='pxeboot.img' /> + </dhcp> + </ip> +</network> diff --git a/tests/networkxml2xmlout/routed-network.xml b/tests/networkxml2xmlout/routed-network.xml new file mode 100644 index 0000000..e9b873e --- /dev/null +++ b/tests/networkxml2xmlout/routed-network.xml @@ -0,0 +1,11 @@ +<network> + <name>local</name> + <uuid>81ff0d90-c91e-6742-64da-4a736edb9a9b</uuid> + <forward dev='eth1' mode='route'/> + <bridge name='virbr1' stp='on' forwardDelay='0' /> + <ip address='192.168.122.1' netmask='255.255.255.0'> + <dhcp> + <range start='192.168.122.2' end='192.168.122.254' /> + </dhcp> + </ip> +</network> diff --git a/tests/networkxml2xmltest.c b/tests/networkxml2xmltest.c new file mode 100644 index 0000000..569809d --- /dev/null +++ b/tests/networkxml2xmltest.c @@ -0,0 +1,97 @@ +#include <config.h> + +#include <stdio.h> +#include <stdlib.h> +#include <unistd.h> +#include <string.h> + +#include <sys/types.h> +#include <fcntl.h> + +#include "internal.h" +#include "testutils.h" +#include "network_conf.h" +#include "testutilsqemu.h" + +static char *progname; +static char *abs_srcdir; + +#define MAX_FILE 4096 + + +static int testCompareXMLToXMLFiles(const char *inxml, const char *outxml) { + char inXmlData[MAX_FILE]; + char *inXmlPtr = &(inXmlData[0]); + char outXmlData[MAX_FILE]; + char *outXmlPtr = &(outXmlData[0]); + char *actual = NULL; + int ret = -1; + virNetworkDefPtr dev = NULL; + + if (virtTestLoadFile(inxml, &inXmlPtr, MAX_FILE) < 0) + goto fail; + if (virtTestLoadFile(outxml, &outXmlPtr, MAX_FILE) < 0) + goto fail; + + if (!(dev = virNetworkDefParseString(NULL, inXmlData))) + goto fail; + + if (!(actual = virNetworkDefFormat(NULL, dev))) + goto fail; + + if (STRNEQ(outXmlData, actual)) { + virtTestDifference(stderr, outXmlData, actual); + goto fail; + } + + ret = 0; + + fail: + free(actual); + virNetworkDefFree(dev); + return ret; +} + +static int testCompareXMLToXMLHelper(const void *data) { + char inxml[PATH_MAX]; + char outxml[PATH_MAX]; + snprintf(inxml, PATH_MAX, "%s/networkxml2xmlin/%s.xml", + abs_srcdir, (const char*)data); + snprintf(outxml, PATH_MAX, "%s/networkxml2xmlout/%s.xml", + abs_srcdir, (const char*)data); + return testCompareXMLToXMLFiles(inxml, outxml); +} + + +static int +mymain(int argc, char **argv) +{ + int ret = 0; + char cwd[PATH_MAX]; + + progname = argv[0]; + + if (argc > 1) { + fprintf(stderr, "Usage: %s\n", progname); + return (EXIT_FAILURE); + } + + abs_srcdir = getenv("abs_srcdir"); + if (!abs_srcdir) + abs_srcdir = getcwd(cwd, sizeof(cwd)); + +#define DO_TEST(name) \ + if (virtTestRun("Network XML-2-XML " name, \ + 1, testCompareXMLToXMLHelper, (name)) < 0) \ + ret = -1 + + DO_TEST("isolated-network"); + DO_TEST("routed-network"); + DO_TEST("nat-network"); + DO_TEST("netboot-network"); + DO_TEST("forward-delay-network"); + + return (ret==0 ? EXIT_SUCCESS : EXIT_FAILURE); +} + +VIRT_TEST_MAIN(mymain) -- 1.6.5.rc2

Cole, I'm afraid you broke the dist when making this commit On Mon, Oct 12, 2009 at 10:46:54AM -0400, Cole Robinson wrote:
Signed-off-by: Cole Robinson <crobinso@redhat.com> ---
[...]
create mode 100644 tests/networkxml2xmlin/forward-delay-network.xml create mode 100644 tests/networkxml2xmlin/isolated-network.xml create mode 100644 tests/networkxml2xmlin/nat-network.xml create mode 100644 tests/networkxml2xmlin/netboot-network.xml create mode 100644 tests/networkxml2xmlin/routed-network.xml create mode 100644 tests/networkxml2xmlout/forward-delay-network.xml create mode 100644 tests/networkxml2xmlout/isolated-network.xml create mode 100644 tests/networkxml2xmlout/nat-network.xml create mode 100644 tests/networkxml2xmlout/netboot-network.xml create mode 100644 tests/networkxml2xmlout/routed-network.xml create mode 100644 tests/networkxml2xmltest.c
All files are created in tests/networkxml2xmlin and tests/networkxml2xmlout
--- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -56,7 +56,8 @@ EXTRA_DIST = \ capabilityschematest \ capabilityschemadata \ networkschematest \ - networkschemadata \ + networkpoolxml2xmlout \ + networkpoolxml2xmlin \
But here you use the wrong paths Clearly 'pool' need to be removed from those subdirs, I commited that fix to restore make dist/make rpm Daniel -- Daniel Veillard | libxml Gnome XML XSLT toolkit http://xmlsoft.org/ daniel@veillard.com | Rpmfind RPM search engine http://rpmfind.net/ http://veillard.com/ | virtualization library http://libvirt.org/

On 10/21/2009 05:18 AM, Daniel Veillard wrote:
Cole, I'm afraid you broke the dist when making this commit
On Mon, Oct 12, 2009 at 10:46:54AM -0400, Cole Robinson wrote:
Signed-off-by: Cole Robinson <crobinso@redhat.com> ---
[...]
create mode 100644 tests/networkxml2xmlin/forward-delay-network.xml create mode 100644 tests/networkxml2xmlin/isolated-network.xml create mode 100644 tests/networkxml2xmlin/nat-network.xml create mode 100644 tests/networkxml2xmlin/netboot-network.xml create mode 100644 tests/networkxml2xmlin/routed-network.xml create mode 100644 tests/networkxml2xmlout/forward-delay-network.xml create mode 100644 tests/networkxml2xmlout/isolated-network.xml create mode 100644 tests/networkxml2xmlout/nat-network.xml create mode 100644 tests/networkxml2xmlout/netboot-network.xml create mode 100644 tests/networkxml2xmlout/routed-network.xml create mode 100644 tests/networkxml2xmltest.c
All files are created in tests/networkxml2xmlin and tests/networkxml2xmlout
--- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -56,7 +56,8 @@ EXTRA_DIST = \ capabilityschematest \ capabilityschemadata \ networkschematest \ - networkschemadata \ + networkpoolxml2xmlout \ + networkpoolxml2xmlin \
But here you use the wrong paths Clearly 'pool' need to be removed from those subdirs, I commited that fix to restore make dist/make rpm
Daniel
Arg, my bad. Pretty sure I fixed that at one point but must have rebased incorrectly. Thanks for the fix up. - Cole

Signed-off-by: Cole Robinson <crobinso@redhat.com> --- tests/.gitignore | 1 + tests/Makefile.am | 12 ++- tests/storagevolschemadata/vol-logical.xml | 20 --- tests/storagevolschemadata/vol-partition.xml | 21 ---- tests/storagevolschemadata/vol-qcow2.xml | 31 ----- tests/storagevolschematest | 3 +- tests/storagevolxml2xmlin/vol-file-backing.xml | 24 ++++ tests/storagevolxml2xmlin/vol-file.xml | 15 +++ tests/storagevolxml2xmlin/vol-logical-backing.xml | 29 +++++ tests/storagevolxml2xmlin/vol-logical.xml | 20 +++ tests/storagevolxml2xmlin/vol-partition.xml | 21 ++++ tests/storagevolxml2xmlin/vol-qcow2.xml | 31 +++++ tests/storagevolxml2xmlout/vol-file-backing.xml | 27 +++++ tests/storagevolxml2xmlout/vol-file.xml | 18 +++ tests/storagevolxml2xmlout/vol-logical-backing.xml | 26 ++++ tests/storagevolxml2xmlout/vol-logical.xml | 17 +++ tests/storagevolxml2xmlout/vol-partition.xml | 18 +++ tests/storagevolxml2xmlout/vol-qcow2.xml | 31 +++++ tests/storagevolxml2xmltest.c | 123 ++++++++++++++++++++ 19 files changed, 411 insertions(+), 77 deletions(-) delete mode 100644 tests/storagevolschemadata/vol-logical.xml delete mode 100644 tests/storagevolschemadata/vol-partition.xml delete mode 100644 tests/storagevolschemadata/vol-qcow2.xml create mode 100644 tests/storagevolxml2xmlin/vol-file-backing.xml create mode 100644 tests/storagevolxml2xmlin/vol-file.xml create mode 100644 tests/storagevolxml2xmlin/vol-logical-backing.xml create mode 100644 tests/storagevolxml2xmlin/vol-logical.xml create mode 100644 tests/storagevolxml2xmlin/vol-partition.xml create mode 100644 tests/storagevolxml2xmlin/vol-qcow2.xml create mode 100644 tests/storagevolxml2xmlout/vol-file-backing.xml create mode 100644 tests/storagevolxml2xmlout/vol-file.xml create mode 100644 tests/storagevolxml2xmlout/vol-logical-backing.xml create mode 100644 tests/storagevolxml2xmlout/vol-logical.xml create mode 100644 tests/storagevolxml2xmlout/vol-partition.xml create mode 100644 tests/storagevolxml2xmlout/vol-qcow2.xml create mode 100644 tests/storagevolxml2xmltest.c diff --git a/tests/.gitignore b/tests/.gitignore index c202141..399baee 100644 --- a/tests/.gitignore +++ b/tests/.gitignore @@ -16,6 +16,7 @@ qemuhelptest networkxml2xmltest nodedevxml2xmltest interfacexml2xmltest +storagevolxml2xmltest storagepoolxml2xmltest nodeinfotest statstest diff --git a/tests/Makefile.am b/tests/Makefile.am index b6acfa4..44f16ad 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -65,7 +65,8 @@ EXTRA_DIST = \ storagepoolxml2xmlout \ storagepoolxml2xmlin \ storagevolschematest \ - storagevolschemadata \ + storagevolxml2xmlout \ + storagevolxml2xmlin \ nodedevschematest \ nodedevschemadata \ $(patsubst %,qemuhelpdata/%,$(qemuhelpdata)) @@ -99,7 +100,7 @@ endif noinst_PROGRAMS += networkxml2xmltest -noinst_PROGRAMS += storagepoolxml2xmltest +noinst_PROGRAMS += storagevolxml2xmltest storagepoolxml2xmltest noinst_PROGRAMS += nodedevxml2xmltest @@ -176,7 +177,7 @@ endif TESTS += networkxml2xmltest -TESTS += storagepoolxml2xmltest +TESTS += storagevolxml2xmltest storagepoolxml2xmltest TESTS += nodedevxml2xmltest @@ -279,6 +280,11 @@ networkxml2xmltest_SOURCES = \ testutils.c testutils.h networkxml2xmltest_LDADD = $(LDADDS) +storagevolxml2xmltest_SOURCES = \ + storagevolxml2xmltest.c \ + testutils.c testutils.h +storagevolxml2xmltest_LDADD = $(LDADDS) + storagepoolxml2xmltest_SOURCES = \ storagepoolxml2xmltest.c \ testutils.c testutils.h diff --git a/tests/storagevolschemadata/vol-logical.xml b/tests/storagevolschemadata/vol-logical.xml deleted file mode 100644 index 1c1e29c..0000000 --- a/tests/storagevolschemadata/vol-logical.xml +++ /dev/null @@ -1,20 +0,0 @@ -<volume> - <name>Swap</name> - <key>r4xkCv-MQhr-WKIT-R66x-Epn2-e8hG-1Z5gY0</key> - <source> - <device path='/dev/sda2'> - <extent start='31440502784' end='33520877568'/> - </device> - </source> - <capacity>2080374784</capacity> - <allocation>2080374784</allocation> - <target> - <path>/dev/HostVG/Swap</path> - <permissions> - <mode>060660</mode> - <owner>0</owner> - <group>6</group> - <label>system_u:object_r:fixed_disk_device_t:s0</label> - </permissions> - </target> -</volume> diff --git a/tests/storagevolschemadata/vol-partition.xml b/tests/storagevolschemadata/vol-partition.xml deleted file mode 100644 index 2db7e92..0000000 --- a/tests/storagevolschemadata/vol-partition.xml +++ /dev/null @@ -1,21 +0,0 @@ -<volume> - <name>sda1</name> - <key>/dev/sda1</key> - <source> - <device path='/dev/sda'> - <extent start='32256' end='106928640'/> - </device> - </source> - <capacity>106896384</capacity> - <allocation>106896384</allocation> - <target> - <path>/dev/sda1</path> - <format type='none'/> - <permissions> - <mode>060660</mode> - <owner>0</owner> - <group>6</group> - <label>system_u:object_r:fixed_disk_device_t:s0</label> - </permissions> - </target> -</volume> diff --git a/tests/storagevolschemadata/vol-qcow2.xml b/tests/storagevolschemadata/vol-qcow2.xml deleted file mode 100644 index 2a13cd1..0000000 --- a/tests/storagevolschemadata/vol-qcow2.xml +++ /dev/null @@ -1,31 +0,0 @@ -<volume> - <name>OtherDemo.img</name> - <key>/var/lib/libvirt/images/OtherDemo.img</key> - <source> - </source> - <capacity unit="G">5</capacity> - <allocation>294912</allocation> - <target> - <path>/var/lib/libvirt/images/OtherDemo.img</path> - <format type='qcow2'/> - <permissions> - <mode>0100644</mode> - <owner>0</owner> - <group>0</group> - <label>unconfined_u:object_r:virt_image_t:s0</label> - </permissions> - <encryption format='qcow'> - <secret type='passphrase' uuid='e78d4b51-a2af-485f-b0f5-afca709a80f4'/> - </encryption> - </target> - <backingStore> - <path>/var/lib/libvirt/images/BaseDemo.img</path> - <format type='raw'/> - <permissions> - <mode>0100644</mode> - <owner>0</owner> - <group>0</group> - <label>unconfined_u:object_r:virt_image_t:s0</label> - </permissions> - </backingStore> -</volume> diff --git a/tests/storagevolschematest b/tests/storagevolschematest index 8b5559a..ffc5c8a 100755 --- a/tests/storagevolschematest +++ b/tests/storagevolschematest @@ -2,8 +2,7 @@ source ./schematestutils.sh -DIRS="storagevolschemadata" +DIRS="storagevolxml2xmlin storagevolxml2xmlout" SCHEMA="storagevol.rng" check_schema "$DIRS" "$SCHEMA" - diff --git a/tests/storagevolxml2xmlin/vol-file-backing.xml b/tests/storagevolxml2xmlin/vol-file-backing.xml new file mode 100644 index 0000000..c1a5837 --- /dev/null +++ b/tests/storagevolxml2xmlin/vol-file-backing.xml @@ -0,0 +1,24 @@ +<volume> + <name>sparse.img</name> + <source/> + <capacity>10000000000</capacity> + <allocation>0</allocation> + <target> + <path>/var/lib/libvirt/images/sparse.img</path> + <permissions> + <mode>0</mode> + <owner>0744</owner> + <group>0</group> + </permissions> + </target> + <backingStore> + <path>/var/lib/virt/images/master.img</path> + <format type='vmdk'/> + <permissions> + <mode>0744</mode> + <owner>1</owner> + <group>1</group> + <label>virt_image_t</label> + </permissions> + </backingStore> +</volume> diff --git a/tests/storagevolxml2xmlin/vol-file.xml b/tests/storagevolxml2xmlin/vol-file.xml new file mode 100644 index 0000000..d7de0aa --- /dev/null +++ b/tests/storagevolxml2xmlin/vol-file.xml @@ -0,0 +1,15 @@ +<volume> + <name>sparse.img</name> + <source/> + <capacity unit="T">1</capacity> + <allocation>0</allocation> + <target> + <path>/var/lib/libvirt/images/sparse.img</path> + <permissions> + <mode>0</mode> + <owner>0744</owner> + <group>0</group> + <label>virt_image_t</label> + </permissions> + </target> +</volume> diff --git a/tests/storagevolxml2xmlin/vol-logical-backing.xml b/tests/storagevolxml2xmlin/vol-logical-backing.xml new file mode 100644 index 0000000..b4141a5 --- /dev/null +++ b/tests/storagevolxml2xmlin/vol-logical-backing.xml @@ -0,0 +1,29 @@ +<volume> + <name>Swap</name> + <key>r4xkCv-MQhr-WKIT-R66x-Epn2-e8hG-1Z5gY0</key> + <source> + <device path='/dev/sda2'> + <extent start='31440502784' end='33520877568'/> + </device> + </source> + <capacity>2080374784</capacity> + <allocation>2080374784</allocation> + <target> + <path>/dev/HostVG/Swap</path> + <permissions> + <mode>0660</mode> + <owner>0</owner> + <group>6</group> + <label>system_u:object_r:fixed_disk_device_t:s0</label> + </permissions> + </target> + <backingStore> + <path>/dev/HostVG/snapshot</path> + <permissions> + <mode>0744</mode> + <owner>1</owner> + <group>1</group> + <label>virt_image_t</label> + </permissions> + </backingStore> +</volume> diff --git a/tests/storagevolxml2xmlin/vol-logical.xml b/tests/storagevolxml2xmlin/vol-logical.xml new file mode 100644 index 0000000..cd4d3f7 --- /dev/null +++ b/tests/storagevolxml2xmlin/vol-logical.xml @@ -0,0 +1,20 @@ +<volume> + <name>Swap</name> + <key>r4xkCv-MQhr-WKIT-R66x-Epn2-e8hG-1Z5gY0</key> + <source> + <device path='/dev/sda2'> + <extent start='31440502784' end='33520877568'/> + </device> + </source> + <capacity>2080374784</capacity> + <allocation>2080374784</allocation> + <target> + <path>/dev/HostVG/Swap</path> + <permissions> + <mode>0660</mode> + <owner>0</owner> + <group>6</group> + <label>system_u:object_r:fixed_disk_device_t:s0</label> + </permissions> + </target> +</volume> diff --git a/tests/storagevolxml2xmlin/vol-partition.xml b/tests/storagevolxml2xmlin/vol-partition.xml new file mode 100644 index 0000000..6990bb5 --- /dev/null +++ b/tests/storagevolxml2xmlin/vol-partition.xml @@ -0,0 +1,21 @@ +<volume> + <name>sda1</name> + <key>/dev/sda1</key> + <source> + <device path='/dev/sda'> + <extent start='32256' end='106928640'/> + </device> + </source> + <capacity>106896384</capacity> + <allocation>106896384</allocation> + <target> + <path>/dev/sda1</path> + <format type='none'/> + <permissions> + <mode>0660</mode> + <owner>0</owner> + <group>6</group> + <label>system_u:object_r:fixed_disk_device_t:s0</label> + </permissions> + </target> +</volume> diff --git a/tests/storagevolxml2xmlin/vol-qcow2.xml b/tests/storagevolxml2xmlin/vol-qcow2.xml new file mode 100644 index 0000000..b4924de --- /dev/null +++ b/tests/storagevolxml2xmlin/vol-qcow2.xml @@ -0,0 +1,31 @@ +<volume> + <name>OtherDemo.img</name> + <key>/var/lib/libvirt/images/OtherDemo.img</key> + <source> + </source> + <capacity unit="G">5</capacity> + <allocation>294912</allocation> + <target> + <path>/var/lib/libvirt/images/OtherDemo.img</path> + <format type='qcow2'/> + <permissions> + <mode>0644</mode> + <owner>0</owner> + <group>0</group> + <label>unconfined_u:object_r:virt_image_t:s0</label> + </permissions> + <encryption format='qcow'> + <secret type='passphrase' uuid='e78d4b51-a2af-485f-b0f5-afca709a80f4'/> + </encryption> + </target> + <backingStore> + <path>/var/lib/libvirt/images/BaseDemo.img</path> + <format type='raw'/> + <permissions> + <mode>0644</mode> + <owner>0</owner> + <group>0</group> + <label>unconfined_u:object_r:virt_image_t:s0</label> + </permissions> + </backingStore> +</volume> diff --git a/tests/storagevolxml2xmlout/vol-file-backing.xml b/tests/storagevolxml2xmlout/vol-file-backing.xml new file mode 100644 index 0000000..2d7b9d0 --- /dev/null +++ b/tests/storagevolxml2xmlout/vol-file-backing.xml @@ -0,0 +1,27 @@ +<volume> + <name>sparse.img</name> + <key>(null)</key> + <source> + </source> + <capacity>10000000000</capacity> + <allocation>0</allocation> + <target> + <path>/var/lib/libvirt/images/sparse.img</path> + <format type='raw'/> + <permissions> + <mode>00</mode> + <owner>744</owner> + <group>0</group> + </permissions> + </target> + <backingStore> + <path>/var/lib/virt/images/master.img</path> + <format type='vmdk'/> + <permissions> + <mode>0744</mode> + <owner>1</owner> + <group>1</group> + <label>virt_image_t</label> + </permissions> + </backingStore> +</volume> diff --git a/tests/storagevolxml2xmlout/vol-file.xml b/tests/storagevolxml2xmlout/vol-file.xml new file mode 100644 index 0000000..c4cc91e --- /dev/null +++ b/tests/storagevolxml2xmlout/vol-file.xml @@ -0,0 +1,18 @@ +<volume> + <name>sparse.img</name> + <key>(null)</key> + <source> + </source> + <capacity>1099511627776</capacity> + <allocation>0</allocation> + <target> + <path>/var/lib/libvirt/images/sparse.img</path> + <format type='raw'/> + <permissions> + <mode>00</mode> + <owner>744</owner> + <group>0</group> + <label>virt_image_t</label> + </permissions> + </target> +</volume> diff --git a/tests/storagevolxml2xmlout/vol-logical-backing.xml b/tests/storagevolxml2xmlout/vol-logical-backing.xml new file mode 100644 index 0000000..45b8f3a --- /dev/null +++ b/tests/storagevolxml2xmlout/vol-logical-backing.xml @@ -0,0 +1,26 @@ +<volume> + <name>Swap</name> + <key>(null)</key> + <source> + </source> + <capacity>2080374784</capacity> + <allocation>2080374784</allocation> + <target> + <path>/dev/HostVG/Swap</path> + <permissions> + <mode>0660</mode> + <owner>0</owner> + <group>6</group> + <label>system_u:object_r:fixed_disk_device_t:s0</label> + </permissions> + </target> + <backingStore> + <path>/dev/HostVG/snapshot</path> + <permissions> + <mode>0744</mode> + <owner>1</owner> + <group>1</group> + <label>virt_image_t</label> + </permissions> + </backingStore> +</volume> diff --git a/tests/storagevolxml2xmlout/vol-logical.xml b/tests/storagevolxml2xmlout/vol-logical.xml new file mode 100644 index 0000000..570956e --- /dev/null +++ b/tests/storagevolxml2xmlout/vol-logical.xml @@ -0,0 +1,17 @@ +<volume> + <name>Swap</name> + <key>(null)</key> + <source> + </source> + <capacity>2080374784</capacity> + <allocation>2080374784</allocation> + <target> + <path>/dev/HostVG/Swap</path> + <permissions> + <mode>0660</mode> + <owner>0</owner> + <group>6</group> + <label>system_u:object_r:fixed_disk_device_t:s0</label> + </permissions> + </target> +</volume> diff --git a/tests/storagevolxml2xmlout/vol-partition.xml b/tests/storagevolxml2xmlout/vol-partition.xml new file mode 100644 index 0000000..c3d861e --- /dev/null +++ b/tests/storagevolxml2xmlout/vol-partition.xml @@ -0,0 +1,18 @@ +<volume> + <name>sda1</name> + <key>(null)</key> + <source> + </source> + <capacity>106896384</capacity> + <allocation>106896384</allocation> + <target> + <path>/dev/sda1</path> + <format type='none'/> + <permissions> + <mode>0660</mode> + <owner>0</owner> + <group>6</group> + <label>system_u:object_r:fixed_disk_device_t:s0</label> + </permissions> + </target> +</volume> diff --git a/tests/storagevolxml2xmlout/vol-qcow2.xml b/tests/storagevolxml2xmlout/vol-qcow2.xml new file mode 100644 index 0000000..30fea1e --- /dev/null +++ b/tests/storagevolxml2xmlout/vol-qcow2.xml @@ -0,0 +1,31 @@ +<volume> + <name>OtherDemo.img</name> + <key>(null)</key> + <source> + </source> + <capacity>5368709120</capacity> + <allocation>294912</allocation> + <target> + <path>/var/lib/libvirt/images/OtherDemo.img</path> + <format type='qcow2'/> + <permissions> + <mode>0644</mode> + <owner>0</owner> + <group>0</group> + <label>unconfined_u:object_r:virt_image_t:s0</label> + </permissions> + <encryption format='qcow'> + <secret type='passphrase' uuid='e78d4b51-a2af-485f-b0f5-afca709a80f4'/> + </encryption> + </target> + <backingStore> + <path>/var/lib/libvirt/images/BaseDemo.img</path> + <format type='raw'/> + <permissions> + <mode>0644</mode> + <owner>0</owner> + <group>0</group> + <label>unconfined_u:object_r:virt_image_t:s0</label> + </permissions> + </backingStore> +</volume> diff --git a/tests/storagevolxml2xmltest.c b/tests/storagevolxml2xmltest.c new file mode 100644 index 0000000..17bf009 --- /dev/null +++ b/tests/storagevolxml2xmltest.c @@ -0,0 +1,123 @@ +#include <config.h> + +#include <stdio.h> +#include <stdlib.h> +#include <unistd.h> +#include <string.h> + +#include <sys/types.h> +#include <fcntl.h> + +#include "internal.h" +#include "testutils.h" +#include "storage_conf.h" +#include "testutilsqemu.h" + +static char *progname; +static char *abs_srcdir; + +#define MAX_FILE 4096 + + +static int testCompareXMLToXMLFiles(const char *poolxml, + const char *inxml, + const char *outxml) { + char poolXmlData[MAX_FILE]; + char *poolXmlPtr = &(poolXmlData[0]); + char inXmlData[MAX_FILE]; + char *inXmlPtr = &(inXmlData[0]); + char outXmlData[MAX_FILE]; + char *outXmlPtr = &(outXmlData[0]); + char *actual = NULL; + int ret = -1; + virStoragePoolDefPtr pool = NULL; + virStorageVolDefPtr dev = NULL; + + if (virtTestLoadFile(poolxml, &poolXmlPtr, MAX_FILE) < 0) + goto fail; + if (virtTestLoadFile(inxml, &inXmlPtr, MAX_FILE) < 0) + goto fail; + if (virtTestLoadFile(outxml, &outXmlPtr, MAX_FILE) < 0) + goto fail; + + if (!(pool = virStoragePoolDefParseString(NULL, poolXmlData))) + goto fail; + + if (!(dev = virStorageVolDefParseString(NULL, pool, inXmlData))) + goto fail; + + if (!(actual = virStorageVolDefFormat(NULL, pool, dev))) + goto fail; + + if (STRNEQ(outXmlData, actual)) { + virtTestDifference(stderr, outXmlData, actual); + goto fail; + } + + ret = 0; + + fail: + free(actual); + virStoragePoolDefFree(pool); + virStorageVolDefFree(dev); + return ret; +} + +struct testInfo { + const char *pool; + const char *name; +}; + +static int testCompareXMLToXMLHelper(const void *data) { + char poolxml[PATH_MAX]; + char inxml[PATH_MAX]; + char outxml[PATH_MAX]; + const struct testInfo *info = data; + + snprintf(poolxml, PATH_MAX, "%s/storagepoolxml2xmlin/%s.xml", + abs_srcdir, (const char*)info->pool); + snprintf(inxml, PATH_MAX, "%s/storagevolxml2xmlin/%s.xml", + abs_srcdir, (const char*)info->name); + snprintf(outxml, PATH_MAX, "%s/storagevolxml2xmlout/%s.xml", + abs_srcdir, (const char*)info->name); + return testCompareXMLToXMLFiles(poolxml, inxml, outxml); +} + + +static int +mymain(int argc, char **argv) +{ + int ret = 0; + char cwd[PATH_MAX]; + + progname = argv[0]; + + if (argc > 1) { + fprintf(stderr, "Usage: %s\n", progname); + return (EXIT_FAILURE); + } + + abs_srcdir = getenv("abs_srcdir"); + if (!abs_srcdir) + abs_srcdir = getcwd(cwd, sizeof(cwd)); + +#define DO_TEST(pool, name) \ + do { \ + struct testInfo info = { pool, name }; \ + if (virtTestRun("Storage Vol XML-2-XML " name, \ + 1, testCompareXMLToXMLHelper, &info) < 0) \ + ret = -1; \ + } \ + while(0); + + DO_TEST("pool-dir", "vol-file"); + DO_TEST("pool-dir", "vol-file-backing"); + DO_TEST("pool-dir", "vol-qcow2"); + DO_TEST("pool-disk", "vol-partition"); + DO_TEST("pool-logical", "vol-logical"); + DO_TEST("pool-logical", "vol-logical-backing"); + + return (ret==0 ? EXIT_SUCCESS : EXIT_FAILURE); +} + +VIRT_TEST_MAIN(mymain) -- 1.6.5.rc2

On 10/12/2009 10:46 AM, Cole Robinson wrote:
Signed-off-by: Cole Robinson <crobinso@redhat.com>
Sorry, this series was a little butchered. This should be patch 10, please ignore the duplicate 'tests: Add network XML to XML tests' - Cole

On Mon, Oct 12, 2009 at 10:46:55AM -0400, Cole Robinson wrote:
Signed-off-by: Cole Robinson <crobinso@redhat.com> --- tests/.gitignore | 1 + tests/Makefile.am | 12 ++- tests/storagevolschemadata/vol-logical.xml | 20 --- tests/storagevolschemadata/vol-partition.xml | 21 ---- tests/storagevolschemadata/vol-qcow2.xml | 31 ----- tests/storagevolschematest | 3 +- tests/storagevolxml2xmlin/vol-file-backing.xml | 24 ++++ tests/storagevolxml2xmlin/vol-file.xml | 15 +++ tests/storagevolxml2xmlin/vol-logical-backing.xml | 29 +++++ tests/storagevolxml2xmlin/vol-logical.xml | 20 +++ tests/storagevolxml2xmlin/vol-partition.xml | 21 ++++ tests/storagevolxml2xmlin/vol-qcow2.xml | 31 +++++ tests/storagevolxml2xmlout/vol-file-backing.xml | 27 +++++ tests/storagevolxml2xmlout/vol-file.xml | 18 +++ tests/storagevolxml2xmlout/vol-logical-backing.xml | 26 ++++ tests/storagevolxml2xmlout/vol-logical.xml | 17 +++ tests/storagevolxml2xmlout/vol-partition.xml | 18 +++ tests/storagevolxml2xmlout/vol-qcow2.xml | 31 +++++ tests/storagevolxml2xmltest.c | 123 ++++++++++++++++++++ 19 files changed, 411 insertions(+), 77 deletions(-) delete mode 100644 tests/storagevolschemadata/vol-logical.xml delete mode 100644 tests/storagevolschemadata/vol-partition.xml delete mode 100644 tests/storagevolschemadata/vol-qcow2.xml create mode 100644 tests/storagevolxml2xmlin/vol-file-backing.xml create mode 100644 tests/storagevolxml2xmlin/vol-file.xml create mode 100644 tests/storagevolxml2xmlin/vol-logical-backing.xml create mode 100644 tests/storagevolxml2xmlin/vol-logical.xml create mode 100644 tests/storagevolxml2xmlin/vol-partition.xml create mode 100644 tests/storagevolxml2xmlin/vol-qcow2.xml create mode 100644 tests/storagevolxml2xmlout/vol-file-backing.xml create mode 100644 tests/storagevolxml2xmlout/vol-file.xml create mode 100644 tests/storagevolxml2xmlout/vol-logical-backing.xml create mode 100644 tests/storagevolxml2xmlout/vol-logical.xml create mode 100644 tests/storagevolxml2xmlout/vol-partition.xml create mode 100644 tests/storagevolxml2xmlout/vol-qcow2.xml create mode 100644 tests/storagevolxml2xmltest.c
ACK Daniel -- |: Red Hat, Engineering, London -o- http://people.redhat.com/berrange/ :| |: http://libvirt.org -o- http://virt-manager.org -o- http://ovirt.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|

On Mon, Oct 12, 2009 at 10:46:47AM -0400, Cole Robinson wrote:
All schema tests have identical functionality, so avoid the duplication.
Signed-off-by: Cole Robinson <crobinso@redhat.com> --- tests/Makefile.am | 1 + tests/capabilityschematest | 34 ++++------------------------------ tests/domainschematest | 33 ++++----------------------------- tests/interfaceschematest | 31 +++---------------------------- tests/networkschematest | 30 +++--------------------------- tests/nodedevschematest | 31 +++---------------------------- tests/schematestutils.sh | 39 +++++++++++++++++++++++++++++++++++++++ tests/storagepoolschematest | 31 +++---------------------------- tests/storagevolschematest | 30 +++--------------------------- 9 files changed, 63 insertions(+), 197 deletions(-) create mode 100644 tests/schematestutils.sh
ACK Daniel -- |: Red Hat, Engineering, London -o- http://people.redhat.com/berrange/ :| |: http://libvirt.org -o- http://virt-manager.org -o- http://ovirt.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|

Daniel P. Berrange wrote:
On Mon, Oct 12, 2009 at 10:46:47AM -0400, Cole Robinson wrote:
All schema tests have identical functionality, so avoid the duplication.
Signed-off-by: Cole Robinson <crobinso@redhat.com> --- tests/Makefile.am | 1 + tests/capabilityschematest | 34 ++++------------------------------ tests/domainschematest | 33 ++++----------------------------- tests/interfaceschematest | 31 +++---------------------------- tests/networkschematest | 30 +++--------------------------- tests/nodedevschematest | 31 +++---------------------------- tests/schematestutils.sh | 39 +++++++++++++++++++++++++++++++++++++++ tests/storagepoolschematest | 31 +++---------------------------- tests/storagevolschematest | 30 +++--------------------------- 9 files changed, 63 insertions(+), 197 deletions(-) create mode 100644 tests/schematestutils.sh
ACK
Daniel
Pushed now. Thanks, Cole

2009/10/12 Cole Robinson <crobinso@redhat.com>:
All schema tests have identical functionality, so avoid the duplication.
Signed-off-by: Cole Robinson <crobinso@redhat.com> --- tests/Makefile.am | 1 + tests/capabilityschematest | 34 ++++------------------------------ tests/domainschematest | 33 ++++----------------------------- tests/interfaceschematest | 31 +++---------------------------- tests/networkschematest | 30 +++--------------------------- tests/nodedevschematest | 31 +++---------------------------- tests/schematestutils.sh | 39 +++++++++++++++++++++++++++++++++++++++ tests/storagepoolschematest | 31 +++---------------------------- tests/storagevolschematest | 30 +++--------------------------- 9 files changed, 63 insertions(+), 197 deletions(-) create mode 100644 tests/schematestutils.sh
Your patch adds some bashisms. This prevents make check from running successfully on Debian/Ubuntu, because their default shell is dash and not bash. The attached patch removes this bashisms. Matthias

Matthias Bolte wrote:
2009/10/12 Cole Robinson <crobinso@redhat.com>:
All schema tests have identical functionality, so avoid the duplication.
Signed-off-by: Cole Robinson <crobinso@redhat.com> ---  tests/Makefile.am      |   1 +  tests/capabilityschematest  |  34 ++++------------------------------  tests/domainschematest    |  33 ++++-----------------------------  tests/interfaceschematest  |  31 +++----------------------------  tests/networkschematest   |  30 +++---------------------------  tests/nodedevschematest   |  31 +++----------------------------  tests/schematestutils.sh   |  39 +++++++++++++++++++++++++++++++++++++++  tests/storagepoolschematest |  31 +++----------------------------  tests/storagevolschematest  |  30 +++---------------------------  9 files changed, 63 insertions(+), 197 deletions(-)  create mode 100644 tests/schematestutils.sh
Your patch adds some bashisms. This prevents make check from running successfully on Debian/Ubuntu, because their default shell is dash and not bash.
The attached patch removes this bashisms.
Matthias
Ah, I meant to check for that, I've made the same mistake in the past. ACK to the patch. Thanks, Cole

On Mon, Oct 12, 2009 at 10:45:05AM -0400, Cole Robinson wrote:
In attempting to refactor some storage pool XML parsing, I wanted some unit tests to ensure I wasn't causing regressions. So, the following series adds XML 2 XML tests for storage pools (and virtual networks and storage vols). Also included are several cleanups in tests/, and bug fixes needed to make the new tests actually pass.
Cole Robinson (10): tests: Fix text output for interface XML 2 XML tests: Document VIR_TEST_DEBUG environment variable. tests: Break out duplicate schema verification functionality. storage: Fix generating iscsi 'auth' xml schema: Update storage pool schema. tests: Add XML 2 XML tests for storage pools. network: Fix reading 'forwardDelay' attribute. schema: Update network schema. tests: Add network XML to XML tests. tests: Add storage volume XML 2 XML tests.
I'm fine with the overall test cleanup. I would prefer if the few real bug fixes in the lot could be fixed now for 0.7.2 release, if you want to commit the changes to test/ I'm fine too since that should not affect running code (just make sure 'make dist' still passes after it ;-) thanks ! Daniel -- Daniel Veillard | libxml Gnome XML XSLT toolkit http://xmlsoft.org/ daniel@veillard.com | Rpmfind RPM search engine http://rpmfind.net/ http://veillard.com/ | virtualization library http://libvirt.org/
participants (4)
-
Cole Robinson
-
Daniel P. Berrange
-
Daniel Veillard
-
Matthias Bolte