The testsuite is absolutely essential to feeling comfortable about swapping the backing chain structure over to a new format. This patch tests the path settings, and demonstrates that right now the code is passing only the canonical name to the child struct, which means more work is necessary in virstoragefile to pass the user spelling alongside the canonical name down to the child. * tests/virstoragetest.c (testStorageChain): Test path. (mymain): Update expected data. Signed-off-by: Eric Blake <eblake@xxxxxxxxxx> --- tests/virstoragetest.c | 239 ++++++++++++++++++++++++++++++++++++------------- 1 file changed, 175 insertions(+), 64 deletions(-) diff --git a/tests/virstoragetest.c b/tests/virstoragetest.c index efd920a..9d6e344 100644 --- a/tests/virstoragetest.c +++ b/tests/virstoragetest.c @@ -205,6 +205,7 @@ struct _testFileData bool expIsFile; unsigned long long expCapacity; bool expEncrypted; + const char *expPath; }; enum { @@ -266,21 +267,25 @@ testStorageChain(const void *args) } if (virAsprintf(&expect, - "store:%s\nraw:%s\ndirectory:%s\nother:%d %d %lld %d", + "store:%s\nraw:%s\ndirectory:%s\nother:%d %d %lld %d\n" + "path:%s\n", NULLSTR(data->files[i]->expBackingStore), NULLSTR(data->files[i]->expBackingStoreRaw), NULLSTR(data->files[i]->expDirectory), data->files[i]->expFormat, data->files[i]->expIsFile, data->files[i]->expCapacity, - data->files[i]->expEncrypted) < 0 || + data->files[i]->expEncrypted, + NULLSTR(data->files[i]->expPath)) < 0 || virAsprintf(&actual, - "store:%s\nraw:%s\ndirectory:%s\nother:%d %d %lld %d", + "store:%s\nraw:%s\ndirectory:%s\nother:%d %d %lld %d\n" + "path:%s\n", NULLSTR(elt->backingStore), NULLSTR(elt->backingStoreRaw), NULLSTR(elt->directory), elt->backingStoreFormat, elt->backingStoreIsFile, - elt->capacity, !!elt->encryption) < 0) { + elt->capacity, !!elt->encryption, + NULLSTR(elt->path)) < 0) { VIR_FREE(expect); VIR_FREE(actual); goto cleanup; @@ -351,9 +356,24 @@ mymain(void) } while (0) /* Expected details about files in chains */ - const testFileData raw = { + const testFileData rel_raw = { .expFormat = VIR_STORAGE_FILE_NONE, + .expPath = "raw", }; + const testFileData abs_raw = { + .expFormat = VIR_STORAGE_FILE_NONE, + .expPath = canonraw, + }; + + const testFileData rel_qcow2_as_raw = { + .expFormat = VIR_STORAGE_FILE_NONE, + .expPath = "qcow2", + }; + const testFileData abs_qcow2_as_raw = { + .expFormat = VIR_STORAGE_FILE_NONE, + .expPath = canonqcow2, + }; + const testFileData qcow2_relback_relstart = { .expBackingStore = canonraw, .expBackingStoreRaw = "raw", @@ -361,6 +381,7 @@ mymain(void) .expFormat = VIR_STORAGE_FILE_RAW, .expIsFile = true, .expCapacity = 1024, + .expPath = "qcow2", }; const testFileData qcow2_relback_absstart = { .expBackingStore = canonraw, @@ -369,15 +390,28 @@ mymain(void) .expFormat = VIR_STORAGE_FILE_RAW, .expIsFile = true, .expCapacity = 1024, + .expPath = canonqcow2, }; - const testFileData qcow2_absback = { + + const testFileData rel_qcow2_absback = { .expBackingStore = canonraw, .expBackingStoreRaw = absraw, .expDirectory = datadir, .expFormat = VIR_STORAGE_FILE_RAW, .expIsFile = true, .expCapacity = 1024, + .expPath = "qcow2", }; + const testFileData abs_qcow2_absback = { + .expBackingStore = canonraw, + .expBackingStoreRaw = absraw, + .expDirectory = datadir, + .expFormat = VIR_STORAGE_FILE_RAW, + .expIsFile = true, + .expCapacity = 1024, + .expPath = canonqcow2, + }; + const testFileData qcow2_as_probe = { .expBackingStore = canonraw, .expBackingStoreRaw = absraw, @@ -385,50 +419,122 @@ mymain(void) .expFormat = VIR_STORAGE_FILE_AUTO, .expIsFile = true, .expCapacity = 1024, + .expPath = canonqcow2, }; - const testFileData qcow2_bogus = { + + const testFileData rel_qcow2_bogus = { .expBackingStoreRaw = datadir "/bogus", .expDirectory = datadir, .expFormat = VIR_STORAGE_FILE_NONE, .expCapacity = 1024, + .expPath = "qcow2", }; - const testFileData qcow2_protocol = { + const testFileData abs_qcow2_bogus = { + .expBackingStoreRaw = datadir "/bogus", + .expDirectory = datadir, + .expFormat = VIR_STORAGE_FILE_NONE, + .expCapacity = 1024, + .expPath = canonqcow2, + }; + + const testFileData rel_qcow2_protocol = { .expBackingStore = "nbd:example.org:6000", .expFormat = VIR_STORAGE_FILE_RAW, .expCapacity = 1024, + .expPath = "qcow2", }; - const testFileData wrap = { + const testFileData abs_qcow2_protocol = { + .expBackingStore = "nbd:example.org:6000", + .expFormat = VIR_STORAGE_FILE_RAW, + .expCapacity = 1024, + .expPath = canonqcow2, + }; + + const testFileData rel_wrap = { .expBackingStore = canonqcow2, .expBackingStoreRaw = absqcow2, .expDirectory = datadir, .expFormat = VIR_STORAGE_FILE_QCOW2, .expIsFile = true, .expCapacity = 1024, + .expPath = "wrap", }; - const testFileData wrap_as_raw = { + const testFileData abs_wrap = { + .expBackingStore = canonqcow2, + .expBackingStoreRaw = absqcow2, + .expDirectory = datadir, + .expFormat = VIR_STORAGE_FILE_QCOW2, + .expIsFile = true, + .expCapacity = 1024, + .expPath = abswrap, + }; + + const testFileData rel_wrap_as_raw = { .expBackingStore = canonqcow2, .expBackingStoreRaw = absqcow2, .expDirectory = datadir, .expFormat = VIR_STORAGE_FILE_RAW, .expIsFile = true, .expCapacity = 1024, + .expPath = "wrap", }; - const testFileData wrap_as_probe = { + const testFileData abs_wrap_as_raw = { + .expBackingStore = canonqcow2, + .expBackingStoreRaw = absqcow2, + .expDirectory = datadir, + .expFormat = VIR_STORAGE_FILE_RAW, + .expIsFile = true, + .expCapacity = 1024, + .expPath = abswrap, + }; + + const testFileData rel_wrap_as_probe = { .expBackingStore = canonqcow2, .expBackingStoreRaw = absqcow2, .expDirectory = datadir, .expFormat = VIR_STORAGE_FILE_AUTO, .expIsFile = true, .expCapacity = 1024, + .expPath = "wrap", }; - const testFileData qed = { + const testFileData abs_wrap_as_probe = { + .expBackingStore = canonqcow2, + .expBackingStoreRaw = absqcow2, + .expDirectory = datadir, + .expFormat = VIR_STORAGE_FILE_AUTO, + .expIsFile = true, + .expCapacity = 1024, + .expPath = abswrap, + }; + + const testFileData rel_qed_as_raw = { + .expFormat = VIR_STORAGE_FILE_NONE, + .expPath = "qed", + }; + const testFileData abs_qed_as_raw = { + .expFormat = VIR_STORAGE_FILE_NONE, + .expPath = absqed, + }; + + const testFileData rel_qed = { + .expBackingStore = canonraw, + .expBackingStoreRaw = absraw, + .expDirectory = datadir, + .expFormat = VIR_STORAGE_FILE_RAW, + .expIsFile = true, + .expCapacity = 1024, + .expPath = "qed", + }; + const testFileData abs_qed = { .expBackingStore = canonraw, .expBackingStoreRaw = absraw, .expDirectory = datadir, .expFormat = VIR_STORAGE_FILE_RAW, .expIsFile = true, .expCapacity = 1024, + .expPath = absqed, }; + #if HAVE_SYMLINK const testFileData link1_rel = { .expBackingStore = canonraw, @@ -437,6 +543,7 @@ mymain(void) .expFormat = VIR_STORAGE_FILE_RAW, .expIsFile = true, .expCapacity = 1024, + .expPath = canonqcow2, }; const testFileData link1_abs = { .expBackingStore = canonraw, @@ -445,7 +552,9 @@ mymain(void) .expFormat = VIR_STORAGE_FILE_RAW, .expIsFile = true, .expCapacity = 1024, + .expPath = canonqcow2, }; + const testFileData link2_rel = { .expBackingStore = canonqcow2, .expBackingStoreRaw = "../sub/link1", @@ -453,6 +562,7 @@ mymain(void) .expFormat = VIR_STORAGE_FILE_QCOW2, .expIsFile = true, .expCapacity = 1024, + .expPath = "sub/link2", }; const testFileData link2_abs = { .expBackingStore = canonqcow2, @@ -461,6 +571,7 @@ mymain(void) .expFormat = VIR_STORAGE_FILE_QCOW2, .expIsFile = true, .expCapacity = 1024, + .expPath = abslink2, }; #endif @@ -471,27 +582,27 @@ mymain(void) /* Raw image, whether with right format or no specified format */ TEST_CHAIN(1, "raw", absraw, VIR_STORAGE_FILE_RAW, - (&raw), EXP_PASS, - (&raw), ALLOW_PROBE | EXP_PASS, - (&raw), EXP_PASS, - (&raw), ALLOW_PROBE | EXP_PASS); + (&rel_raw), EXP_PASS, + (&rel_raw), ALLOW_PROBE | EXP_PASS, + (&abs_raw), EXP_PASS, + (&abs_raw), ALLOW_PROBE | EXP_PASS); TEST_CHAIN(2, "raw", absraw, VIR_STORAGE_FILE_AUTO, - (&raw), EXP_PASS, - (&raw), ALLOW_PROBE | EXP_PASS, - (&raw), EXP_PASS, - (&raw), ALLOW_PROBE | EXP_PASS); + (&rel_raw), EXP_PASS, + (&rel_raw), ALLOW_PROBE | EXP_PASS, + (&abs_raw), EXP_PASS, + (&abs_raw), ALLOW_PROBE | EXP_PASS); /* Qcow2 file with relative raw backing, format provided */ TEST_CHAIN(3, "qcow2", absqcow2, VIR_STORAGE_FILE_QCOW2, - (&qcow2_relback_relstart, &raw), EXP_PASS, - (&qcow2_relback_relstart, &raw), ALLOW_PROBE | EXP_PASS, - (&qcow2_relback_absstart, &raw), EXP_PASS, - (&qcow2_relback_absstart, &raw), ALLOW_PROBE | EXP_PASS); + (&qcow2_relback_relstart, &abs_raw), EXP_PASS, + (&qcow2_relback_relstart, &abs_raw), ALLOW_PROBE | EXP_PASS, + (&qcow2_relback_absstart, &abs_raw), EXP_PASS, + (&qcow2_relback_absstart, &abs_raw), ALLOW_PROBE | EXP_PASS); TEST_CHAIN(4, "qcow2", absqcow2, VIR_STORAGE_FILE_AUTO, - (&raw), EXP_PASS, - (&qcow2_relback_relstart, &raw), ALLOW_PROBE | EXP_PASS, - (&raw), EXP_PASS, - (&qcow2_relback_absstart, &raw), ALLOW_PROBE | EXP_PASS); + (&rel_qcow2_as_raw), EXP_PASS, + (&qcow2_relback_relstart, &abs_raw), ALLOW_PROBE | EXP_PASS, + (&abs_qcow2_as_raw), EXP_PASS, + (&qcow2_relback_absstart, &abs_raw), ALLOW_PROBE | EXP_PASS); /* Rewrite qcow2 file to use absolute backing name */ virCommandFree(cmd); @@ -502,22 +613,22 @@ mymain(void) /* Qcow2 file with raw as absolute backing, backing format provided */ TEST_CHAIN(5, "qcow2", absqcow2, VIR_STORAGE_FILE_QCOW2, - (&qcow2_absback, &raw), EXP_PASS, - (&qcow2_absback, &raw), ALLOW_PROBE | EXP_PASS, - (&qcow2_absback, &raw), EXP_PASS, - (&qcow2_absback, &raw), ALLOW_PROBE | EXP_PASS); + (&rel_qcow2_absback, &abs_raw), EXP_PASS, + (&rel_qcow2_absback, &abs_raw), ALLOW_PROBE | EXP_PASS, + (&abs_qcow2_absback, &abs_raw), EXP_PASS, + (&abs_qcow2_absback, &abs_raw), ALLOW_PROBE | EXP_PASS); TEST_CHAIN(6, "qcow2", absqcow2, VIR_STORAGE_FILE_AUTO, - (&raw), EXP_PASS, - (&qcow2_absback, &raw), ALLOW_PROBE | EXP_PASS, - (&raw), EXP_PASS, - (&qcow2_absback, &raw), ALLOW_PROBE | EXP_PASS); + (&rel_qcow2_as_raw), EXP_PASS, + (&rel_qcow2_absback, &abs_raw), ALLOW_PROBE | EXP_PASS, + (&abs_qcow2_as_raw), EXP_PASS, + (&abs_qcow2_absback, &abs_raw), ALLOW_PROBE | EXP_PASS); /* Wrapped file access */ TEST_CHAIN(7, "wrap", abswrap, VIR_STORAGE_FILE_QCOW2, - (&wrap, &qcow2_absback, &raw), EXP_PASS, - (&wrap, &qcow2_absback, &raw), ALLOW_PROBE | EXP_PASS, - (&wrap, &qcow2_absback, &raw), EXP_PASS, - (&wrap, &qcow2_absback, &raw), ALLOW_PROBE | EXP_PASS); + (&rel_wrap, &abs_qcow2_absback, &abs_raw), EXP_PASS, + (&rel_wrap, &abs_qcow2_absback, &abs_raw), ALLOW_PROBE | EXP_PASS, + (&abs_wrap, &abs_qcow2_absback, &abs_raw), EXP_PASS, + (&abs_wrap, &abs_qcow2_absback, &abs_raw), ALLOW_PROBE | EXP_PASS); /* Rewrite qcow2 and wrap file to omit backing file type */ virCommandFree(cmd); @@ -534,10 +645,10 @@ mymain(void) /* Qcow2 file with raw as absolute backing, backing format omitted */ TEST_CHAIN(8, "wrap", abswrap, VIR_STORAGE_FILE_QCOW2, - (&wrap_as_raw, &raw), EXP_PASS, - (&wrap_as_probe, &qcow2_as_probe, &raw), ALLOW_PROBE | EXP_PASS, - (&wrap_as_raw, &raw), EXP_PASS, - (&wrap_as_probe, &qcow2_as_probe, &raw), ALLOW_PROBE | EXP_PASS); + (&rel_wrap_as_raw, &abs_qcow2_as_raw), EXP_PASS, + (&rel_wrap_as_probe, &qcow2_as_probe, &abs_raw), ALLOW_PROBE | EXP_PASS, + (&abs_wrap_as_raw, &abs_qcow2_as_raw), EXP_PASS, + (&abs_wrap_as_probe, &qcow2_as_probe, &abs_raw), ALLOW_PROBE | EXP_PASS); /* Rewrite qcow2 to a missing backing file, with backing type */ virCommandFree(cmd); @@ -549,10 +660,10 @@ mymain(void) /* Qcow2 file with missing backing file but specified type */ TEST_CHAIN(9, "qcow2", absqcow2, VIR_STORAGE_FILE_QCOW2, - (&qcow2_bogus), EXP_WARN, - (&qcow2_bogus), ALLOW_PROBE | EXP_WARN, - (&qcow2_bogus), EXP_WARN, - (&qcow2_bogus), ALLOW_PROBE | EXP_WARN); + (&rel_qcow2_bogus), EXP_WARN, + (&rel_qcow2_bogus), ALLOW_PROBE | EXP_WARN, + (&abs_qcow2_bogus), EXP_WARN, + (&abs_qcow2_bogus), ALLOW_PROBE | EXP_WARN); /* Rewrite qcow2 to a missing backing file, without backing type */ virCommandFree(cmd); @@ -563,10 +674,10 @@ mymain(void) /* Qcow2 file with missing backing file and no specified type */ TEST_CHAIN(10, "qcow2", absqcow2, VIR_STORAGE_FILE_QCOW2, - (&qcow2_bogus), EXP_WARN, - (&qcow2_bogus), ALLOW_PROBE | EXP_WARN, - (&qcow2_bogus), EXP_WARN, - (&qcow2_bogus), ALLOW_PROBE | EXP_WARN); + (&rel_qcow2_bogus), EXP_WARN, + (&rel_qcow2_bogus), ALLOW_PROBE | EXP_WARN, + (&abs_qcow2_bogus), EXP_WARN, + (&abs_qcow2_bogus), ALLOW_PROBE | EXP_WARN); /* Rewrite qcow2 to use an nbd: protocol as backend */ virCommandFree(cmd); @@ -578,17 +689,17 @@ mymain(void) /* Qcow2 file with backing protocol instead of file */ TEST_CHAIN(11, "qcow2", absqcow2, VIR_STORAGE_FILE_QCOW2, - (&qcow2_protocol), EXP_PASS, - (&qcow2_protocol), ALLOW_PROBE | EXP_PASS, - (&qcow2_protocol), EXP_PASS, - (&qcow2_protocol), ALLOW_PROBE | EXP_PASS); + (&rel_qcow2_protocol), EXP_PASS, + (&rel_qcow2_protocol), ALLOW_PROBE | EXP_PASS, + (&abs_qcow2_protocol), EXP_PASS, + (&abs_qcow2_protocol), ALLOW_PROBE | EXP_PASS); /* qed file */ TEST_CHAIN(12, "qed", absqed, VIR_STORAGE_FILE_AUTO, - (&raw), EXP_PASS, - (&qed, &raw), ALLOW_PROBE | EXP_PASS, - (&raw), EXP_PASS, - (&qed, &raw), ALLOW_PROBE | EXP_PASS); + (&rel_qed_as_raw), EXP_PASS, + (&rel_qed, &abs_raw), ALLOW_PROBE | EXP_PASS, + (&abs_qed_as_raw), EXP_PASS, + (&abs_qed, &abs_raw), ALLOW_PROBE | EXP_PASS); #ifdef HAVE_SYMLINK /* Rewrite qcow2 and wrap file to use backing names relative to a @@ -608,10 +719,10 @@ mymain(void) /* Behavior of symlinks to qcow2 with relative backing files */ TEST_CHAIN(13, "sub/link2", abslink2, VIR_STORAGE_FILE_QCOW2, - (&link2_rel, &link1_rel, &raw), EXP_PASS, - (&link2_rel, &link1_rel, &raw), ALLOW_PROBE | EXP_PASS, - (&link2_abs, &link1_abs, &raw), EXP_PASS, - (&link2_abs, &link1_abs, &raw), ALLOW_PROBE | EXP_PASS); + (&link2_rel, &link1_rel, &abs_raw), EXP_PASS, + (&link2_rel, &link1_rel, &abs_raw), ALLOW_PROBE | EXP_PASS, + (&link2_abs, &link1_abs, &abs_raw), EXP_PASS, + (&link2_abs, &link1_abs, &abs_raw), ALLOW_PROBE | EXP_PASS); #endif /* Final cleanup */ testCleanupImages(); -- 1.9.0 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list