diff options
author | Eric Blake <eblake@redhat.com> | 2012-02-04 07:01:56 -0700 |
---|---|---|
committer | Eric Blake <eblake@redhat.com> | 2012-02-06 12:04:33 -0700 |
commit | c052d8a89f6df81822abbd0a3204d47f402f6de4 (patch) | |
tree | f472eed9a8f28673bd58733eea6d32216df000e5 /tests/qemuxml2xmltest.c | |
parent | maint: Add test output files to .gitignore (diff) | |
download | libvirt-c052d8a89f6df81822abbd0a3204d47f402f6de4.tar.gz libvirt-c052d8a89f6df81822abbd0a3204d47f402f6de4.tar.bz2 libvirt-c052d8a89f6df81822abbd0a3204d47f402f6de4.zip |
seclabel: make code and RNG match
Commit b170eb99 introduced a bug: domains that had an explicit
<seclabel type='none'/> when started would not be reparsed if
libvirtd restarted. It turns out that our testsuite was not
exercising this because it never tried anything but inactive
parsing. Additionally, the live XML for such a domain failed
to re-validate. Applying just the tests/ portion of this patch
will expose the bugs that are fixed by the other two files.
* docs/schemas/domaincommon.rng (seclabel): Allow relabel under
type='none'.
* src/conf/domain_conf.c (virSecurityLabelDefParseXML): Per RNG,
presence of <seclabel> with no type implies dynamic. Don't
require sub-elements for type='none'.
* tests/qemuxml2xmltest.c (mymain): Add test.
* tests/qemuxml2argvtest.c (mymain): Likewise.
* tests/qemuxml2argvdata/qemuxml2argv-seclabel-none.xml: Add file.
* tests/qemuxml2argvdata/qemuxml2argv-seclabel-none.args: Add file.
Reported by Ansis Atteka.
Diffstat (limited to 'tests/qemuxml2xmltest.c')
-rw-r--r-- | tests/qemuxml2xmltest.c | 29 |
1 files changed, 19 insertions, 10 deletions
diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c index b0f80d3ff..ddc7caecb 100644 --- a/tests/qemuxml2xmltest.c +++ b/tests/qemuxml2xmltest.c @@ -19,7 +19,7 @@ static struct qemud_driver driver; static int -testCompareXMLToXMLFiles(const char *inxml, const char *outxml) +testCompareXMLToXMLFiles(const char *inxml, const char *outxml, bool live) { char *inXmlData = NULL; char *outXmlData = NULL; @@ -34,7 +34,7 @@ testCompareXMLToXMLFiles(const char *inxml, const char *outxml) if (!(def = virDomainDefParseString(driver.caps, inXmlData, QEMU_EXPECTED_VIRT_TYPES, - VIR_DOMAIN_XML_INACTIVE))) + live ? 0 : VIR_DOMAIN_XML_INACTIVE))) goto fail; if (!(actual = virDomainDefFormat(def, VIR_DOMAIN_XML_SECURE))) @@ -58,6 +58,7 @@ testCompareXMLToXMLFiles(const char *inxml, const char *outxml) struct testInfo { const char *name; int different; + bool inactive_only; }; static int @@ -75,9 +76,16 @@ testCompareXMLToXMLHelper(const void *data) goto cleanup; if (info->different) { - ret = testCompareXMLToXMLFiles(xml_in, xml_out); + ret = testCompareXMLToXMLFiles(xml_in, xml_out, false); } else { - ret = testCompareXMLToXMLFiles(xml_in, xml_in); + ret = testCompareXMLToXMLFiles(xml_in, xml_in, false); + } + if (!info->inactive_only) { + if (info->different) { + ret = testCompareXMLToXMLFiles(xml_in, xml_out, true); + } else { + ret = testCompareXMLToXMLFiles(xml_in, xml_in, true); + } } cleanup: @@ -95,19 +103,19 @@ mymain(void) if ((driver.caps = testQemuCapsInit()) == NULL) return (EXIT_FAILURE); -# define DO_TEST_FULL(name, is_different) \ +# define DO_TEST_FULL(name, is_different, inactive) \ do { \ - const struct testInfo info = {name, is_different}; \ + const struct testInfo info = {name, is_different, inactive}; \ if (virtTestRun("QEMU XML-2-XML " name, \ 1, testCompareXMLToXMLHelper, &info) < 0) \ ret = -1; \ } while (0) # define DO_TEST(name) \ - DO_TEST_FULL(name, 0) + DO_TEST_FULL(name, 0, false) # define DO_TEST_DIFFERENT(name) \ - DO_TEST_FULL(name, 1) + DO_TEST_FULL(name, 1, false) /* Unset or set all envvars here that are copied in qemudBuildCommandLine * using ADD_ENV_COPY, otherwise these tests may fail due to unexpected @@ -200,9 +208,10 @@ mymain(void) DO_TEST("usb-redir"); DO_TEST("blkdeviotune"); - DO_TEST("seclabel-dynamic-baselabel"); - DO_TEST("seclabel-dynamic-override"); + DO_TEST_FULL("seclabel-dynamic-baselabel", false, true); + DO_TEST_FULL("seclabel-dynamic-override", false, true); DO_TEST("seclabel-static"); + DO_TEST("seclabel-none"); /* These tests generate different XML */ DO_TEST_DIFFERENT("balloon-device-auto"); |