[PATCH 00/24] virstoragetest: Re-instate testing of images without backing format

Most of the series are refactors to make virstoragetest less archaic, the last commit then re-introduces testing of images which don't have backing format recorded in the metadata which can't be formatted using qemu-img any more but have security implications if we'd mishandle them. Peter Krempa (24): virstoragetest: Drop testing of RBD backends via parsing real images virstoragetest: Drop testing of NBD backends via parsing real images testutils: Introduce helper for stripping bulilddir/srcdir from test outputs virstoragetest: Store output of TEST_CHAIN in output files virstoragetest: Remove redundant arguments for chain lookup tests virstoragetest: Rework TEST_LOOKUP* cases to work on fake backing chain virstoragetest: Test backing chain loops with hardcoded images virstoragetest: Use existing directory in the source tree for 'directory' probing tests virstoragetest: Use a pre-formatted QED file for testing backing store extraction virstoragetest: Use pre-formatted file for non-path extraction test virstoragetest: Use preformatted file for testing missing backing store virstoragetest: Use existing file for testing 'raw' image lookup virstoragetest: Convert symlink and relative image testing use preformatted images virstoragetest: Use preformatted qcow2 image for testing relative paths virstoragetest: Unify testing of QCOW2 images with absolute backing virstoragetest: Stop rewriting images in 'mymain' virstoragetest: Don't rewrite the 'qcow2' image virstoragetest: Assume that 'qemu-img' supports '-o compat=' virstoragetest: testPrepImages: Don't reuse 'cmd' pointer virstoragetest: testPrepImages: Use 'qemu-img' to format 'raw' image virstoragetest: testStorageChain: Skip test if filename is NULL virstoragetest: Don't skip the whole test when qemu-img fails to format images virstoragetest: Remove pointless goto from mymain virstoragetest: Reinstate testing of images without 'backing_fmt' build-aux/syntax-check.mk | 2 +- tests/testutils.c | 30 + tests/testutils.h | 3 + tests/virstoragetest.c | 906 ++++++------------ tests/virstoragetestdata/images/loop-1.qcow2 | Bin 0 -> 196616 bytes tests/virstoragetestdata/images/loop-2.qcow2 | Bin 0 -> 196616 bytes .../virstoragetestdata/images/loop-self.qcow2 | Bin 0 -> 196616 bytes tests/virstoragetestdata/images/qcow2 | Bin 0 -> 196616 bytes .../images/qcow2_nbd-raw.qcow2 | Bin 0 -> 196616 bytes .../images/qcow2_qcow2-auto.qcow2 | Bin 0 -> 196616 bytes .../images/qcow2_qcow2-auto_qcow2-auto.qcow2 | Bin 0 -> 196616 bytes .../images/qcow2_qcow2-missing.qcow2 | Bin 0 -> 196616 bytes ...2_qcow2-qcow2-symlink_raw-raw-reldir.qcow2 | Bin 0 -> 196616 bytes .../images/qcow2_qcow2-qcow2_qcow2-auto.qcow2 | Bin 0 -> 196616 bytes .../images/qcow2_qcow2-qcow2_raw-auto.qcow2 | Bin 0 -> 196616 bytes .../images/qcow2_raw-auto.qcow2 | Bin 0 -> 196616 bytes .../images/qcow2_raw-raw-relative.qcow2 | Bin 0 -> 196616 bytes .../images/qcow2_raw-raw-reldir.qcow2 | Bin 0 -> 196616 bytes .../images/qed_raw-raw-relative | Bin 0 -> 327680 bytes tests/virstoragetestdata/images/raw | Bin 0 -> 1024 bytes tests/virstoragetestdata/images/sub/link1 | 1 + tests/virstoragetestdata/images/sub/link2 | 1 + tests/virstoragetestdata/lookup/qcow2 | 0 tests/virstoragetestdata/lookup/raw | 0 tests/virstoragetestdata/lookup/sub/link2 | 1 + tests/virstoragetestdata/lookup/wrap | 0 tests/virstoragetestdata/out/directory-dir | 9 + tests/virstoragetestdata/out/directory-none | 9 + tests/virstoragetestdata/out/directory-raw | 9 + .../out/qcow2-auto_qcow2-qcow2_raw-raw | 9 + .../out/qcow2-auto_raw-raw-relative | 9 + .../out/qcow2-qcow2_nbd-raw | 19 + .../out/qcow2-qcow2_qcow2-auto | 19 + .../out/qcow2-qcow2_qcow2-qcow2_qcow2-auto | 29 + .../out/qcow2-qcow2_qcow2-qcow2_raw-auto | 29 + .../out/qcow2-qcow2_qcow2-qcow2_raw-raw | 29 + .../out/qcow2-qcow2_raw-raw-relative | 19 + tests/virstoragetestdata/out/qcow2-symlinks | 29 + tests/virstoragetestdata/out/qed-auto_raw | 9 + tests/virstoragetestdata/out/qed-qed_raw | 19 + tests/virstoragetestdata/out/raw-auto | 9 + tests/virstoragetestdata/out/raw-raw | 9 + 42 files changed, 580 insertions(+), 628 deletions(-) create mode 100644 tests/virstoragetestdata/images/loop-1.qcow2 create mode 100644 tests/virstoragetestdata/images/loop-2.qcow2 create mode 100644 tests/virstoragetestdata/images/loop-self.qcow2 create mode 100644 tests/virstoragetestdata/images/qcow2 create mode 100644 tests/virstoragetestdata/images/qcow2_nbd-raw.qcow2 create mode 100644 tests/virstoragetestdata/images/qcow2_qcow2-auto.qcow2 create mode 100644 tests/virstoragetestdata/images/qcow2_qcow2-auto_qcow2-auto.qcow2 create mode 100644 tests/virstoragetestdata/images/qcow2_qcow2-missing.qcow2 create mode 100644 tests/virstoragetestdata/images/qcow2_qcow2-qcow2-symlink_raw-raw-reldir.qcow2 create mode 100644 tests/virstoragetestdata/images/qcow2_qcow2-qcow2_qcow2-auto.qcow2 create mode 100644 tests/virstoragetestdata/images/qcow2_qcow2-qcow2_raw-auto.qcow2 create mode 100644 tests/virstoragetestdata/images/qcow2_raw-auto.qcow2 create mode 100644 tests/virstoragetestdata/images/qcow2_raw-raw-relative.qcow2 create mode 100644 tests/virstoragetestdata/images/qcow2_raw-raw-reldir.qcow2 create mode 100644 tests/virstoragetestdata/images/qed_raw-raw-relative create mode 100644 tests/virstoragetestdata/images/raw create mode 120000 tests/virstoragetestdata/images/sub/link1 create mode 120000 tests/virstoragetestdata/images/sub/link2 create mode 100644 tests/virstoragetestdata/lookup/qcow2 create mode 100644 tests/virstoragetestdata/lookup/raw create mode 120000 tests/virstoragetestdata/lookup/sub/link2 create mode 100644 tests/virstoragetestdata/lookup/wrap create mode 100644 tests/virstoragetestdata/out/directory-dir create mode 100644 tests/virstoragetestdata/out/directory-none create mode 100644 tests/virstoragetestdata/out/directory-raw create mode 100644 tests/virstoragetestdata/out/qcow2-auto_qcow2-qcow2_raw-raw create mode 100644 tests/virstoragetestdata/out/qcow2-auto_raw-raw-relative create mode 100644 tests/virstoragetestdata/out/qcow2-qcow2_nbd-raw create mode 100644 tests/virstoragetestdata/out/qcow2-qcow2_qcow2-auto create mode 100644 tests/virstoragetestdata/out/qcow2-qcow2_qcow2-qcow2_qcow2-auto create mode 100644 tests/virstoragetestdata/out/qcow2-qcow2_qcow2-qcow2_raw-auto create mode 100644 tests/virstoragetestdata/out/qcow2-qcow2_qcow2-qcow2_raw-raw create mode 100644 tests/virstoragetestdata/out/qcow2-qcow2_raw-raw-relative create mode 100644 tests/virstoragetestdata/out/qcow2-symlinks create mode 100644 tests/virstoragetestdata/out/qed-auto_raw create mode 100644 tests/virstoragetestdata/out/qed-qed_raw create mode 100644 tests/virstoragetestdata/out/raw-auto create mode 100644 tests/virstoragetestdata/out/raw-raw -- 2.31.1

We now have specific tests for the backing store parser and previous tests cover the extraction of the backing store string so there's no need for these particular tests. Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- tests/virstoragetest.c | 38 -------------------------------------- 1 file changed, 38 deletions(-) diff --git a/tests/virstoragetest.c b/tests/virstoragetest.c index b80818bc7b..ab34f2f3be 100644 --- a/tests/virstoragetest.c +++ b/tests/virstoragetest.c @@ -799,44 +799,6 @@ mymain(void) /* Behavior of an infinite loop chain */ TEST_CHAIN(abswrap, VIR_STORAGE_FILE_QCOW2, (&wrap, &qcow2), EXP_FAIL); - /* Rewrite qcow2 to use an rbd: protocol as backend */ - virCommandFree(cmd); - cmd = virCommandNewArgList(qemuimg, "rebase", "-u", "-f", "qcow2", - "-F", "raw", "-b", "rbd:testshare", - "qcow2", NULL); - if (virCommandRun(cmd, NULL) < 0) - ret = -1; - qcow2.expBackingStoreRaw = "rbd:testshare"; - - /* Qcow2 file with backing protocol instead of file */ - testFileData rbd1 = { - .path = "testshare", - .type = VIR_STORAGE_TYPE_NETWORK, - .format = VIR_STORAGE_FILE_RAW, - .protocol = VIR_STORAGE_NET_PROTOCOL_RBD, - }; - TEST_CHAIN(absqcow2, VIR_STORAGE_FILE_QCOW2, (&qcow2, &rbd1), EXP_PASS); - - /* Rewrite qcow2 to use an rbd: protocol as backend */ - virCommandFree(cmd); - cmd = virCommandNewArgList(qemuimg, "rebase", "-u", "-f", "qcow2", - "-F", "raw", "-b", "rbd:testshare:id=asdf:mon_host=example.com", - "qcow2", NULL); - if (virCommandRun(cmd, NULL) < 0) - ret = -1; - qcow2.expBackingStoreRaw = "rbd:testshare:id=asdf:mon_host=example.com"; - - /* Qcow2 file with backing protocol instead of file */ - testFileData rbd2 = { - .path = "testshare", - .type = VIR_STORAGE_TYPE_NETWORK, - .format = VIR_STORAGE_FILE_RAW, - .protocol = VIR_STORAGE_NET_PROTOCOL_RBD, - .secret = "asdf", - .hostname = "example.com", - }; - TEST_CHAIN(absqcow2, VIR_STORAGE_FILE_QCOW2, (&qcow2, &rbd2), EXP_PASS); - VIR_WARNINGS_RESET /* Rewrite wrap and qcow2 back to 3-deep chain, absolute backing */ -- 2.31.1

We now have specific tests for the backing store parser and previous tests cover the extraction of the backing store string so there's no need for these particular tests. Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- tests/virstoragetest.c | 31 ------------------------------- 1 file changed, 31 deletions(-) diff --git a/tests/virstoragetest.c b/tests/virstoragetest.c index ab34f2f3be..f6af1a17ac 100644 --- a/tests/virstoragetest.c +++ b/tests/virstoragetest.c @@ -651,25 +651,6 @@ mymain(void) TEST_CHAIN(absqcow2, VIR_STORAGE_FILE_QCOW2, (&qcow2), EXP_FAIL); - /* Rewrite qcow2 to use an nbd: protocol as backend */ - virCommandFree(cmd); - cmd = virCommandNewArgList(qemuimg, "rebase", "-u", "-f", "qcow2", - "-F", "raw", "-b", "nbd:example.org:6000:exportname=blah", - "qcow2", NULL); - if (virCommandRun(cmd, NULL) < 0) - ret = -1; - qcow2.expBackingStoreRaw = "nbd:example.org:6000:exportname=blah"; - - /* Qcow2 file with backing protocol instead of file */ - testFileData nbd = { - .path = "blah", - .type = VIR_STORAGE_TYPE_NETWORK, - .format = VIR_STORAGE_FILE_RAW, - .protocol = VIR_STORAGE_NET_PROTOCOL_NBD, - .hostname = "example.org", - }; - TEST_CHAIN(absqcow2, VIR_STORAGE_FILE_QCOW2, (&qcow2, &nbd), EXP_PASS); - /* Rewrite qcow2 to use an nbd: protocol as backend */ virCommandFree(cmd); cmd = virCommandNewArgList(qemuimg, "rebase", "-u", "-f", "qcow2", @@ -689,18 +670,6 @@ mymain(void) }; TEST_CHAIN(absqcow2, VIR_STORAGE_FILE_QCOW2, (&qcow2, &nbd2), EXP_PASS); - /* Rewrite qcow2 to use an nbd: protocol without path as backend */ - virCommandFree(cmd); - cmd = virCommandNewArgList(qemuimg, "rebase", "-u", "-f", "qcow2", - "-F", "raw", "-b", "nbd://example.org", - "qcow2", NULL); - if (virCommandRun(cmd, NULL) < 0) - ret = -1; - qcow2.expBackingStoreRaw = "nbd://example.org"; - - nbd2.path = NULL; - TEST_CHAIN(absqcow2, VIR_STORAGE_FILE_QCOW2, (&qcow2, &nbd2), EXP_PASS); - /* qed file */ testFileData qed = { .expBackingStoreRaw = absraw, -- 2.31.1

In certain cases we want to be able to compare test output containing real paths against a static output file and thus we need a helper which strips srcdir/builddir from given path. Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- tests/testutils.c | 30 ++++++++++++++++++++++++++++++ tests/testutils.h | 3 +++ 2 files changed, 33 insertions(+) diff --git a/tests/testutils.c b/tests/testutils.c index 5e9835ee89..185d281e96 100644 --- a/tests/testutils.c +++ b/tests/testutils.c @@ -1117,3 +1117,33 @@ const char return virtTestCounterStr; } + + +/** + * virTestStablePath: + * @path: path to make stable + * + * If @path starts with the absolute source directory path, the prefix + * is replaced with the string "ABS_SRCDIR" and similarly the build directory + * is replaced by "ABS_BUILDDIR". This is useful when paths e.g. in output + * test files need to be made stable. + * + * If @path is NULL the equivalent to NULLSTR(path) is returned. + * + * The caller is responsible for freeing the returned buffer. + */ +char * +virTestStablePath(const char *path) +{ + const char *tmp; + + path = NULLSTR(path); + + if ((tmp = STRSKIP(path, abs_srcdir))) + return g_strdup_printf("ABS_SRCDIR%s", tmp); + + if ((tmp = STRSKIP(path, abs_builddir))) + return g_strdup_printf("ABS_BUILDDIR%s", tmp); + + return g_strdup(path); +} diff --git a/tests/testutils.h b/tests/testutils.h index 48de864131..27d135fc02 100644 --- a/tests/testutils.h +++ b/tests/testutils.h @@ -170,3 +170,6 @@ int testCompareDomXML2XMLFiles(virCaps *caps, bool live, unsigned int parseFlags, testCompareDomXML2XMLResult expectResult); + +char * +virTestStablePath(const char *path); -- 2.31.1

The TEST_CHAIN cases were storing the expected output (or rather data to generate the expected output) in code. This made the code really hard to follow and even harder to modify to add new cases. This patch modifies the code to store the expected output in text files (using the same generator as we've used to) and uses 'virTestCompareToFile' to check the outputs. The result is that the code is way simpler and doesn't require fiddling with 'testFileData' structs when adding new cases. Additionally this removes mixing of code and declaration so we can stop disabling the warning for this file. Another advantage is that the tests are now named so it's easier to figure out if one of them breaks. Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- tests/virstoragetest.c | 252 ++++-------------- tests/virstoragetestdata/out/directory-dir | 9 + tests/virstoragetestdata/out/directory-none | 9 + tests/virstoragetestdata/out/directory-raw | 9 + .../virstoragetestdata/out/qcow2-auto_raw-raw | 9 + .../out/qcow2-auto_raw-raw-relative | 9 + .../out/qcow2-qcow2_nbd-raw | 19 ++ .../out/qcow2-qcow2_qcow2-qcow2_raw-raw | 29 ++ .../out/qcow2-qcow2_raw-raw | 19 ++ .../out/qcow2-qcow2_raw-raw-relative | 19 ++ tests/virstoragetestdata/out/qcow2-symlinks | 29 ++ tests/virstoragetestdata/out/qed-auto_raw | 9 + tests/virstoragetestdata/out/qed-qed_raw | 19 ++ tests/virstoragetestdata/out/raw-auto | 9 + tests/virstoragetestdata/out/raw-raw | 9 + 15 files changed, 263 insertions(+), 195 deletions(-) create mode 100644 tests/virstoragetestdata/out/directory-dir create mode 100644 tests/virstoragetestdata/out/directory-none create mode 100644 tests/virstoragetestdata/out/directory-raw create mode 100644 tests/virstoragetestdata/out/qcow2-auto_raw-raw create mode 100644 tests/virstoragetestdata/out/qcow2-auto_raw-raw-relative create mode 100644 tests/virstoragetestdata/out/qcow2-qcow2_nbd-raw create mode 100644 tests/virstoragetestdata/out/qcow2-qcow2_qcow2-qcow2_raw-raw create mode 100644 tests/virstoragetestdata/out/qcow2-qcow2_raw-raw create mode 100644 tests/virstoragetestdata/out/qcow2-qcow2_raw-raw-relative create mode 100644 tests/virstoragetestdata/out/qcow2-symlinks create mode 100644 tests/virstoragetestdata/out/qed-auto_raw create mode 100644 tests/virstoragetestdata/out/qed-qed_raw create mode 100644 tests/virstoragetestdata/out/raw-auto create mode 100644 tests/virstoragetestdata/out/raw-raw diff --git a/tests/virstoragetest.c b/tests/virstoragetest.c index f6af1a17ac..4f4fd4e824 100644 --- a/tests/virstoragetest.c +++ b/tests/virstoragetest.c @@ -218,26 +218,6 @@ testPrepImages(void) goto cleanup; } -/* Many fields of virStorageFileMetadata have the same content whether - * we access the file relatively or absolutely; but file names differ - * depending on how the chain was opened. For ease of testing, we - * test both relative and absolute starts, and use a flag to say which - * of the two variations to compare against. */ -typedef struct _testFileData testFileData; -struct _testFileData -{ - const char *expBackingStoreRaw; - unsigned long long expCapacity; - bool expEncrypted; - const char *pathRel; - const char *path; - int type; - int format; - const char *secret; - const char *hostname; - int protocol; -}; - enum { EXP_PASS = 0, EXP_FAIL = 1, @@ -245,33 +225,23 @@ enum { struct testChainData { + const char *testname; const char *start; virStorageFileFormat format; - const testFileData *files[4]; - int nfiles; unsigned int flags; }; -static const char testStorageChainFormat[] = - "chain member: %zu\n" - "path:%s\n" - "backingStoreRaw: %s\n" - "capacity: %lld\n" - "encryption: %d\n" - "relPath:%s\n" - "type:%d\n" - "format:%d\n" - "protocol:%s\n" - "hostname:%s\n"; - static int testStorageChain(const void *args) { const struct testChainData *data = args; virStorageSource *elt; - size_t i = 0; g_autoptr(virStorageSource) meta = NULL; + g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER; + g_autofree char *actual = NULL; + g_autofree char *expectpath = g_strdup_printf("%s/virstoragetestdata/out/%s", + abs_srcdir, data->testname); meta = testStorageFileGetMetadata(data->start, data->format, -1, -1); if (!meta) { @@ -290,47 +260,38 @@ testStorageChain(const void *args) return -1; } - elt = meta; - while (virStorageSourceIsBacking(elt)) { - g_autofree char *expect = NULL; - g_autofree char *actual = NULL; + for (elt = meta; virStorageSourceIsBacking(elt); elt = elt->backingStore) { + g_autofree char *strippedPath = virTestStablePath(elt->path); + g_autofree char *strippedBackingStoreRaw = virTestStablePath(elt->backingStoreRaw); + g_autofree char *strippedRelPath = virTestStablePath(elt->relPath); + + virBufferAsprintf(&buf, + "path:%s\n" + "backingStoreRaw: %s\n" + "capacity: %lld\n" + "encryption: %d\n" + "relPath:%s\n" + "type:%d\n" + "format:%d\n" + "protocol:%s\n" + "hostname:%s\n\n", + strippedPath, + strippedBackingStoreRaw, + elt->capacity, + !!elt->encryption, + strippedRelPath, + elt->type, + elt->format, + virStorageNetProtocolTypeToString(elt->protocol), + NULLSTR(elt->nhosts ? elt->hosts[0].name : NULL)); + } - if (i == data->nfiles) { - fprintf(stderr, "probed chain was too long\n"); - return -1; - } + virBufferTrim(&buf, "\n"); - expect = g_strdup_printf(testStorageChainFormat, i, - NULLSTR(data->files[i]->path), - NULLSTR(data->files[i]->expBackingStoreRaw), - data->files[i]->expCapacity, - data->files[i]->expEncrypted, - NULLSTR(data->files[i]->pathRel), - data->files[i]->type, - data->files[i]->format, - virStorageNetProtocolTypeToString(data->files[i]->protocol), - NULLSTR(data->files[i]->hostname)); - actual = g_strdup_printf(testStorageChainFormat, i, - NULLSTR(elt->path), - NULLSTR(elt->backingStoreRaw), - elt->capacity, - !!elt->encryption, - NULLSTR(elt->relPath), - elt->type, - elt->format, - virStorageNetProtocolTypeToString(elt->protocol), - NULLSTR(elt->nhosts ? elt->hosts[0].name : NULL)); - if (STRNEQ(expect, actual)) { - virTestDifference(stderr, expect, actual); - return -1; - } - elt = elt->backingStore; - i++; - } - if (i != data->nfiles) { - fprintf(stderr, "probed chain was too short\n"); + actual = virBufferContentAndReset(&buf); + + if (virTestCompareToFile(actual, expectpath) < 0) return -1; - } return 0; } @@ -561,59 +522,23 @@ mymain(void) if ((ret = testPrepImages()) != 0) return ret; -#define TEST_ONE_CHAIN(start, format, flags, ...) \ +#define TEST_CHAIN(testname, start, format, flags) \ do { \ - size_t i; \ - memset(&data, 0, sizeof(data)); \ - data = (struct testChainData){ \ - start, format, { __VA_ARGS__ }, 0, flags, \ - }; \ - for (i = 0; i < G_N_ELEMENTS(data.files); i++) \ - if (data.files[i]) \ - data.nfiles++; \ - if (virTestRun(virTestCounterNext(), \ - testStorageChain, &data) < 0) \ + data = (struct testChainData){ testname, start, format, flags }; \ + if (virTestRun(testname, testStorageChain, &data) < 0) \ ret = -1; \ } while (0) -#define VIR_FLATTEN_2(...) __VA_ARGS__ -#define VIR_FLATTEN_1(_1) VIR_FLATTEN_2 _1 - -#define TEST_CHAIN(path, format, chain, flags) \ - TEST_ONE_CHAIN(path, format, flags, VIR_FLATTEN_1(chain)); - - /* The actual tests, in several groups. */ - virTestCounterReset("Storage backing chain "); - /* Missing file */ - TEST_ONE_CHAIN("bogus", VIR_STORAGE_FILE_RAW, EXP_FAIL); + TEST_CHAIN("missing", "bogus", VIR_STORAGE_FILE_RAW, EXP_FAIL); - VIR_WARNINGS_NO_DECLARATION_AFTER_STATEMENT /* Raw image, whether with right format or no specified format */ - testFileData raw = { - .path = absraw, - .type = VIR_STORAGE_TYPE_FILE, - .format = VIR_STORAGE_FILE_RAW, - }; - TEST_CHAIN(absraw, VIR_STORAGE_FILE_RAW, (&raw), EXP_PASS); - TEST_CHAIN(absraw, VIR_STORAGE_FILE_AUTO, (&raw), EXP_PASS); + TEST_CHAIN("raw-raw", absraw, VIR_STORAGE_FILE_RAW, EXP_PASS); + TEST_CHAIN("raw-auto", absraw, VIR_STORAGE_FILE_AUTO, EXP_PASS); /* Qcow2 file with relative raw backing, format provided */ - raw.pathRel = "raw"; - testFileData qcow2 = { - .expBackingStoreRaw = "raw", - .expCapacity = 1024, - .path = absqcow2, - .type = VIR_STORAGE_TYPE_FILE, - .format = VIR_STORAGE_FILE_QCOW2, - }; - testFileData qcow2_as_raw = { - .path = absqcow2, - .type = VIR_STORAGE_TYPE_FILE, - .format = VIR_STORAGE_FILE_RAW, - }; - TEST_CHAIN(absqcow2, VIR_STORAGE_FILE_QCOW2, (&qcow2, &raw), EXP_PASS); - TEST_CHAIN(absqcow2, VIR_STORAGE_FILE_AUTO, (&qcow2_as_raw), EXP_PASS); + TEST_CHAIN("qcow2-qcow2_raw-raw-relative", absqcow2, VIR_STORAGE_FILE_QCOW2, EXP_PASS); + TEST_CHAIN("qcow2-auto_raw-raw-relative", absqcow2, VIR_STORAGE_FILE_AUTO, EXP_PASS); /* Rewrite qcow2 file to use absolute backing name */ virCommandFree(cmd); @@ -621,22 +546,13 @@ mymain(void) "-F", "raw", "-b", absraw, "qcow2", NULL); if (virCommandRun(cmd, NULL) < 0) ret = -1; - qcow2.expBackingStoreRaw = absraw; - raw.pathRel = NULL; /* Qcow2 file with raw as absolute backing, backing format provided */ - TEST_CHAIN(absqcow2, VIR_STORAGE_FILE_QCOW2, (&qcow2, &raw), EXP_PASS); - TEST_CHAIN(absqcow2, VIR_STORAGE_FILE_AUTO, (&qcow2_as_raw), EXP_PASS); - - /* Wrapped file access */ - testFileData wrap = { - .expBackingStoreRaw = absqcow2, - .expCapacity = 1024, - .path = abswrap, - .type = VIR_STORAGE_TYPE_FILE, - .format = VIR_STORAGE_FILE_QCOW2, - }; - TEST_CHAIN(abswrap, VIR_STORAGE_FILE_QCOW2, (&wrap, &qcow2, &raw), EXP_PASS); + TEST_CHAIN("qcow2-qcow2_raw-raw", absqcow2, VIR_STORAGE_FILE_QCOW2, EXP_PASS); + TEST_CHAIN("qcow2-auto_raw-raw", absqcow2, VIR_STORAGE_FILE_AUTO, EXP_PASS); + + /* qcow2 with a longer backing chain */ + TEST_CHAIN("qcow2-qcow2_qcow2-qcow2_raw-raw", abswrap, VIR_STORAGE_FILE_QCOW2, EXP_PASS); /* Rewrite qcow2 to a missing backing file, with backing type */ virCommandFree(cmd); @@ -645,10 +561,9 @@ mymain(void) "qcow2", NULL); if (virCommandRun(cmd, NULL) < 0) ret = -1; - qcow2.expBackingStoreRaw = datadir "/bogus"; /* Qcow2 file with missing backing file but specified type */ - TEST_CHAIN(absqcow2, VIR_STORAGE_FILE_QCOW2, (&qcow2), EXP_FAIL); + TEST_CHAIN("qcow2-qcow2_missing", absqcow2, VIR_STORAGE_FILE_QCOW2, EXP_FAIL); /* Rewrite qcow2 to use an nbd: protocol as backend */ @@ -658,48 +573,18 @@ mymain(void) "qcow2", NULL); if (virCommandRun(cmd, NULL) < 0) ret = -1; - qcow2.expBackingStoreRaw = "nbd+tcp://example.org:6000/blah"; /* Qcow2 file with backing protocol instead of file */ - testFileData nbd2 = { - .path = "blah", - .type = VIR_STORAGE_TYPE_NETWORK, - .format = VIR_STORAGE_FILE_RAW, - .protocol = VIR_STORAGE_NET_PROTOCOL_NBD, - .hostname = "example.org", - }; - TEST_CHAIN(absqcow2, VIR_STORAGE_FILE_QCOW2, (&qcow2, &nbd2), EXP_PASS); + TEST_CHAIN("qcow2-qcow2_nbd-raw", absqcow2, VIR_STORAGE_FILE_QCOW2, EXP_PASS); /* qed file */ - testFileData qed = { - .expBackingStoreRaw = absraw, - .expCapacity = 1024, - .path = absqed, - .type = VIR_STORAGE_TYPE_FILE, - .format = VIR_STORAGE_FILE_QED, - }; - testFileData qed_as_raw = { - .path = absqed, - .type = VIR_STORAGE_TYPE_FILE, - .format = VIR_STORAGE_FILE_RAW, - }; - TEST_CHAIN(absqed, VIR_STORAGE_FILE_QED, (&qed, &raw), EXP_PASS); - TEST_CHAIN(absqed, VIR_STORAGE_FILE_AUTO, (&qed_as_raw), EXP_PASS); + TEST_CHAIN("qed-qed_raw", absqed, VIR_STORAGE_FILE_QED, EXP_PASS); + TEST_CHAIN("qed-auto_raw", absqed, VIR_STORAGE_FILE_AUTO, EXP_PASS); /* directory */ - testFileData dir = { - .path = absdir, - .type = VIR_STORAGE_TYPE_DIR, - .format = VIR_STORAGE_FILE_DIR, - }; - testFileData dir_as_raw = { - .path = absdir, - .type = VIR_STORAGE_TYPE_DIR, - .format = VIR_STORAGE_FILE_RAW, - }; - TEST_CHAIN(absdir, VIR_STORAGE_FILE_RAW, (&dir_as_raw), EXP_PASS); - TEST_CHAIN(absdir, VIR_STORAGE_FILE_NONE, (&dir), EXP_PASS); - TEST_CHAIN(absdir, VIR_STORAGE_FILE_DIR, (&dir), EXP_PASS); + TEST_CHAIN("directory-raw", absdir, VIR_STORAGE_FILE_RAW, EXP_PASS); + TEST_CHAIN("directory-none", absdir, VIR_STORAGE_FILE_NONE, EXP_PASS); + TEST_CHAIN("directory-dir", absdir, VIR_STORAGE_FILE_DIR, EXP_PASS); #ifdef WITH_SYMLINK /* Rewrite qcow2 and wrap file to use backing names relative to a @@ -718,26 +603,7 @@ mymain(void) ret = -1; /* Behavior of symlinks to qcow2 with relative backing files */ - testFileData link1 = { - .expBackingStoreRaw = "../raw", - .expCapacity = 1024, - .pathRel = "../sub/link1", - .path = datadir "/sub/../sub/link1", - .type = VIR_STORAGE_TYPE_FILE, - .format = VIR_STORAGE_FILE_QCOW2, - }; - testFileData link2 = { - .expBackingStoreRaw = "../sub/link1", - .expCapacity = 1024, - .path = abslink2, - .type = VIR_STORAGE_TYPE_FILE, - .format = VIR_STORAGE_FILE_QCOW2, - }; - - raw.path = datadir "/sub/../sub/../raw"; - raw.pathRel = "../raw"; - TEST_CHAIN(abslink2, VIR_STORAGE_FILE_QCOW2, - (&link2, &link1, &raw), EXP_PASS); + TEST_CHAIN("qcow2-symlinks", abslink2, VIR_STORAGE_FILE_QCOW2, EXP_PASS); #endif /* Rewrite qcow2 to be a self-referential loop */ @@ -746,10 +612,9 @@ mymain(void) "-F", "qcow2", "-b", "qcow2", "qcow2", NULL); if (virCommandRun(cmd, NULL) < 0) ret = -1; - qcow2.expBackingStoreRaw = "qcow2"; /* Behavior of an infinite loop chain */ - TEST_CHAIN(absqcow2, VIR_STORAGE_FILE_QCOW2, (&qcow2), EXP_FAIL); + TEST_CHAIN("qcow2-qcow2_infinite-self", absqcow2, VIR_STORAGE_FILE_QCOW2, EXP_FAIL); /* Rewrite wrap and qcow2 to be mutually-referential loop */ virCommandFree(cmd); @@ -763,12 +628,9 @@ mymain(void) "-F", "qcow2", "-b", absqcow2, "wrap", NULL); if (virCommandRun(cmd, NULL) < 0) ret = -1; - qcow2.expBackingStoreRaw = "wrap"; /* Behavior of an infinite loop chain */ - TEST_CHAIN(abswrap, VIR_STORAGE_FILE_QCOW2, (&wrap, &qcow2), EXP_FAIL); - - VIR_WARNINGS_RESET + TEST_CHAIN("qcow2-qcow2_infinite-mutual", abswrap, VIR_STORAGE_FILE_QCOW2, EXP_FAIL); /* Rewrite wrap and qcow2 back to 3-deep chain, absolute backing */ virCommandFree(cmd); diff --git a/tests/virstoragetestdata/out/directory-dir b/tests/virstoragetestdata/out/directory-dir new file mode 100644 index 0000000000..cff67595b4 --- /dev/null +++ b/tests/virstoragetestdata/out/directory-dir @@ -0,0 +1,9 @@ +path:ABS_BUILDDIR/virstoragedata/dir +backingStoreRaw: <null> +capacity: 0 +encryption: 0 +relPath:<null> +type:3 +format:2 +protocol:none +hostname:<null> diff --git a/tests/virstoragetestdata/out/directory-none b/tests/virstoragetestdata/out/directory-none new file mode 100644 index 0000000000..cff67595b4 --- /dev/null +++ b/tests/virstoragetestdata/out/directory-none @@ -0,0 +1,9 @@ +path:ABS_BUILDDIR/virstoragedata/dir +backingStoreRaw: <null> +capacity: 0 +encryption: 0 +relPath:<null> +type:3 +format:2 +protocol:none +hostname:<null> diff --git a/tests/virstoragetestdata/out/directory-raw b/tests/virstoragetestdata/out/directory-raw new file mode 100644 index 0000000000..ebe23cbbd6 --- /dev/null +++ b/tests/virstoragetestdata/out/directory-raw @@ -0,0 +1,9 @@ +path:ABS_BUILDDIR/virstoragedata/dir +backingStoreRaw: <null> +capacity: 0 +encryption: 0 +relPath:<null> +type:3 +format:1 +protocol:none +hostname:<null> diff --git a/tests/virstoragetestdata/out/qcow2-auto_raw-raw b/tests/virstoragetestdata/out/qcow2-auto_raw-raw new file mode 100644 index 0000000000..4a01b24589 --- /dev/null +++ b/tests/virstoragetestdata/out/qcow2-auto_raw-raw @@ -0,0 +1,9 @@ +path:ABS_BUILDDIR/virstoragedata/qcow2 +backingStoreRaw: <null> +capacity: 0 +encryption: 0 +relPath:<null> +type:1 +format:1 +protocol:none +hostname:<null> diff --git a/tests/virstoragetestdata/out/qcow2-auto_raw-raw-relative b/tests/virstoragetestdata/out/qcow2-auto_raw-raw-relative new file mode 100644 index 0000000000..4a01b24589 --- /dev/null +++ b/tests/virstoragetestdata/out/qcow2-auto_raw-raw-relative @@ -0,0 +1,9 @@ +path:ABS_BUILDDIR/virstoragedata/qcow2 +backingStoreRaw: <null> +capacity: 0 +encryption: 0 +relPath:<null> +type:1 +format:1 +protocol:none +hostname:<null> diff --git a/tests/virstoragetestdata/out/qcow2-qcow2_nbd-raw b/tests/virstoragetestdata/out/qcow2-qcow2_nbd-raw new file mode 100644 index 0000000000..64acdb880a --- /dev/null +++ b/tests/virstoragetestdata/out/qcow2-qcow2_nbd-raw @@ -0,0 +1,19 @@ +path:ABS_BUILDDIR/virstoragedata/qcow2 +backingStoreRaw: nbd+tcp://example.org:6000/blah +capacity: 1024 +encryption: 0 +relPath:<null> +type:1 +format:14 +protocol:none +hostname:<null> + +path:blah +backingStoreRaw: <null> +capacity: 0 +encryption: 0 +relPath:<null> +type:4 +format:1 +protocol:nbd +hostname:example.org diff --git a/tests/virstoragetestdata/out/qcow2-qcow2_qcow2-qcow2_raw-raw b/tests/virstoragetestdata/out/qcow2-qcow2_qcow2-qcow2_raw-raw new file mode 100644 index 0000000000..5f93fe746b --- /dev/null +++ b/tests/virstoragetestdata/out/qcow2-qcow2_qcow2-qcow2_raw-raw @@ -0,0 +1,29 @@ +path:ABS_BUILDDIR/virstoragedata/wrap +backingStoreRaw: ABS_BUILDDIR/virstoragedata/qcow2 +capacity: 1024 +encryption: 0 +relPath:<null> +type:1 +format:14 +protocol:none +hostname:<null> + +path:ABS_BUILDDIR/virstoragedata/qcow2 +backingStoreRaw: ABS_BUILDDIR/virstoragedata/raw +capacity: 1024 +encryption: 0 +relPath:<null> +type:1 +format:14 +protocol:none +hostname:<null> + +path:ABS_BUILDDIR/virstoragedata/raw +backingStoreRaw: <null> +capacity: 0 +encryption: 0 +relPath:<null> +type:1 +format:1 +protocol:none +hostname:<null> diff --git a/tests/virstoragetestdata/out/qcow2-qcow2_raw-raw b/tests/virstoragetestdata/out/qcow2-qcow2_raw-raw new file mode 100644 index 0000000000..57ce62a376 --- /dev/null +++ b/tests/virstoragetestdata/out/qcow2-qcow2_raw-raw @@ -0,0 +1,19 @@ +path:ABS_BUILDDIR/virstoragedata/qcow2 +backingStoreRaw: ABS_BUILDDIR/virstoragedata/raw +capacity: 1024 +encryption: 0 +relPath:<null> +type:1 +format:14 +protocol:none +hostname:<null> + +path:ABS_BUILDDIR/virstoragedata/raw +backingStoreRaw: <null> +capacity: 0 +encryption: 0 +relPath:<null> +type:1 +format:1 +protocol:none +hostname:<null> diff --git a/tests/virstoragetestdata/out/qcow2-qcow2_raw-raw-relative b/tests/virstoragetestdata/out/qcow2-qcow2_raw-raw-relative new file mode 100644 index 0000000000..a1fb142e98 --- /dev/null +++ b/tests/virstoragetestdata/out/qcow2-qcow2_raw-raw-relative @@ -0,0 +1,19 @@ +path:ABS_BUILDDIR/virstoragedata/qcow2 +backingStoreRaw: raw +capacity: 1024 +encryption: 0 +relPath:<null> +type:1 +format:14 +protocol:none +hostname:<null> + +path:ABS_BUILDDIR/virstoragedata/raw +backingStoreRaw: <null> +capacity: 0 +encryption: 0 +relPath:raw +type:1 +format:1 +protocol:none +hostname:<null> diff --git a/tests/virstoragetestdata/out/qcow2-symlinks b/tests/virstoragetestdata/out/qcow2-symlinks new file mode 100644 index 0000000000..ed37f61e9f --- /dev/null +++ b/tests/virstoragetestdata/out/qcow2-symlinks @@ -0,0 +1,29 @@ +path:ABS_BUILDDIR/virstoragedata/sub/link2 +backingStoreRaw: ../sub/link1 +capacity: 1024 +encryption: 0 +relPath:<null> +type:1 +format:14 +protocol:none +hostname:<null> + +path:ABS_BUILDDIR/virstoragedata/sub/../sub/link1 +backingStoreRaw: ../raw +capacity: 1024 +encryption: 0 +relPath:../sub/link1 +type:1 +format:14 +protocol:none +hostname:<null> + +path:ABS_BUILDDIR/virstoragedata/sub/../sub/../raw +backingStoreRaw: <null> +capacity: 0 +encryption: 0 +relPath:../raw +type:1 +format:1 +protocol:none +hostname:<null> diff --git a/tests/virstoragetestdata/out/qed-auto_raw b/tests/virstoragetestdata/out/qed-auto_raw new file mode 100644 index 0000000000..e8ab498038 --- /dev/null +++ b/tests/virstoragetestdata/out/qed-auto_raw @@ -0,0 +1,9 @@ +path:ABS_BUILDDIR/virstoragedata/qed +backingStoreRaw: <null> +capacity: 0 +encryption: 0 +relPath:<null> +type:1 +format:1 +protocol:none +hostname:<null> diff --git a/tests/virstoragetestdata/out/qed-qed_raw b/tests/virstoragetestdata/out/qed-qed_raw new file mode 100644 index 0000000000..70a75c4e37 --- /dev/null +++ b/tests/virstoragetestdata/out/qed-qed_raw @@ -0,0 +1,19 @@ +path:ABS_BUILDDIR/virstoragedata/qed +backingStoreRaw: ABS_BUILDDIR/virstoragedata/raw +capacity: 1024 +encryption: 0 +relPath:<null> +type:1 +format:15 +protocol:none +hostname:<null> + +path:ABS_BUILDDIR/virstoragedata/raw +backingStoreRaw: <null> +capacity: 0 +encryption: 0 +relPath:<null> +type:1 +format:1 +protocol:none +hostname:<null> diff --git a/tests/virstoragetestdata/out/raw-auto b/tests/virstoragetestdata/out/raw-auto new file mode 100644 index 0000000000..8d6c525896 --- /dev/null +++ b/tests/virstoragetestdata/out/raw-auto @@ -0,0 +1,9 @@ +path:ABS_BUILDDIR/virstoragedata/raw +backingStoreRaw: <null> +capacity: 0 +encryption: 0 +relPath:<null> +type:1 +format:1 +protocol:none +hostname:<null> diff --git a/tests/virstoragetestdata/out/raw-raw b/tests/virstoragetestdata/out/raw-raw new file mode 100644 index 0000000000..8d6c525896 --- /dev/null +++ b/tests/virstoragetestdata/out/raw-raw @@ -0,0 +1,9 @@ +path:ABS_BUILDDIR/virstoragedata/raw +backingStoreRaw: <null> +capacity: 0 +encryption: 0 +relPath:<null> +type:1 +format:1 +protocol:none +hostname:<null> -- 2.31.1

Passing in both "chain*" and "chain*->path" is pointless. Use only the full struct which we can use to infer the rest. Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- tests/virstoragetest.c | 201 +++++++++++++++++++---------------------- 1 file changed, 94 insertions(+), 107 deletions(-) diff --git a/tests/virstoragetest.c b/tests/virstoragetest.c index 4f4fd4e824..a3f9c537e5 100644 --- a/tests/virstoragetest.c +++ b/tests/virstoragetest.c @@ -303,7 +303,6 @@ struct testLookupData virStorageSource *from; const char *name; unsigned int expIndex; - const char *expResult; virStorageSource *expMeta; virStorageSource *expParent; }; @@ -318,25 +317,16 @@ testStorageLookup(const void *args) result = virStorageSourceChainLookup(data->chain, data->from, data->name, data->target, &actualParent); - if (!data->expResult) + if (!data->expMeta) virResetLastError(); - if (!result) { - if (data->expResult) { - fprintf(stderr, "result: expected %s, got NULL\n", - data->expResult); - ret = -1; - } - } else if (STRNEQ_NULLABLE(data->expResult, result->path)) { - fprintf(stderr, "result: expected %s, got %s\n", - NULLSTR(data->expResult), NULLSTR(result->path)); - ret = -1; - } if (data->expMeta != result) { - fprintf(stderr, "meta: expected %p, got %p\n", - data->expMeta, result); + fprintf(stderr, "meta: expected %s, got %s\n", + NULLSTR(data->expMeta ? data->expMeta->path : NULL), + NULLSTR(result ? result->path : NULL)); ret = -1; } + if (data->expIndex > 0) { if (!result) { fprintf(stderr, "index: resulting lookup is empty, can't match index\n"); @@ -649,47 +639,44 @@ mymain(void) chain2 = chain->backingStore; chain3 = chain2->backingStore; -#define TEST_LOOKUP_TARGET(id, target, from, name, index, result, \ - meta, parent) \ +#define TEST_LOOKUP_TARGET(id, target, from, name, index, meta, parent) \ do { \ data2 = (struct testLookupData){ \ - chain, target, from, name, index, \ - result, meta, parent, }; \ - if (virTestRun("Chain lookup " #id, \ - testStorageLookup, &data2) < 0) \ + chain, target, from, name, index, meta, parent, }; \ + if (virTestRun("Chain lookup " #id, testStorageLookup, &data2) < 0) \ ret = -1; \ } while (0) -#define TEST_LOOKUP(id, from, name, result, meta, parent) \ - TEST_LOOKUP_TARGET(id, NULL, from, name, 0, result, meta, parent) - - TEST_LOOKUP(0, NULL, "bogus", NULL, NULL, NULL); - TEST_LOOKUP(1, chain, "bogus", NULL, NULL, NULL); - TEST_LOOKUP(2, NULL, "wrap", chain->path, chain, NULL); - TEST_LOOKUP(3, chain, "wrap", NULL, NULL, NULL); - TEST_LOOKUP(4, chain2, "wrap", NULL, NULL, NULL); - TEST_LOOKUP(5, NULL, abswrap, chain->path, chain, NULL); - TEST_LOOKUP(6, chain, abswrap, NULL, NULL, NULL); - TEST_LOOKUP(7, chain2, abswrap, NULL, NULL, NULL); - TEST_LOOKUP(8, NULL, "qcow2", chain2->path, chain2, chain); - TEST_LOOKUP(9, chain, "qcow2", chain2->path, chain2, chain); - TEST_LOOKUP(10, chain2, "qcow2", NULL, NULL, NULL); - TEST_LOOKUP(11, chain3, "qcow2", NULL, NULL, NULL); - TEST_LOOKUP(12, NULL, absqcow2, chain2->path, chain2, chain); - TEST_LOOKUP(13, chain, absqcow2, chain2->path, chain2, chain); - TEST_LOOKUP(14, chain2, absqcow2, NULL, NULL, NULL); - TEST_LOOKUP(15, chain3, absqcow2, NULL, NULL, NULL); - TEST_LOOKUP(16, NULL, "raw", chain3->path, chain3, chain2); - TEST_LOOKUP(17, chain, "raw", chain3->path, chain3, chain2); - TEST_LOOKUP(18, chain2, "raw", chain3->path, chain3, chain2); - TEST_LOOKUP(19, chain3, "raw", NULL, NULL, NULL); - TEST_LOOKUP(20, NULL, absraw, chain3->path, chain3, chain2); - TEST_LOOKUP(21, chain, absraw, chain3->path, chain3, chain2); - TEST_LOOKUP(22, chain2, absraw, chain3->path, chain3, chain2); - TEST_LOOKUP(23, chain3, absraw, NULL, NULL, NULL); - TEST_LOOKUP(24, NULL, NULL, chain3->path, chain3, chain2); - TEST_LOOKUP(25, chain, NULL, chain3->path, chain3, chain2); - TEST_LOOKUP(26, chain2, NULL, chain3->path, chain3, chain2); - TEST_LOOKUP(27, chain3, NULL, NULL, NULL, NULL); +#define TEST_LOOKUP(id, from, name, meta, parent) \ + TEST_LOOKUP_TARGET(id, NULL, from, name, 0, meta, parent) + + TEST_LOOKUP(0, NULL, "bogus", NULL, NULL); + TEST_LOOKUP(1, chain, "bogus", NULL, NULL); + TEST_LOOKUP(2, NULL, "wrap", chain, NULL); + TEST_LOOKUP(3, chain, "wrap", NULL, NULL); + TEST_LOOKUP(4, chain2, "wrap", NULL, NULL); + TEST_LOOKUP(5, NULL, abswrap, chain, NULL); + TEST_LOOKUP(6, chain, abswrap, NULL, NULL); + TEST_LOOKUP(7, chain2, abswrap, NULL, NULL); + TEST_LOOKUP(8, NULL, "qcow2", chain2, chain); + TEST_LOOKUP(9, chain, "qcow2", chain2, chain); + TEST_LOOKUP(10, chain2, "qcow2", NULL, NULL); + TEST_LOOKUP(11, chain3, "qcow2", NULL, NULL); + TEST_LOOKUP(12, NULL, absqcow2, chain2, chain); + TEST_LOOKUP(13, chain, absqcow2, chain2, chain); + TEST_LOOKUP(14, chain2, absqcow2, NULL, NULL); + TEST_LOOKUP(15, chain3, absqcow2, NULL, NULL); + TEST_LOOKUP(16, NULL, "raw", chain3, chain2); + TEST_LOOKUP(17, chain, "raw", chain3, chain2); + TEST_LOOKUP(18, chain2, "raw", chain3, chain2); + TEST_LOOKUP(19, chain3, "raw", NULL, NULL); + TEST_LOOKUP(20, NULL, absraw, chain3, chain2); + TEST_LOOKUP(21, chain, absraw, chain3, chain2); + TEST_LOOKUP(22, chain2, absraw, chain3, chain2); + TEST_LOOKUP(23, chain3, absraw, NULL, NULL); + TEST_LOOKUP(24, NULL, NULL, chain3, chain2); + TEST_LOOKUP(25, chain, NULL, chain3, chain2); + TEST_LOOKUP(26, chain2, NULL, chain3, chain2); + TEST_LOOKUP(27, chain3, NULL, NULL, NULL); /* Rewrite wrap and qcow2 back to 3-deep chain, relative backing */ virCommandFree(cmd); @@ -714,34 +701,34 @@ mymain(void) chain2 = chain->backingStore; chain3 = chain2->backingStore; - TEST_LOOKUP(28, NULL, "bogus", NULL, NULL, NULL); - TEST_LOOKUP(29, chain, "bogus", NULL, NULL, NULL); - TEST_LOOKUP(30, NULL, "wrap", chain->path, chain, NULL); - TEST_LOOKUP(31, chain, "wrap", NULL, NULL, NULL); - TEST_LOOKUP(32, chain2, "wrap", NULL, NULL, NULL); - TEST_LOOKUP(33, NULL, abswrap, chain->path, chain, NULL); - TEST_LOOKUP(34, chain, abswrap, NULL, NULL, NULL); - TEST_LOOKUP(35, chain2, abswrap, NULL, NULL, NULL); - TEST_LOOKUP(36, NULL, "qcow2", chain2->path, chain2, chain); - TEST_LOOKUP(37, chain, "qcow2", chain2->path, chain2, chain); - TEST_LOOKUP(38, chain2, "qcow2", NULL, NULL, NULL); - TEST_LOOKUP(39, chain3, "qcow2", NULL, NULL, NULL); - TEST_LOOKUP(40, NULL, absqcow2, chain2->path, chain2, chain); - TEST_LOOKUP(41, chain, absqcow2, chain2->path, chain2, chain); - TEST_LOOKUP(42, chain2, absqcow2, NULL, NULL, NULL); - TEST_LOOKUP(43, chain3, absqcow2, NULL, NULL, NULL); - TEST_LOOKUP(44, NULL, "raw", chain3->path, chain3, chain2); - TEST_LOOKUP(45, chain, "raw", chain3->path, chain3, chain2); - TEST_LOOKUP(46, chain2, "raw", chain3->path, chain3, chain2); - TEST_LOOKUP(47, chain3, "raw", NULL, NULL, NULL); - TEST_LOOKUP(48, NULL, absraw, chain3->path, chain3, chain2); - TEST_LOOKUP(49, chain, absraw, chain3->path, chain3, chain2); - TEST_LOOKUP(50, chain2, absraw, chain3->path, chain3, chain2); - TEST_LOOKUP(51, chain3, absraw, NULL, NULL, NULL); - TEST_LOOKUP(52, NULL, NULL, chain3->path, chain3, chain2); - TEST_LOOKUP(53, chain, NULL, chain3->path, chain3, chain2); - TEST_LOOKUP(54, chain2, NULL, chain3->path, chain3, chain2); - TEST_LOOKUP(55, chain3, NULL, NULL, NULL, NULL); + TEST_LOOKUP(28, NULL, "bogus", NULL, NULL); + TEST_LOOKUP(29, chain, "bogus", NULL, NULL); + TEST_LOOKUP(30, NULL, "wrap", chain, NULL); + TEST_LOOKUP(31, chain, "wrap", NULL, NULL); + TEST_LOOKUP(32, chain2, "wrap", NULL, NULL); + TEST_LOOKUP(33, NULL, abswrap, chain, NULL); + TEST_LOOKUP(34, chain, abswrap, NULL, NULL); + TEST_LOOKUP(35, chain2, abswrap, NULL, NULL); + TEST_LOOKUP(36, NULL, "qcow2", chain2, chain); + TEST_LOOKUP(37, chain, "qcow2", chain2, chain); + TEST_LOOKUP(38, chain2, "qcow2", NULL, NULL); + TEST_LOOKUP(39, chain3, "qcow2", NULL, NULL); + TEST_LOOKUP(40, NULL, absqcow2, chain2, chain); + TEST_LOOKUP(41, chain, absqcow2, chain2, chain); + TEST_LOOKUP(42, chain2, absqcow2, NULL, NULL); + TEST_LOOKUP(43, chain3, absqcow2, NULL, NULL); + TEST_LOOKUP(44, NULL, "raw", chain3, chain2); + TEST_LOOKUP(45, chain, "raw", chain3, chain2); + TEST_LOOKUP(46, chain2, "raw", chain3, chain2); + TEST_LOOKUP(47, chain3, "raw", NULL, NULL); + TEST_LOOKUP(48, NULL, absraw, chain3, chain2); + TEST_LOOKUP(49, chain, absraw, chain3, chain2); + TEST_LOOKUP(50, chain2, absraw, chain3, chain2); + TEST_LOOKUP(51, chain3, absraw, NULL, NULL); + TEST_LOOKUP(52, NULL, NULL, chain3, chain2); + TEST_LOOKUP(53, chain, NULL, chain3, chain2); + TEST_LOOKUP(54, chain2, NULL, chain3, chain2); + TEST_LOOKUP(55, chain3, NULL, NULL, NULL); /* Use link to wrap with cross-directory relative backing */ virCommandFree(cmd); @@ -761,33 +748,33 @@ mymain(void) chain2 = chain->backingStore; chain3 = chain2->backingStore; - TEST_LOOKUP(56, NULL, "bogus", NULL, NULL, NULL); - TEST_LOOKUP(57, NULL, "sub/link2", chain->path, chain, NULL); - TEST_LOOKUP(58, NULL, "wrap", chain->path, chain, NULL); - TEST_LOOKUP(59, NULL, abswrap, chain->path, chain, NULL); - TEST_LOOKUP(60, NULL, "../qcow2", chain2->path, chain2, chain); - TEST_LOOKUP(61, NULL, "qcow2", NULL, NULL, NULL); - TEST_LOOKUP(62, NULL, absqcow2, chain2->path, chain2, chain); - TEST_LOOKUP(63, NULL, "raw", chain3->path, chain3, chain2); - TEST_LOOKUP(64, NULL, absraw, chain3->path, chain3, chain2); - TEST_LOOKUP(65, NULL, NULL, chain3->path, chain3, chain2); - - TEST_LOOKUP_TARGET(66, "vda", NULL, "bogus[1]", 0, NULL, NULL, NULL); - TEST_LOOKUP_TARGET(67, "vda", NULL, "vda[-1]", 0, NULL, NULL, NULL); - TEST_LOOKUP_TARGET(68, "vda", NULL, "vda[1][1]", 0, NULL, NULL, NULL); - TEST_LOOKUP_TARGET(69, "vda", NULL, "wrap", 0, chain->path, chain, NULL); - TEST_LOOKUP_TARGET(70, "vda", chain, "wrap", 0, NULL, NULL, NULL); - TEST_LOOKUP_TARGET(71, "vda", chain2, "wrap", 0, NULL, NULL, NULL); - TEST_LOOKUP_TARGET(72, "vda", NULL, "vda[0]", 0, NULL, NULL, NULL); - TEST_LOOKUP_TARGET(73, "vda", NULL, "vda[1]", 1, chain2->path, chain2, chain); - TEST_LOOKUP_TARGET(74, "vda", chain, "vda[1]", 1, chain2->path, chain2, chain); - TEST_LOOKUP_TARGET(75, "vda", chain2, "vda[1]", 0, NULL, NULL, NULL); - TEST_LOOKUP_TARGET(76, "vda", chain3, "vda[1]", 0, NULL, NULL, NULL); - TEST_LOOKUP_TARGET(77, "vda", NULL, "vda[2]", 2, chain3->path, chain3, chain2); - TEST_LOOKUP_TARGET(78, "vda", chain, "vda[2]", 2, chain3->path, chain3, chain2); - TEST_LOOKUP_TARGET(79, "vda", chain2, "vda[2]", 2, chain3->path, chain3, chain2); - TEST_LOOKUP_TARGET(80, "vda", chain3, "vda[2]", 0, NULL, NULL, NULL); - TEST_LOOKUP_TARGET(81, "vda", NULL, "vda[3]", 0, NULL, NULL, NULL); + TEST_LOOKUP(56, NULL, "bogus", NULL, NULL); + TEST_LOOKUP(57, NULL, "sub/link2", chain, NULL); + TEST_LOOKUP(58, NULL, "wrap", chain, NULL); + TEST_LOOKUP(59, NULL, abswrap, chain, NULL); + TEST_LOOKUP(60, NULL, "../qcow2", chain2, chain); + TEST_LOOKUP(61, NULL, "qcow2", NULL, NULL); + TEST_LOOKUP(62, NULL, absqcow2, chain2, chain); + TEST_LOOKUP(63, NULL, "raw", chain3, chain2); + TEST_LOOKUP(64, NULL, absraw, chain3, chain2); + TEST_LOOKUP(65, NULL, NULL, chain3, chain2); + + TEST_LOOKUP_TARGET(66, "vda", NULL, "bogus[1]", 0, NULL, NULL); + TEST_LOOKUP_TARGET(67, "vda", NULL, "vda[-1]", 0, NULL, NULL); + TEST_LOOKUP_TARGET(68, "vda", NULL, "vda[1][1]", 0, NULL, NULL); + TEST_LOOKUP_TARGET(69, "vda", NULL, "wrap", 0, chain, NULL); + TEST_LOOKUP_TARGET(70, "vda", chain, "wrap", 0, NULL, NULL); + TEST_LOOKUP_TARGET(71, "vda", chain2, "wrap", 0, NULL, NULL); + TEST_LOOKUP_TARGET(72, "vda", NULL, "vda[0]", 0, NULL, NULL); + TEST_LOOKUP_TARGET(73, "vda", NULL, "vda[1]", 1, chain2, chain); + TEST_LOOKUP_TARGET(74, "vda", chain, "vda[1]", 1, chain2, chain); + TEST_LOOKUP_TARGET(75, "vda", chain2, "vda[1]", 0, NULL, NULL); + TEST_LOOKUP_TARGET(76, "vda", chain3, "vda[1]", 0, NULL, NULL); + TEST_LOOKUP_TARGET(77, "vda", NULL, "vda[2]", 2, chain3, chain2); + TEST_LOOKUP_TARGET(78, "vda", chain, "vda[2]", 2, chain3, chain2); + TEST_LOOKUP_TARGET(79, "vda", chain2, "vda[2]", 2, chain3, chain2); + TEST_LOOKUP_TARGET(80, "vda", chain3, "vda[2]", 0, NULL, NULL); + TEST_LOOKUP_TARGET(81, "vda", NULL, "vda[3]", 0, NULL, NULL); #define TEST_RELATIVE_BACKING(id, TOP, BASE, EXPECT) \ do { \ -- 2.31.1

Rather than using 'qemu-img' and rewriting the chain we can use fake data and few empty files to ensure the same level of coverage. This is possible since we've already tested that the metadata parsing from files works properly and the only thing we are testing here is that the symlink resolution works properly. Additionally after the refactor of 'virstoragetest' is complete additional tests on real data will be added. Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- tests/virstoragetest.c | 140 ++++++++++------------ tests/virstoragetestdata/lookup/qcow2 | 0 tests/virstoragetestdata/lookup/raw | 0 tests/virstoragetestdata/lookup/sub/link2 | 1 + tests/virstoragetestdata/lookup/wrap | 0 5 files changed, 63 insertions(+), 78 deletions(-) create mode 100644 tests/virstoragetestdata/lookup/qcow2 create mode 100644 tests/virstoragetestdata/lookup/raw create mode 120000 tests/virstoragetestdata/lookup/sub/link2 create mode 100644 tests/virstoragetestdata/lookup/wrap diff --git a/tests/virstoragetest.c b/tests/virstoragetest.c index a3f9c537e5..299b16e119 100644 --- a/tests/virstoragetest.c +++ b/tests/virstoragetest.c @@ -499,10 +499,11 @@ mymain(void) struct testLookupData data2; struct testPathRelativeBacking data4; struct testBackingParseData data5; - virStorageSource *chain2; /* short for chain->backingStore */ - virStorageSource *chain3; /* short for chain2->backingStore */ + virStorageSource fakeChain[4]; + virStorageSource *chain = &fakeChain[0]; + virStorageSource *chain2 = &fakeChain[1]; + virStorageSource *chain3 = &fakeChain[2]; g_autoptr(virCommand) cmd = NULL; - g_autoptr(virStorageSource) chain = NULL; if (storageRegisterAll() < 0) return EXIT_FAILURE; @@ -622,22 +623,29 @@ mymain(void) /* Behavior of an infinite loop chain */ TEST_CHAIN("qcow2-qcow2_infinite-mutual", abswrap, VIR_STORAGE_FILE_QCOW2, EXP_FAIL); - /* Rewrite wrap and qcow2 back to 3-deep chain, absolute backing */ - virCommandFree(cmd); - cmd = virCommandNewArgList(qemuimg, "rebase", "-u", "-f", "qcow2", - "-F", "raw", "-b", absraw, "qcow2", NULL); - if (virCommandRun(cmd, NULL) < 0) - ret = -1; - - /* Test behavior of chain lookups, absolute backing from relative start */ - chain = testStorageFileGetMetadata("wrap", VIR_STORAGE_FILE_QCOW2, - -1, -1); - if (!chain) { - ret = -1; + /* setup data for backing chain lookup testing */ + if (chdir(abs_srcdir "/virstoragetestdata/lookup") < 0) { + fprintf(stderr, "unable to test relative backing chains\n"); goto cleanup; } - chain2 = chain->backingStore; - chain3 = chain2->backingStore; + + memset(fakeChain, 0, sizeof(fakeChain)); + fakeChain[0].backingStore = &fakeChain[1]; + fakeChain[1].backingStore = &fakeChain[2]; + fakeChain[2].backingStore = &fakeChain[3]; + + fakeChain[0].type = VIR_STORAGE_TYPE_FILE; + fakeChain[1].type = VIR_STORAGE_TYPE_FILE; + fakeChain[2].type = VIR_STORAGE_TYPE_FILE; + + fakeChain[0].format = VIR_STORAGE_FILE_QCOW2; + fakeChain[1].format = VIR_STORAGE_FILE_QCOW2; + fakeChain[2].format = VIR_STORAGE_FILE_RAW; + + /* backing chain with relative start and absolute backing paths */ + fakeChain[0].path = (char *) "wrap"; + fakeChain[1].path = (char *) abs_srcdir "/virstoragetestdata/lookup/qcow2"; + fakeChain[2].path = (char *) abs_srcdir "/virstoragetestdata/lookup/raw"; #define TEST_LOOKUP_TARGET(id, target, from, name, index, meta, parent) \ do { \ @@ -654,111 +662,87 @@ mymain(void) TEST_LOOKUP(2, NULL, "wrap", chain, NULL); TEST_LOOKUP(3, chain, "wrap", NULL, NULL); TEST_LOOKUP(4, chain2, "wrap", NULL, NULL); - TEST_LOOKUP(5, NULL, abswrap, chain, NULL); - TEST_LOOKUP(6, chain, abswrap, NULL, NULL); - TEST_LOOKUP(7, chain2, abswrap, NULL, NULL); + TEST_LOOKUP(5, NULL, abs_srcdir "/virstoragetestdata/lookup/wrap", chain, NULL); + TEST_LOOKUP(6, chain, abs_srcdir "/virstoragetestdata/lookup/wrap", NULL, NULL); + TEST_LOOKUP(7, chain2, abs_srcdir "/virstoragetestdata/lookup/wrap", NULL, NULL); TEST_LOOKUP(8, NULL, "qcow2", chain2, chain); TEST_LOOKUP(9, chain, "qcow2", chain2, chain); TEST_LOOKUP(10, chain2, "qcow2", NULL, NULL); TEST_LOOKUP(11, chain3, "qcow2", NULL, NULL); - TEST_LOOKUP(12, NULL, absqcow2, chain2, chain); - TEST_LOOKUP(13, chain, absqcow2, chain2, chain); - TEST_LOOKUP(14, chain2, absqcow2, NULL, NULL); - TEST_LOOKUP(15, chain3, absqcow2, NULL, NULL); + TEST_LOOKUP(12, NULL, abs_srcdir "/virstoragetestdata/lookup/qcow2", chain2, chain); + TEST_LOOKUP(13, chain, abs_srcdir "/virstoragetestdata/lookup/qcow2", chain2, chain); + TEST_LOOKUP(14, chain2, abs_srcdir "/virstoragetestdata/lookup/qcow2", NULL, NULL); + TEST_LOOKUP(15, chain3, abs_srcdir "/virstoragetestdata/lookup/qcow2", NULL, NULL); TEST_LOOKUP(16, NULL, "raw", chain3, chain2); TEST_LOOKUP(17, chain, "raw", chain3, chain2); TEST_LOOKUP(18, chain2, "raw", chain3, chain2); TEST_LOOKUP(19, chain3, "raw", NULL, NULL); - TEST_LOOKUP(20, NULL, absraw, chain3, chain2); - TEST_LOOKUP(21, chain, absraw, chain3, chain2); - TEST_LOOKUP(22, chain2, absraw, chain3, chain2); - TEST_LOOKUP(23, chain3, absraw, NULL, NULL); + TEST_LOOKUP(20, NULL, abs_srcdir "/virstoragetestdata/lookup/raw", chain3, chain2); + TEST_LOOKUP(21, chain, abs_srcdir "/virstoragetestdata/lookup/raw", chain3, chain2); + TEST_LOOKUP(22, chain2, abs_srcdir "/virstoragetestdata/lookup/raw", chain3, chain2); + TEST_LOOKUP(23, chain3, abs_srcdir "/virstoragetestdata/lookup/raw", NULL, NULL); TEST_LOOKUP(24, NULL, NULL, chain3, chain2); TEST_LOOKUP(25, chain, NULL, chain3, chain2); TEST_LOOKUP(26, chain2, NULL, chain3, chain2); TEST_LOOKUP(27, chain3, NULL, NULL, NULL); - /* Rewrite wrap and qcow2 back to 3-deep chain, relative backing */ - virCommandFree(cmd); - cmd = virCommandNewArgList(qemuimg, "rebase", "-u", "-f", "qcow2", - "-F", "raw", "-b", "raw", "qcow2", NULL); - if (virCommandRun(cmd, NULL) < 0) - ret = -1; + /* relative backing, absolute start */ + fakeChain[0].path = (char *) abs_srcdir "/virstoragetestdata/lookup/wrap"; - virCommandFree(cmd); - cmd = virCommandNewArgList(qemuimg, "rebase", "-u", "-f", "qcow2", - "-F", "qcow2", "-b", "qcow2", "wrap", NULL); - if (virCommandRun(cmd, NULL) < 0) - ret = -1; - - /* Test behavior of chain lookups, relative backing from absolute start */ - virObjectUnref(chain); - chain = testStorageFileGetMetadata(abswrap, VIR_STORAGE_FILE_QCOW2, -1, -1); - if (!chain) { - ret = -1; - goto cleanup; - } - chain2 = chain->backingStore; - chain3 = chain2->backingStore; + fakeChain[1].relPath = (char *) "qcow2"; + fakeChain[2].relPath = (char *) "raw"; TEST_LOOKUP(28, NULL, "bogus", NULL, NULL); TEST_LOOKUP(29, chain, "bogus", NULL, NULL); TEST_LOOKUP(30, NULL, "wrap", chain, NULL); TEST_LOOKUP(31, chain, "wrap", NULL, NULL); TEST_LOOKUP(32, chain2, "wrap", NULL, NULL); - TEST_LOOKUP(33, NULL, abswrap, chain, NULL); - TEST_LOOKUP(34, chain, abswrap, NULL, NULL); - TEST_LOOKUP(35, chain2, abswrap, NULL, NULL); + TEST_LOOKUP(33, NULL, abs_srcdir "/virstoragetestdata/lookup/wrap", chain, NULL); + TEST_LOOKUP(34, chain, abs_srcdir "/virstoragetestdata/lookup/wrap", NULL, NULL); + TEST_LOOKUP(35, chain2, abs_srcdir "/virstoragetestdata/lookup/wrap", NULL, NULL); TEST_LOOKUP(36, NULL, "qcow2", chain2, chain); TEST_LOOKUP(37, chain, "qcow2", chain2, chain); TEST_LOOKUP(38, chain2, "qcow2", NULL, NULL); TEST_LOOKUP(39, chain3, "qcow2", NULL, NULL); - TEST_LOOKUP(40, NULL, absqcow2, chain2, chain); - TEST_LOOKUP(41, chain, absqcow2, chain2, chain); - TEST_LOOKUP(42, chain2, absqcow2, NULL, NULL); - TEST_LOOKUP(43, chain3, absqcow2, NULL, NULL); + TEST_LOOKUP(40, NULL, abs_srcdir "/virstoragetestdata/lookup/qcow2", chain2, chain); + TEST_LOOKUP(41, chain, abs_srcdir "/virstoragetestdata/lookup/qcow2", chain2, chain); + TEST_LOOKUP(42, chain2, abs_srcdir "/virstoragetestdata/lookup/qcow2", NULL, NULL); + TEST_LOOKUP(43, chain3, abs_srcdir "/virstoragetestdata/lookup/qcow2", NULL, NULL); TEST_LOOKUP(44, NULL, "raw", chain3, chain2); TEST_LOOKUP(45, chain, "raw", chain3, chain2); TEST_LOOKUP(46, chain2, "raw", chain3, chain2); TEST_LOOKUP(47, chain3, "raw", NULL, NULL); - TEST_LOOKUP(48, NULL, absraw, chain3, chain2); - TEST_LOOKUP(49, chain, absraw, chain3, chain2); - TEST_LOOKUP(50, chain2, absraw, chain3, chain2); - TEST_LOOKUP(51, chain3, absraw, NULL, NULL); + TEST_LOOKUP(48, NULL, abs_srcdir "/virstoragetestdata/lookup/raw", chain3, chain2); + TEST_LOOKUP(49, chain, abs_srcdir "/virstoragetestdata/lookup/raw", chain3, chain2); + TEST_LOOKUP(50, chain2, abs_srcdir "/virstoragetestdata/lookup/raw", chain3, chain2); + TEST_LOOKUP(51, chain3, abs_srcdir "/virstoragetestdata/lookup/raw", NULL, NULL); TEST_LOOKUP(52, NULL, NULL, chain3, chain2); TEST_LOOKUP(53, chain, NULL, chain3, chain2); TEST_LOOKUP(54, chain2, NULL, chain3, chain2); TEST_LOOKUP(55, chain3, NULL, NULL, NULL); /* Use link to wrap with cross-directory relative backing */ - virCommandFree(cmd); - cmd = virCommandNewArgList(qemuimg, "rebase", "-u", "-f", "qcow2", - "-F", "qcow2", "-b", "../qcow2", "wrap", NULL); - if (virCommandRun(cmd, NULL) < 0) - ret = -1; + fakeChain[0].path = (char *) abs_srcdir "/virstoragetestdata/lookup/sub/link2"; - /* Test behavior of chain lookups, relative backing */ - virObjectUnref(chain); - chain = testStorageFileGetMetadata("sub/link2", VIR_STORAGE_FILE_QCOW2, - -1, -1); - if (!chain) { - ret = -1; - goto cleanup; - } - chain2 = chain->backingStore; - chain3 = chain2->backingStore; + fakeChain[1].relPath = (char *) "../qcow2"; + fakeChain[2].relPath = (char *) "raw"; TEST_LOOKUP(56, NULL, "bogus", NULL, NULL); TEST_LOOKUP(57, NULL, "sub/link2", chain, NULL); TEST_LOOKUP(58, NULL, "wrap", chain, NULL); - TEST_LOOKUP(59, NULL, abswrap, chain, NULL); + TEST_LOOKUP(59, NULL, abs_srcdir "/virstoragetestdata/lookup/wrap", chain, NULL); TEST_LOOKUP(60, NULL, "../qcow2", chain2, chain); TEST_LOOKUP(61, NULL, "qcow2", NULL, NULL); - TEST_LOOKUP(62, NULL, absqcow2, chain2, chain); + TEST_LOOKUP(62, NULL, abs_srcdir "/virstoragetestdata/lookup/qcow2", chain2, chain); TEST_LOOKUP(63, NULL, "raw", chain3, chain2); - TEST_LOOKUP(64, NULL, absraw, chain3, chain2); + TEST_LOOKUP(64, NULL, abs_srcdir "/virstoragetestdata/lookup/raw", chain3, chain2); TEST_LOOKUP(65, NULL, NULL, chain3, chain2); + /* index lookup */ + fakeChain[0].id = 0; + fakeChain[1].id = 1; + fakeChain[2].id = 2; + TEST_LOOKUP_TARGET(66, "vda", NULL, "bogus[1]", 0, NULL, NULL); TEST_LOOKUP_TARGET(67, "vda", NULL, "vda[-1]", 0, NULL, NULL); TEST_LOOKUP_TARGET(68, "vda", NULL, "vda[1][1]", 0, NULL, NULL); diff --git a/tests/virstoragetestdata/lookup/qcow2 b/tests/virstoragetestdata/lookup/qcow2 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/virstoragetestdata/lookup/raw b/tests/virstoragetestdata/lookup/raw new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/virstoragetestdata/lookup/sub/link2 b/tests/virstoragetestdata/lookup/sub/link2 new file mode 120000 index 0000000000..5efbc33afa --- /dev/null +++ b/tests/virstoragetestdata/lookup/sub/link2 @@ -0,0 +1 @@ +../wrap \ No newline at end of file diff --git a/tests/virstoragetestdata/lookup/wrap b/tests/virstoragetestdata/lookup/wrap new file mode 100644 index 0000000000..e69de29bb2 -- 2.31.1

Provide the images for the self and mutual backing image loop cases in the repository rather than formatting them with qemu-img. This makes the code more readable and also decouples the backing chain tests from each other. Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- build-aux/syntax-check.mk | 2 +- tests/virstoragetest.c | 30 ++++-------------- tests/virstoragetestdata/images/loop-1.qcow2 | Bin 0 -> 196616 bytes tests/virstoragetestdata/images/loop-2.qcow2 | Bin 0 -> 196616 bytes .../virstoragetestdata/images/loop-self.qcow2 | Bin 0 -> 196616 bytes 5 files changed, 7 insertions(+), 25 deletions(-) create mode 100644 tests/virstoragetestdata/images/loop-1.qcow2 create mode 100644 tests/virstoragetestdata/images/loop-2.qcow2 create mode 100644 tests/virstoragetestdata/images/loop-self.qcow2 diff --git a/build-aux/syntax-check.mk b/build-aux/syntax-check.mk index 2058af0b77..cb54c8ba36 100644 --- a/build-aux/syntax-check.mk +++ b/build-aux/syntax-check.mk @@ -1563,7 +1563,7 @@ exclude_file_name_regexp--sc_prohibit_close = \ (\.p[yl]$$|\.spec\.in$$|^docs/|^(src/util/vir(file|event)\.c|src/libvirt-stream\.c|tests/(vir.+mock\.c|commandhelper\.c|qemusecuritymock\.c)|tools/nss/libvirt_nss_(leases|macs)\.c)$$) exclude_file_name_regexp--sc_prohibit_empty_lines_at_EOF = \ - (^tests/(nodedevmdevctl|virhostcpu|virpcitest)data/|docs/js/.*\.js|docs/fonts/.*\.woff|\.diff|tests/virconfdata/no-newline\.conf$$) + (^tests/(nodedevmdevctl|virhostcpu|virpcitest|virstoragetest)data/|docs/js/.*\.js|docs/fonts/.*\.woff|\.diff|tests/virconfdata/no-newline\.conf$$) exclude_file_name_regexp--sc_prohibit_fork_wrappers = \ (^(src/(util/(vircommand|virdaemon)|lxc/lxc_controller)|tests/testutils)\.c$$) diff --git a/tests/virstoragetest.c b/tests/virstoragetest.c index 299b16e119..785699d4e8 100644 --- a/tests/virstoragetest.c +++ b/tests/virstoragetest.c @@ -597,31 +597,13 @@ mymain(void) TEST_CHAIN("qcow2-symlinks", abslink2, VIR_STORAGE_FILE_QCOW2, EXP_PASS); #endif - /* Rewrite qcow2 to be a self-referential loop */ - virCommandFree(cmd); - cmd = virCommandNewArgList(qemuimg, "rebase", "-u", "-f", "qcow2", - "-F", "qcow2", "-b", "qcow2", "qcow2", NULL); - if (virCommandRun(cmd, NULL) < 0) - ret = -1; - - /* Behavior of an infinite loop chain */ - TEST_CHAIN("qcow2-qcow2_infinite-self", absqcow2, VIR_STORAGE_FILE_QCOW2, EXP_FAIL); - - /* Rewrite wrap and qcow2 to be mutually-referential loop */ - virCommandFree(cmd); - cmd = virCommandNewArgList(qemuimg, "rebase", "-u", "-f", "qcow2", - "-F", "qcow2", "-b", "wrap", "qcow2", NULL); - if (virCommandRun(cmd, NULL) < 0) - ret = -1; - - virCommandFree(cmd); - cmd = virCommandNewArgList(qemuimg, "rebase", "-u", "-f", "qcow2", - "-F", "qcow2", "-b", absqcow2, "wrap", NULL); - if (virCommandRun(cmd, NULL) < 0) - ret = -1; - /* Behavior of an infinite loop chain */ - TEST_CHAIN("qcow2-qcow2_infinite-mutual", abswrap, VIR_STORAGE_FILE_QCOW2, EXP_FAIL); + TEST_CHAIN("qcow2-qcow2_infinite-self", + abs_srcdir "/virstoragetestdata/images/loop-self.qcow2", + VIR_STORAGE_FILE_QCOW2, EXP_FAIL); + TEST_CHAIN("qcow2-qcow2_infinite-mutual", + abs_srcdir "/virstoragetestdata/images/loop-2.qcow2", + VIR_STORAGE_FILE_QCOW2, EXP_FAIL); /* setup data for backing chain lookup testing */ if (chdir(abs_srcdir "/virstoragetestdata/lookup") < 0) { diff --git a/tests/virstoragetestdata/images/loop-1.qcow2 b/tests/virstoragetestdata/images/loop-1.qcow2 new file mode 100644 index 0000000000000000000000000000000000000000..21b0bb8d8749647b3de277175de0611d070b9ee8 GIT binary patch literal 196616 zcmeIvF;2rU6aY{sEgJ(z$czL-4}pZl!o(cfAR?6{q^U}nI11<C7@Pu$1-G;y1_FCu zBHKUtKX&|ld3OFDLKwvsuk<K(hq0~45S};vx=S|EwrczI`R=Ra*I*no%`W@eAHT%- z;C@=KCNa1jy<NrWpF)_GZP#blWw$FG9+PR^w#%mb?-yzD&=qZ!&$C(H<=IU+F9sJF zP3ya+Ef$NiuClIghO0vuujj93#Vos+WJT4rWw97oAPMvQvCrD#W?C<+Zm4uKOB$lg zUEcgzxLq?%+I*G$*z>^Oe5dAh-JDELcgORc5D_3ifB*pk1PBlyK!5-N0t5&UAV7cs z0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZ zfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&U zAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C7 z2oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N z0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FoH0 z0_lEi(=G`RAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF z5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk z1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs z0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZ zfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&U zAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyKwv;137_{si4*|>1PBlyK!5-N0t5&U zAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C7 z2oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N z0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+ z009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBly zK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF Q5FkK+009C72<(r*2VfXEjsO4v literal 0 HcmV?d00001 diff --git a/tests/virstoragetestdata/images/loop-2.qcow2 b/tests/virstoragetestdata/images/loop-2.qcow2 new file mode 100644 index 0000000000000000000000000000000000000000..3e2e020b5a3ac98516e4a5fc557fbe5aa7e89d39 GIT binary patch literal 196616 zcmeIvF;2rU6aY{sg^htDWJUrB4uOQk!o(cfAR@I%NK-+WI11<C7@Pu$1-G<R3<UPR zM7DqOf9&}A>ips(gfNONUg=@%4q{u5A-t^mWtXg?b=CUm>)m(Bufbl-G@I;OfAkvT z{rhqKa2A8R(ff6r{yBt6*>-()Q+Auu;V~K4ZM$f?|9+7ck6qDL`81p4U7p>R(_(Oe z(YT&9Z84vhb(M8}Gh7|Q-g5qGQcSYTv#hAPwk+lY3nXEhKlNE#+>Yx-)eV)dW=TVo zndQx&h3hrbq|G0)AA277n{8@Z*Uj<i$>w;r2@wGT1PBlyK!5-N0t5&UAV7cs0RjXF z5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk z1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs z0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZ zfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&U zAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009EK zA&~CIHtmuC0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+ z009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBly zK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF z5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk z1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs z0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5yGlJIp8lt>XEK!5-N0t5&UAV7cs z0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZ zfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&U zAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C7 z2oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N z0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+ R009C72oNAZfWYnud;($kIgJ1S literal 0 HcmV?d00001 diff --git a/tests/virstoragetestdata/images/loop-self.qcow2 b/tests/virstoragetestdata/images/loop-self.qcow2 new file mode 100644 index 0000000000000000000000000000000000000000..c8f5927bed91990513b7d2acacbda043602e375a GIT binary patch literal 196616 zcmeIvJx=5>6aZi+!`5(w)GI;3A&`)0sHn3u9uX-dA(Igd6-U|g>@oHfE79QjW3&Z< ze!fJuU-Dk;`19@6^;-yGl3Kd*v(%lYwjM+Hz3JCowuyFCyQl5DkCIP=la%T9*}tow ze^UJ8aoRpzrr>_^?=DUM8p5pVhgI>b8uq2*V>WI3e%TG*{UVRgL+qQfE@tIW7W1l( zqYF%??L*hc#iDAPVpw(K)ghd$=Wk|lR@__`u^IX*E=Cr}LS4SBiayS#?XnrhN;k9Q zA;~<H-Is;CHS?@5pNjwXJn}b(RNc1S`6AZyi~R{5av}l*2oNAZfB*pk1PBlyK!5-N z0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+ z009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBly zK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF z5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk z1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs z0RjY$Kp;PYJ=!7x0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&U zAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C7 z2oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N z0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+ z009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBly zK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PF`^WMO-cSIH6}K!5-N0t5&U zAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C7 z2oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N z0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+ z009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBly zK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF V5FkK+009C72oNAZfWVOmyaSe$I|%>) literal 0 HcmV?d00001 -- 2.31.1

We don't need a special directory for the tests. Reuse the directory holding the data for the virstoragetest. Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- tests/virstoragetest.c | 13 +++---------- tests/virstoragetestdata/out/directory-dir | 2 +- tests/virstoragetestdata/out/directory-none | 2 +- tests/virstoragetestdata/out/directory-raw | 2 +- 4 files changed, 6 insertions(+), 13 deletions(-) diff --git a/tests/virstoragetest.c b/tests/virstoragetest.c index 785699d4e8..3736280611 100644 --- a/tests/virstoragetest.c +++ b/tests/virstoragetest.c @@ -56,7 +56,6 @@ static char *absraw; static char *absqcow2; static char *abswrap; static char *absqed; -static char *absdir; static char *abslink2; static void @@ -67,7 +66,6 @@ testCleanupImages(void) VIR_FREE(absqcow2); VIR_FREE(abswrap); VIR_FREE(absqed); - VIR_FREE(absdir); VIR_FREE(abslink2); if (chdir(abs_builddir) < 0) { @@ -139,17 +137,12 @@ testPrepImages(void) absqcow2 = g_strdup_printf("%s/qcow2", datadir); abswrap = g_strdup_printf("%s/wrap", datadir); absqed = g_strdup_printf("%s/qed", datadir); - absdir = g_strdup_printf("%s/dir", datadir); abslink2 = g_strdup_printf("%s/sub/link2", datadir); if (g_mkdir_with_parents(datadir "/sub", 0777) < 0) { fprintf(stderr, "unable to create directory %s\n", datadir "/sub"); goto cleanup; } - if (g_mkdir_with_parents(datadir "/dir", 0777) < 0) { - fprintf(stderr, "unable to create directory %s\n", datadir "/dir"); - goto cleanup; - } if (chdir(datadir) < 0) { fprintf(stderr, "unable to test relative backing chains\n"); @@ -573,9 +566,9 @@ mymain(void) TEST_CHAIN("qed-auto_raw", absqed, VIR_STORAGE_FILE_AUTO, EXP_PASS); /* directory */ - TEST_CHAIN("directory-raw", absdir, VIR_STORAGE_FILE_RAW, EXP_PASS); - TEST_CHAIN("directory-none", absdir, VIR_STORAGE_FILE_NONE, EXP_PASS); - TEST_CHAIN("directory-dir", absdir, VIR_STORAGE_FILE_DIR, EXP_PASS); + TEST_CHAIN("directory-raw", abs_srcdir "/virstoragetestdata/images/", VIR_STORAGE_FILE_RAW, EXP_PASS); + TEST_CHAIN("directory-none", abs_srcdir "/virstoragetestdata/images/", VIR_STORAGE_FILE_NONE, EXP_PASS); + TEST_CHAIN("directory-dir", abs_srcdir "/virstoragetestdata/images/", VIR_STORAGE_FILE_DIR, EXP_PASS); #ifdef WITH_SYMLINK /* Rewrite qcow2 and wrap file to use backing names relative to a diff --git a/tests/virstoragetestdata/out/directory-dir b/tests/virstoragetestdata/out/directory-dir index cff67595b4..65b7b91912 100644 --- a/tests/virstoragetestdata/out/directory-dir +++ b/tests/virstoragetestdata/out/directory-dir @@ -1,4 +1,4 @@ -path:ABS_BUILDDIR/virstoragedata/dir +path:ABS_SRCDIR/virstoragetestdata/images/ backingStoreRaw: <null> capacity: 0 encryption: 0 diff --git a/tests/virstoragetestdata/out/directory-none b/tests/virstoragetestdata/out/directory-none index cff67595b4..65b7b91912 100644 --- a/tests/virstoragetestdata/out/directory-none +++ b/tests/virstoragetestdata/out/directory-none @@ -1,4 +1,4 @@ -path:ABS_BUILDDIR/virstoragedata/dir +path:ABS_SRCDIR/virstoragetestdata/images/ backingStoreRaw: <null> capacity: 0 encryption: 0 diff --git a/tests/virstoragetestdata/out/directory-raw b/tests/virstoragetestdata/out/directory-raw index ebe23cbbd6..5def2c4b8b 100644 --- a/tests/virstoragetestdata/out/directory-raw +++ b/tests/virstoragetestdata/out/directory-raw @@ -1,4 +1,4 @@ -path:ABS_BUILDDIR/virstoragedata/dir +path:ABS_SRCDIR/virstoragetestdata/images/ backingStoreRaw: <null> capacity: 0 encryption: 0 -- 2.31.1

The QED format isn't really being developed any more. Use a pre-formatted image to test the existing code. In this instance we switch to using a relative backing path for simplicity. Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- tests/virstoragetest.c | 21 +++++------------- .../images/qed_raw-raw-relative | Bin 0 -> 327680 bytes tests/virstoragetestdata/images/raw | Bin 0 -> 1024 bytes tests/virstoragetestdata/out/qed-auto_raw | 2 +- tests/virstoragetestdata/out/qed-qed_raw | 8 +++---- 5 files changed, 11 insertions(+), 20 deletions(-) create mode 100644 tests/virstoragetestdata/images/qed_raw-raw-relative create mode 100644 tests/virstoragetestdata/images/raw diff --git a/tests/virstoragetest.c b/tests/virstoragetest.c index 3736280611..96aeaef9ce 100644 --- a/tests/virstoragetest.c +++ b/tests/virstoragetest.c @@ -42,7 +42,6 @@ VIR_LOG_INIT("tests.storagetest"); * raw: 1024-byte raw file * qcow2: qcow2 file with 'raw' as backing * wrap: qcow2 file with 'qcow2' as backing - * qed: qed file with 'raw' as backing * sub/link1: symlink to qcow2 * sub/link2: symlink to wrap * @@ -55,7 +54,6 @@ static char *qemuimg; static char *absraw; static char *absqcow2; static char *abswrap; -static char *absqed; static char *abslink2; static void @@ -65,7 +63,6 @@ testCleanupImages(void) VIR_FREE(absraw); VIR_FREE(absqcow2); VIR_FREE(abswrap); - VIR_FREE(absqed); VIR_FREE(abslink2); if (chdir(abs_builddir) < 0) { @@ -136,7 +133,6 @@ testPrepImages(void) absraw = g_strdup_printf("%s/raw", datadir); absqcow2 = g_strdup_printf("%s/qcow2", datadir); abswrap = g_strdup_printf("%s/wrap", datadir); - absqed = g_strdup_printf("%s/qed", datadir); abslink2 = g_strdup_printf("%s/sub/link2", datadir); if (g_mkdir_with_parents(datadir "/sub", 0777) < 0) { @@ -181,15 +177,6 @@ testPrepImages(void) if (virCommandRun(cmd, NULL) < 0) goto skip; - /* Create a qed file. */ - virCommandFree(cmd); - cmd = virCommandNewArgList(qemuimg, "create", "-f", "qed", NULL); - virCommandAddArgFormat(cmd, "-obacking_file=%s,backing_fmt=raw", - absraw); - virCommandAddArg(cmd, "qed"); - if (virCommandRun(cmd, NULL) < 0) - goto skip; - #ifdef WITH_SYMLINK /* Create some symlinks in a sub-directory. */ if (symlink("../qcow2", datadir "/sub/link1") < 0 || @@ -562,8 +549,12 @@ mymain(void) TEST_CHAIN("qcow2-qcow2_nbd-raw", absqcow2, VIR_STORAGE_FILE_QCOW2, EXP_PASS); /* qed file */ - TEST_CHAIN("qed-qed_raw", absqed, VIR_STORAGE_FILE_QED, EXP_PASS); - TEST_CHAIN("qed-auto_raw", absqed, VIR_STORAGE_FILE_AUTO, EXP_PASS); + TEST_CHAIN("qed-qed_raw", + abs_srcdir "/virstoragetestdata/images/qed_raw-raw-relative", + VIR_STORAGE_FILE_QED, EXP_PASS); + TEST_CHAIN("qed-auto_raw", + abs_srcdir "/virstoragetestdata/images/qed_raw-raw-relative", + VIR_STORAGE_FILE_AUTO, EXP_PASS); /* directory */ TEST_CHAIN("directory-raw", abs_srcdir "/virstoragetestdata/images/", VIR_STORAGE_FILE_RAW, EXP_PASS); diff --git a/tests/virstoragetestdata/images/qed_raw-raw-relative b/tests/virstoragetestdata/images/qed_raw-raw-relative new file mode 100644 index 0000000000000000000000000000000000000000..5c91c3fcfe3dc4f25455bafada27b9c95c28c6e7 GIT binary patch literal 327680 zcmeIuu?>JQ3<SWBAbU~30F1y2X;>cvEfb)7>21k!b^Ep^X_=py^xEHP@A-bLEY+zx zj<co^AV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+ z009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBly zK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF z5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk z1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs z0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZ zfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&U zAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C7 z2oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N z0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+ z009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBly zK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF z5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk z1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs z0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZ zfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&U zAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C7 z2oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N z0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+ z009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBly zK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF z5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk z1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs z0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZ zfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&U zAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C7 z2oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N g0t5&UAV7cs0RjXF5FkK+009C72oNAZfWY4bE>vg&cmMzZ literal 0 HcmV?d00001 diff --git a/tests/virstoragetestdata/images/raw b/tests/virstoragetestdata/images/raw new file mode 100644 index 0000000000000000000000000000000000000000..06d7405020018ddf3cacee90fd4af10487da3d20 GIT binary patch literal 1024 ScmZQz7zLvtFd70QH3R?z00031 literal 0 HcmV?d00001 diff --git a/tests/virstoragetestdata/out/qed-auto_raw b/tests/virstoragetestdata/out/qed-auto_raw index e8ab498038..292a8fa7fb 100644 --- a/tests/virstoragetestdata/out/qed-auto_raw +++ b/tests/virstoragetestdata/out/qed-auto_raw @@ -1,4 +1,4 @@ -path:ABS_BUILDDIR/virstoragedata/qed +path:ABS_SRCDIR/virstoragetestdata/images/qed_raw-raw-relative backingStoreRaw: <null> capacity: 0 encryption: 0 diff --git a/tests/virstoragetestdata/out/qed-qed_raw b/tests/virstoragetestdata/out/qed-qed_raw index 70a75c4e37..043ec4240b 100644 --- a/tests/virstoragetestdata/out/qed-qed_raw +++ b/tests/virstoragetestdata/out/qed-qed_raw @@ -1,5 +1,5 @@ -path:ABS_BUILDDIR/virstoragedata/qed -backingStoreRaw: ABS_BUILDDIR/virstoragedata/raw +path:ABS_SRCDIR/virstoragetestdata/images/qed_raw-raw-relative +backingStoreRaw: raw capacity: 1024 encryption: 0 relPath:<null> @@ -8,11 +8,11 @@ format:15 protocol:none hostname:<null> -path:ABS_BUILDDIR/virstoragedata/raw +path:ABS_SRCDIR/virstoragetestdata/images/raw backingStoreRaw: <null> capacity: 0 encryption: 0 -relPath:<null> +relPath:raw type:1 format:1 protocol:none -- 2.31.1

This one doesn't require using qemu-img either. Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- tests/virstoragetest.c | 13 +++---------- .../images/qcow2_nbd-raw.qcow2 | Bin 0 -> 196616 bytes .../virstoragetestdata/out/qcow2-qcow2_nbd-raw | 2 +- 3 files changed, 4 insertions(+), 11 deletions(-) create mode 100644 tests/virstoragetestdata/images/qcow2_nbd-raw.qcow2 diff --git a/tests/virstoragetest.c b/tests/virstoragetest.c index 96aeaef9ce..8d3dde265f 100644 --- a/tests/virstoragetest.c +++ b/tests/virstoragetest.c @@ -536,17 +536,10 @@ mymain(void) /* Qcow2 file with missing backing file but specified type */ TEST_CHAIN("qcow2-qcow2_missing", absqcow2, VIR_STORAGE_FILE_QCOW2, EXP_FAIL); - - /* Rewrite qcow2 to use an nbd: protocol as backend */ - virCommandFree(cmd); - cmd = virCommandNewArgList(qemuimg, "rebase", "-u", "-f", "qcow2", - "-F", "raw", "-b", "nbd+tcp://example.org:6000/blah", - "qcow2", NULL); - if (virCommandRun(cmd, NULL) < 0) - ret = -1; - /* Qcow2 file with backing protocol instead of file */ - TEST_CHAIN("qcow2-qcow2_nbd-raw", absqcow2, VIR_STORAGE_FILE_QCOW2, EXP_PASS); + TEST_CHAIN("qcow2-qcow2_nbd-raw", + abs_srcdir "/virstoragetestdata/images/qcow2_nbd-raw.qcow2", + VIR_STORAGE_FILE_QCOW2, EXP_PASS); /* qed file */ TEST_CHAIN("qed-qed_raw", diff --git a/tests/virstoragetestdata/images/qcow2_nbd-raw.qcow2 b/tests/virstoragetestdata/images/qcow2_nbd-raw.qcow2 new file mode 100644 index 0000000000000000000000000000000000000000..848da7ac9da8e115c7e2fbd334a25c1d7e6bfa28 GIT binary patch literal 196616 zcmeIuJ&x2c6aZi+!vVMfsX<~!6cl>^BqSOt>deH;M#?0SCo6WSI3LI06i769{<NYX zu<ht`<UGfIevZG7@816kAuMvwt$dzeFLFP`+@7662*q)5&N_dc<}Mk3kB1`TW%<Yc z<@Y>Zr25No>TdD#Q!f84gr-f?zFN1_C3QX)n<1t9ar)mKWqg=o>g%p*>Zz`7+b+%? zu-FXSF~!}k9r|k8kMr4?>QKLLVpDy1Q^kHtZQRWqP=v1jy022a-3<5rG?#j;Qid$E zt;c^Rp3f|cEL{C@=b68GT<X`&t7$XdESK@2-i}>-J*3Y!Z&$0;a^2N;kBLSE2oNAZ zfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&U zAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C7 z2oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N z0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+ z009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBly zK!5-N0t5&UAV7cs0RjXFT&F;Jo!4?J0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk z1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs z0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZ zfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&U zAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C7 z2oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBm#f<O^Y z&l9#tB|v}x0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+ z009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBly zK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF z5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk z1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs j0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5;&>lOG7e&9Zo literal 0 HcmV?d00001 diff --git a/tests/virstoragetestdata/out/qcow2-qcow2_nbd-raw b/tests/virstoragetestdata/out/qcow2-qcow2_nbd-raw index 64acdb880a..08a93b9f32 100644 --- a/tests/virstoragetestdata/out/qcow2-qcow2_nbd-raw +++ b/tests/virstoragetestdata/out/qcow2-qcow2_nbd-raw @@ -1,4 +1,4 @@ -path:ABS_BUILDDIR/virstoragedata/qcow2 +path:ABS_SRCDIR/virstoragetestdata/images/qcow2_nbd-raw.qcow2 backingStoreRaw: nbd+tcp://example.org:6000/blah capacity: 1024 encryption: 0 -- 2.31.1

Similarly to previous ones, this one doesn't need to be created by qemu-img in order for the test to make sense. Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- tests/virstoragetest.c | 12 +++--------- .../images/qcow2_qcow2-missing.qcow2 | Bin 0 -> 196616 bytes 2 files changed, 3 insertions(+), 9 deletions(-) create mode 100644 tests/virstoragetestdata/images/qcow2_qcow2-missing.qcow2 diff --git a/tests/virstoragetest.c b/tests/virstoragetest.c index 8d3dde265f..34aff3e6dd 100644 --- a/tests/virstoragetest.c +++ b/tests/virstoragetest.c @@ -525,16 +525,10 @@ mymain(void) /* qcow2 with a longer backing chain */ TEST_CHAIN("qcow2-qcow2_qcow2-qcow2_raw-raw", abswrap, VIR_STORAGE_FILE_QCOW2, EXP_PASS); - /* Rewrite qcow2 to a missing backing file, with backing type */ - virCommandFree(cmd); - cmd = virCommandNewArgList(qemuimg, "rebase", "-u", "-f", "qcow2", - "-F", "qcow2", "-b", datadir "/bogus", - "qcow2", NULL); - if (virCommandRun(cmd, NULL) < 0) - ret = -1; - /* Qcow2 file with missing backing file but specified type */ - TEST_CHAIN("qcow2-qcow2_missing", absqcow2, VIR_STORAGE_FILE_QCOW2, EXP_FAIL); + TEST_CHAIN("qcow2-qcow2_missing", + abs_srcdir "/virstoragetestdata/images/qcow2_qcow2-missing.qcow2", + VIR_STORAGE_FILE_QCOW2, EXP_FAIL); /* Qcow2 file with backing protocol instead of file */ TEST_CHAIN("qcow2-qcow2_nbd-raw", diff --git a/tests/virstoragetestdata/images/qcow2_qcow2-missing.qcow2 b/tests/virstoragetestdata/images/qcow2_qcow2-missing.qcow2 new file mode 100644 index 0000000000000000000000000000000000000000..cb9afb25dcd0b489fe848160255d9e5b427ddf0f GIT binary patch literal 196616 zcmeIuOHPA87y#gb>fR%;cIhEZOx(C~O(`l#1*9~!t~{T|@DwI)oW9by5SuQW4>HWa z{14{4yT17jA&laPS9%d2=W(p&c%5yg5R&y`8?}AgeA`9*J+F$iyY0{A<wsnfzZA{l zDlVQzU-z;6dkB-N>zCQM>UW{Tb5b;2H*fnxGt%<4FS|OQW|O?nvxjP04mKDS&2!t8 zvsu;DS-)(Dqa)R-emyBC+3i(U)_qr%vw;RlnC5TGtScXiW?uJ0q3bGXh%(Q4`)}a3 zXPR{RBKvjbfxp>rjhn~$p*{9lRs;wTAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBly zK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF z5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk z1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs z0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZ zfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PGjrKzcGKaS#Fo z2oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N z0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+ z009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBly zK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF z5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk z1PBlyK!5-N0t5&UAV7cs0RjXF5I9yK37h-ae0c;25FkK+009C72oNAZfB*pk1PBly zK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF z5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk z1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs z0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZ zfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&U IAaGIwKRetu*Z=?k literal 0 HcmV?d00001 -- 2.31.1

We've already added a 'raw' file to the example image directory so we can use that instead of formatting one. Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- tests/virstoragetest.c | 8 ++++++-- tests/virstoragetestdata/out/raw-auto | 2 +- tests/virstoragetestdata/out/raw-raw | 2 +- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/tests/virstoragetest.c b/tests/virstoragetest.c index 34aff3e6dd..dcb5a8a427 100644 --- a/tests/virstoragetest.c +++ b/tests/virstoragetest.c @@ -504,8 +504,12 @@ mymain(void) TEST_CHAIN("missing", "bogus", VIR_STORAGE_FILE_RAW, EXP_FAIL); /* Raw image, whether with right format or no specified format */ - TEST_CHAIN("raw-raw", absraw, VIR_STORAGE_FILE_RAW, EXP_PASS); - TEST_CHAIN("raw-auto", absraw, VIR_STORAGE_FILE_AUTO, EXP_PASS); + TEST_CHAIN("raw-raw", + abs_srcdir "/virstoragetestdata/images/raw", + VIR_STORAGE_FILE_RAW, EXP_PASS); + TEST_CHAIN("raw-auto", + abs_srcdir "/virstoragetestdata/images/raw", + VIR_STORAGE_FILE_AUTO, EXP_PASS); /* Qcow2 file with relative raw backing, format provided */ TEST_CHAIN("qcow2-qcow2_raw-raw-relative", absqcow2, VIR_STORAGE_FILE_QCOW2, EXP_PASS); diff --git a/tests/virstoragetestdata/out/raw-auto b/tests/virstoragetestdata/out/raw-auto index 8d6c525896..d98b6e8bf5 100644 --- a/tests/virstoragetestdata/out/raw-auto +++ b/tests/virstoragetestdata/out/raw-auto @@ -1,4 +1,4 @@ -path:ABS_BUILDDIR/virstoragedata/raw +path:ABS_SRCDIR/virstoragetestdata/images/raw backingStoreRaw: <null> capacity: 0 encryption: 0 diff --git a/tests/virstoragetestdata/out/raw-raw b/tests/virstoragetestdata/out/raw-raw index 8d6c525896..d98b6e8bf5 100644 --- a/tests/virstoragetestdata/out/raw-raw +++ b/tests/virstoragetestdata/out/raw-raw @@ -1,4 +1,4 @@ -path:ABS_BUILDDIR/virstoragedata/raw +path:ABS_SRCDIR/virstoragetestdata/images/raw backingStoreRaw: <null> capacity: 0 encryption: 0 -- 2.31.1

Use prepared test images instead to simplify and clarify the code instead of rewriting existing images multiple times. Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- tests/virstoragetest.c | 39 +++--------------- ...2_qcow2-qcow2-symlink_raw-raw-reldir.qcow2 | Bin 0 -> 196616 bytes .../images/qcow2_raw-raw-reldir.qcow2 | Bin 0 -> 196616 bytes tests/virstoragetestdata/images/sub/link1 | 1 + tests/virstoragetestdata/images/sub/link2 | 1 + tests/virstoragetestdata/out/qcow2-symlinks | 6 +-- 6 files changed, 10 insertions(+), 37 deletions(-) create mode 100644 tests/virstoragetestdata/images/qcow2_qcow2-qcow2-symlink_raw-raw-reldir.qcow2 create mode 100644 tests/virstoragetestdata/images/qcow2_raw-raw-reldir.qcow2 create mode 120000 tests/virstoragetestdata/images/sub/link1 create mode 120000 tests/virstoragetestdata/images/sub/link2 diff --git a/tests/virstoragetest.c b/tests/virstoragetest.c index dcb5a8a427..15296cc14f 100644 --- a/tests/virstoragetest.c +++ b/tests/virstoragetest.c @@ -42,8 +42,6 @@ VIR_LOG_INIT("tests.storagetest"); * raw: 1024-byte raw file * qcow2: qcow2 file with 'raw' as backing * wrap: qcow2 file with 'qcow2' as backing - * sub/link1: symlink to qcow2 - * sub/link2: symlink to wrap * * Relative names to these files are known at compile time, but absolute * names depend on where the test is run; for convenience, @@ -54,7 +52,6 @@ static char *qemuimg; static char *absraw; static char *absqcow2; static char *abswrap; -static char *abslink2; static void testCleanupImages(void) @@ -63,7 +60,6 @@ testCleanupImages(void) VIR_FREE(absraw); VIR_FREE(absqcow2); VIR_FREE(abswrap); - VIR_FREE(abslink2); if (chdir(abs_builddir) < 0) { fprintf(stderr, "unable to return to correct directory, refusing to " @@ -133,10 +129,9 @@ testPrepImages(void) absraw = g_strdup_printf("%s/raw", datadir); absqcow2 = g_strdup_printf("%s/qcow2", datadir); abswrap = g_strdup_printf("%s/wrap", datadir); - abslink2 = g_strdup_printf("%s/sub/link2", datadir); - if (g_mkdir_with_parents(datadir "/sub", 0777) < 0) { - fprintf(stderr, "unable to create directory %s\n", datadir "/sub"); + if (g_mkdir_with_parents(datadir, 0777) < 0) { + fprintf(stderr, "unable to create directory %s\n", datadir); goto cleanup; } @@ -177,15 +172,6 @@ testPrepImages(void) if (virCommandRun(cmd, NULL) < 0) goto skip; -#ifdef WITH_SYMLINK - /* Create some symlinks in a sub-directory. */ - if (symlink("../qcow2", datadir "/sub/link1") < 0 || - symlink("../wrap", datadir "/sub/link2") < 0) { - fprintf(stderr, "unable to create symlink"); - goto cleanup; - } -#endif - ret = 0; cleanup: if (ret) @@ -552,25 +538,10 @@ mymain(void) TEST_CHAIN("directory-none", abs_srcdir "/virstoragetestdata/images/", VIR_STORAGE_FILE_NONE, EXP_PASS); TEST_CHAIN("directory-dir", abs_srcdir "/virstoragetestdata/images/", VIR_STORAGE_FILE_DIR, EXP_PASS); -#ifdef WITH_SYMLINK - /* Rewrite qcow2 and wrap file to use backing names relative to a - * symlink from a different directory */ - virCommandFree(cmd); - cmd = virCommandNewArgList(qemuimg, "rebase", "-u", "-f", "qcow2", - "-F", "raw", "-b", "../raw", "qcow2", NULL); - if (virCommandRun(cmd, NULL) < 0) - ret = -1; - - virCommandFree(cmd); - cmd = virCommandNewArgList(qemuimg, "rebase", "-u", "-f", "qcow2", - "-F", "qcow2", "-b", "../sub/link1", "wrap", - NULL); - if (virCommandRun(cmd, NULL) < 0) - ret = -1; - /* Behavior of symlinks to qcow2 with relative backing files */ - TEST_CHAIN("qcow2-symlinks", abslink2, VIR_STORAGE_FILE_QCOW2, EXP_PASS); -#endif + TEST_CHAIN("qcow2-symlinks", + abs_srcdir "/virstoragetestdata/images/sub/link2", + VIR_STORAGE_FILE_QCOW2, EXP_PASS); /* Behavior of an infinite loop chain */ TEST_CHAIN("qcow2-qcow2_infinite-self", diff --git a/tests/virstoragetestdata/images/qcow2_qcow2-qcow2-symlink_raw-raw-reldir.qcow2 b/tests/virstoragetestdata/images/qcow2_qcow2-qcow2-symlink_raw-raw-reldir.qcow2 new file mode 100644 index 0000000000000000000000000000000000000000..9620410502f21101fb64d0314cb4a0c710870dd2 GIT binary patch literal 196616 zcmeIuJ5Iwu5CG7%104lNa7_V%Lm(m1P*FRHBP@b#97iEkoR4F03M3jfKOu@3`aE0f z8Sjo~z3=Y&<|~9Sh$CL<X?&c-v5N6J+Jq32b+WD6zHR1q75n3=NwZu2Sf0Jd{P=lP zFRo(pF!;QW?cYKemu<JqhGn-a?T^W*Zrgd&{r8Ksc<G9^%BR^l@A7O?PK(|R2BZ3^ zX^YvctgEbBHvQF+YSq6Q7vt>qDl4k4EsI&t21%Iaugk10CZl>@b$zAlE@_A|PkHla z;dak7Y4b()>&!iW^Rsk*eleR5FQ#Snc=<CcBS3%v0RjXF5FkK+009C72oNAZfB*pk z1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs z0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZ zfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&U zAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C7 z2oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK;U2m z(t|mvgAyP>fB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBly zK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF z5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk z1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs z0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZ zfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+z&?Q_Z0>#Q<_QoWK!5-N0t5&UAV7cs z0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZ zfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&U zAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C7 z2oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N z0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+ Q009C72oNAZ;GhJ)0p$faq5uE@ literal 0 HcmV?d00001 diff --git a/tests/virstoragetestdata/images/qcow2_raw-raw-reldir.qcow2 b/tests/virstoragetestdata/images/qcow2_raw-raw-reldir.qcow2 new file mode 100644 index 0000000000000000000000000000000000000000..1e32c78a46e0ca9881e85ea9e36aef0a67fccaf7 GIT binary patch literal 196616 zcmeIvO-_SA6ae4>jBAg;+C@z~go%k8SFW+pNKz@GG>R+F=P^8mi5sVXX<QWD_Zu?2 zVdn9M`MAHi{SF~yvB#EP#M^o7>loYFHiVFD2D_}?({^s3aXhYzwEN}H;qoJnv#xmA zOg&{^53&4v2xZ;%L;hIz`_%E6Oc!0ZYWx4bkyfvL)iuRDFN?m&XZ5@q-5{GTp4+Zk zF6%{;_d`3L9jVs!o3bkNyX(Aa`mU~)BO4@PUc3!?SIwr2Rnw29ZmOgq$~+hCpNYFY z(<BP#zs@}JHHW3i<ZAzG4wFU%2oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+ z009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBly zK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF z5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk z1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs z0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXFoQ^<xI!AR<0t5&U zAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C7 z2oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N z0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+ z009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBly zK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF z5FkK+009C72oNAZfB*pk1PBl~B9Mgbb!6Ez0RjXF5FkK+009C72oNAZfB*pk1PBly zK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF z5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk z1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs z0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZ zfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5)0 GmcS44-!<w0 literal 0 HcmV?d00001 diff --git a/tests/virstoragetestdata/images/sub/link1 b/tests/virstoragetestdata/images/sub/link1 new file mode 120000 index 0000000000..35320292b1 --- /dev/null +++ b/tests/virstoragetestdata/images/sub/link1 @@ -0,0 +1 @@ +../qcow2_raw-raw-reldir.qcow2 \ No newline at end of file diff --git a/tests/virstoragetestdata/images/sub/link2 b/tests/virstoragetestdata/images/sub/link2 new file mode 120000 index 0000000000..6fc44056b2 --- /dev/null +++ b/tests/virstoragetestdata/images/sub/link2 @@ -0,0 +1 @@ +../qcow2_qcow2-qcow2-symlink_raw-raw-reldir.qcow2 \ No newline at end of file diff --git a/tests/virstoragetestdata/out/qcow2-symlinks b/tests/virstoragetestdata/out/qcow2-symlinks index ed37f61e9f..34c3a37c2e 100644 --- a/tests/virstoragetestdata/out/qcow2-symlinks +++ b/tests/virstoragetestdata/out/qcow2-symlinks @@ -1,4 +1,4 @@ -path:ABS_BUILDDIR/virstoragedata/sub/link2 +path:ABS_SRCDIR/virstoragetestdata/images/sub/link2 backingStoreRaw: ../sub/link1 capacity: 1024 encryption: 0 @@ -8,7 +8,7 @@ format:14 protocol:none hostname:<null> -path:ABS_BUILDDIR/virstoragedata/sub/../sub/link1 +path:ABS_SRCDIR/virstoragetestdata/images/sub/../sub/link1 backingStoreRaw: ../raw capacity: 1024 encryption: 0 @@ -18,7 +18,7 @@ format:14 protocol:none hostname:<null> -path:ABS_BUILDDIR/virstoragedata/sub/../sub/../raw +path:ABS_SRCDIR/virstoragetestdata/images/sub/../sub/../raw backingStoreRaw: <null> capacity: 0 encryption: 0 -- 2.31.1

More preparation for eliminating image rewriting. Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- tests/virstoragetest.c | 8 ++++++-- .../images/qcow2_raw-raw-relative.qcow2 | Bin 0 -> 196616 bytes .../out/qcow2-auto_raw-raw-relative | 2 +- .../out/qcow2-qcow2_raw-raw-relative | 4 ++-- 4 files changed, 9 insertions(+), 5 deletions(-) create mode 100644 tests/virstoragetestdata/images/qcow2_raw-raw-relative.qcow2 diff --git a/tests/virstoragetest.c b/tests/virstoragetest.c index 15296cc14f..9af8795492 100644 --- a/tests/virstoragetest.c +++ b/tests/virstoragetest.c @@ -498,8 +498,12 @@ mymain(void) VIR_STORAGE_FILE_AUTO, EXP_PASS); /* Qcow2 file with relative raw backing, format provided */ - TEST_CHAIN("qcow2-qcow2_raw-raw-relative", absqcow2, VIR_STORAGE_FILE_QCOW2, EXP_PASS); - TEST_CHAIN("qcow2-auto_raw-raw-relative", absqcow2, VIR_STORAGE_FILE_AUTO, EXP_PASS); + TEST_CHAIN("qcow2-qcow2_raw-raw-relative", + abs_srcdir "/virstoragetestdata/images/qcow2_raw-raw-relative.qcow2", + VIR_STORAGE_FILE_QCOW2, EXP_PASS); + TEST_CHAIN("qcow2-auto_raw-raw-relative", + abs_srcdir "/virstoragetestdata/images/qcow2_raw-raw-relative.qcow2", + VIR_STORAGE_FILE_AUTO, EXP_PASS); /* Rewrite qcow2 file to use absolute backing name */ virCommandFree(cmd); diff --git a/tests/virstoragetestdata/images/qcow2_raw-raw-relative.qcow2 b/tests/virstoragetestdata/images/qcow2_raw-raw-relative.qcow2 new file mode 100644 index 0000000000000000000000000000000000000000..492d9bca1902564ba0128fee27122f5beb0e9e32 GIT binary patch literal 196616 zcmeIuyAi@L3;<B&GeG8G5bh}109K&Mv0}zx4H{&W1{R2mC!cJ~E~I<c^W_~8V`ht6 z=9IZ)X3TX&4Bt!pX;D?}^%Ae=Y0K;MxUc(59sl*ur-A?h0t5&UAV7cs0RjXF5FkK+ z009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBly zK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF z5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk z1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs z0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZ zfB*pk1o{#f`x?hI1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBly zK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF z5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk z1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs z0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZ zfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNA}fWQ#74rr|<0RjXF5FkK+ z009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBly zK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF z5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk z1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs z0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZ WfB*pk1PBlyK!5-N0t5*3C-4E}a0f>K literal 0 HcmV?d00001 diff --git a/tests/virstoragetestdata/out/qcow2-auto_raw-raw-relative b/tests/virstoragetestdata/out/qcow2-auto_raw-raw-relative index 4a01b24589..f9afc138f0 100644 --- a/tests/virstoragetestdata/out/qcow2-auto_raw-raw-relative +++ b/tests/virstoragetestdata/out/qcow2-auto_raw-raw-relative @@ -1,4 +1,4 @@ -path:ABS_BUILDDIR/virstoragedata/qcow2 +path:ABS_SRCDIR/virstoragetestdata/images/qcow2_raw-raw-relative.qcow2 backingStoreRaw: <null> capacity: 0 encryption: 0 diff --git a/tests/virstoragetestdata/out/qcow2-qcow2_raw-raw-relative b/tests/virstoragetestdata/out/qcow2-qcow2_raw-raw-relative index a1fb142e98..6e3f7ab339 100644 --- a/tests/virstoragetestdata/out/qcow2-qcow2_raw-raw-relative +++ b/tests/virstoragetestdata/out/qcow2-qcow2_raw-raw-relative @@ -1,4 +1,4 @@ -path:ABS_BUILDDIR/virstoragedata/qcow2 +path:ABS_SRCDIR/virstoragetestdata/images/qcow2_raw-raw-relative.qcow2 backingStoreRaw: raw capacity: 1024 encryption: 0 @@ -8,7 +8,7 @@ format:14 protocol:none hostname:<null> -path:ABS_BUILDDIR/virstoragedata/raw +path:ABS_SRCDIR/virstoragetestdata/images/raw backingStoreRaw: <null> capacity: 0 encryption: 0 -- 2.31.1

We have 3 test cases for this currently: 1) "qcow2->raw" 1.1) VIR_STORAGE_FILE_QCOW2 as top level format 1.2) VIR_STORAGE_FILE_AUTO as top level format 2) "wrap->qcow2->raw" whith just VIR_STORAGE_FILE_QCOW2 This patch adds also testing of VIR_STORAGE_FILE_AUTO for case 2) and removes both 1) subcases as they are being actually tested as part of 2). Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- tests/virstoragetest.c | 7 ++----- ...raw-raw => qcow2-auto_qcow2-qcow2_raw-raw} | 2 +- .../out/qcow2-qcow2_raw-raw | 19 ------------------- 3 files changed, 3 insertions(+), 25 deletions(-) rename tests/virstoragetestdata/out/{qcow2-auto_raw-raw => qcow2-auto_qcow2-qcow2_raw-raw} (74%) delete mode 100644 tests/virstoragetestdata/out/qcow2-qcow2_raw-raw diff --git a/tests/virstoragetest.c b/tests/virstoragetest.c index 9af8795492..475ff23ce0 100644 --- a/tests/virstoragetest.c +++ b/tests/virstoragetest.c @@ -512,12 +512,9 @@ mymain(void) if (virCommandRun(cmd, NULL) < 0) ret = -1; - /* Qcow2 file with raw as absolute backing, backing format provided */ - TEST_CHAIN("qcow2-qcow2_raw-raw", absqcow2, VIR_STORAGE_FILE_QCOW2, EXP_PASS); - TEST_CHAIN("qcow2-auto_raw-raw", absqcow2, VIR_STORAGE_FILE_AUTO, EXP_PASS); - - /* qcow2 with a longer backing chain */ + /* qcow2 chain with absolute backing formatted with a real qemu-img */ TEST_CHAIN("qcow2-qcow2_qcow2-qcow2_raw-raw", abswrap, VIR_STORAGE_FILE_QCOW2, EXP_PASS); + TEST_CHAIN("qcow2-auto_qcow2-qcow2_raw-raw", abswrap, VIR_STORAGE_FILE_AUTO, EXP_PASS); /* Qcow2 file with missing backing file but specified type */ TEST_CHAIN("qcow2-qcow2_missing", diff --git a/tests/virstoragetestdata/out/qcow2-auto_raw-raw b/tests/virstoragetestdata/out/qcow2-auto_qcow2-qcow2_raw-raw similarity index 74% rename from tests/virstoragetestdata/out/qcow2-auto_raw-raw rename to tests/virstoragetestdata/out/qcow2-auto_qcow2-qcow2_raw-raw index 4a01b24589..2ea087592e 100644 --- a/tests/virstoragetestdata/out/qcow2-auto_raw-raw +++ b/tests/virstoragetestdata/out/qcow2-auto_qcow2-qcow2_raw-raw @@ -1,4 +1,4 @@ -path:ABS_BUILDDIR/virstoragedata/qcow2 +path:ABS_BUILDDIR/virstoragedata/wrap backingStoreRaw: <null> capacity: 0 encryption: 0 diff --git a/tests/virstoragetestdata/out/qcow2-qcow2_raw-raw b/tests/virstoragetestdata/out/qcow2-qcow2_raw-raw deleted file mode 100644 index 57ce62a376..0000000000 --- a/tests/virstoragetestdata/out/qcow2-qcow2_raw-raw +++ /dev/null @@ -1,19 +0,0 @@ -path:ABS_BUILDDIR/virstoragedata/qcow2 -backingStoreRaw: ABS_BUILDDIR/virstoragedata/raw -capacity: 1024 -encryption: 0 -relPath:<null> -type:1 -format:14 -protocol:none -hostname:<null> - -path:ABS_BUILDDIR/virstoragedata/raw -backingStoreRaw: <null> -capacity: 0 -encryption: 0 -relPath:<null> -type:1 -format:1 -protocol:none -hostname:<null> -- 2.31.1

For testing of real images formatted by 'qemu-img' it's now sufficient to format them once without the need to rewrtie them since we use the real images only for testing of one scenario. This allows us to also remove moust of the global variables holding the path to the images which was necessary when they were being rewritten. Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- tests/virstoragetest.c | 33 ++++----------------------------- 1 file changed, 4 insertions(+), 29 deletions(-) diff --git a/tests/virstoragetest.c b/tests/virstoragetest.c index 475ff23ce0..1ee7bb5230 100644 --- a/tests/virstoragetest.c +++ b/tests/virstoragetest.c @@ -37,28 +37,11 @@ VIR_LOG_INIT("tests.storagetest"); #define datadir abs_builddir "/virstoragedata" -/* This test creates the following files, all in datadir: - - * raw: 1024-byte raw file - * qcow2: qcow2 file with 'raw' as backing - * wrap: qcow2 file with 'qcow2' as backing - * - * Relative names to these files are known at compile time, but absolute - * names depend on where the test is run; for convenience, - * we pre-populate the computation of these names for use during the test. -*/ - -static char *qemuimg; -static char *absraw; -static char *absqcow2; static char *abswrap; static void testCleanupImages(void) { - VIR_FREE(qemuimg); - VIR_FREE(absraw); - VIR_FREE(absqcow2); VIR_FREE(abswrap); if (chdir(abs_builddir) < 0) { @@ -106,8 +89,10 @@ testPrepImages(void) bool compat = false; g_autoptr(virCommand) cmd = NULL; g_autofree char *buf = NULL; + g_autofree char *absraw = g_strdup_printf("%s/raw", datadir); + g_autofree char *absqcow2 = g_strdup_printf("%s/qcow2", datadir); + g_autofree char *qemuimg = virFindFileInPath("qemu-img"); - qemuimg = virFindFileInPath("qemu-img"); if (!qemuimg) goto skip; @@ -126,8 +111,6 @@ testPrepImages(void) compat = true; VIR_FREE(buf); - absraw = g_strdup_printf("%s/raw", datadir); - absqcow2 = g_strdup_printf("%s/qcow2", datadir); abswrap = g_strdup_printf("%s/wrap", datadir); if (g_mkdir_with_parents(datadir, 0777) < 0) { @@ -158,7 +141,7 @@ testPrepImages(void) /* Make sure our later uses of 'qemu-img rebase' will work */ virCommandFree(cmd); cmd = virCommandNewArgList(qemuimg, "rebase", "-u", "-f", "qcow2", - "-F", "raw", "-b", "raw", "qcow2", NULL); + "-F", "raw", "-b", absraw, "qcow2", NULL); if (virCommandRun(cmd, NULL) < 0) goto skip; @@ -469,7 +452,6 @@ mymain(void) virStorageSource *chain = &fakeChain[0]; virStorageSource *chain2 = &fakeChain[1]; virStorageSource *chain3 = &fakeChain[2]; - g_autoptr(virCommand) cmd = NULL; if (storageRegisterAll() < 0) return EXIT_FAILURE; @@ -505,13 +487,6 @@ mymain(void) abs_srcdir "/virstoragetestdata/images/qcow2_raw-raw-relative.qcow2", VIR_STORAGE_FILE_AUTO, EXP_PASS); - /* Rewrite qcow2 file to use absolute backing name */ - virCommandFree(cmd); - cmd = virCommandNewArgList(qemuimg, "rebase", "-u", "-f", "qcow2", - "-F", "raw", "-b", absraw, "qcow2", NULL); - if (virCommandRun(cmd, NULL) < 0) - ret = -1; - /* qcow2 chain with absolute backing formatted with a real qemu-img */ TEST_CHAIN("qcow2-qcow2_qcow2-qcow2_raw-raw", abswrap, VIR_STORAGE_FILE_QCOW2, EXP_PASS); TEST_CHAIN("qcow2-auto_qcow2-qcow2_raw-raw", abswrap, VIR_STORAGE_FILE_AUTO, EXP_PASS); -- 2.31.1

On a Thursday in 2021, Peter Krempa wrote:
For testing of real images formatted by 'qemu-img' it's now sufficient to format them once without the need to rewrtie them since we use the real images only for testing of one scenario.
This allows us to also remove moust of the global variables holding the
*most Jano
path to the images which was necessary when they were being rewritten.
Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- tests/virstoragetest.c | 33 ++++----------------------------- 1 file changed, 4 insertions(+), 29 deletions(-)

Create it with the appropriate backing file path rather than using another instance of 'qemu-img rebase'. Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- tests/virstoragetest.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/tests/virstoragetest.c b/tests/virstoragetest.c index 1ee7bb5230..9a7905e28d 100644 --- a/tests/virstoragetest.c +++ b/tests/virstoragetest.c @@ -132,18 +132,15 @@ testPrepImages(void) /* Create a qcow2 wrapping relative raw; later on, we modify its * metadata to test other configurations */ virCommandFree(cmd); - cmd = virCommandNewArgList(qemuimg, "create", "-f", "qcow2", NULL); - virCommandAddArgFormat(cmd, "-obacking_file=raw,backing_fmt=raw%s", - compat ? ",compat=0.10" : ""); + cmd = virCommandNewArgList(qemuimg, "create", + "-f", "qcow2", + "-F", "raw", + "-b", absraw, NULL); + if (compat) + virCommandAddArgList(cmd, "-o", "compat=0.10", NULL); virCommandAddArg(cmd, "qcow2"); if (virCommandRun(cmd, NULL) < 0) goto skip; - /* Make sure our later uses of 'qemu-img rebase' will work */ - virCommandFree(cmd); - cmd = virCommandNewArgList(qemuimg, "rebase", "-u", "-f", "qcow2", - "-F", "raw", "-b", absraw, "qcow2", NULL); - if (virCommandRun(cmd, NULL) < 0) - goto skip; /* Create a second qcow2 wrapping the first, to be sure that we * can correctly avoid insecure probing. */ -- 2.31.1

All supported qemu versions have the parameter, so we don't need to check. This allows us to simplify the code used for formating real images for virstoragetest. Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- tests/virstoragetest.c | 31 +++++++++---------------------- 1 file changed, 9 insertions(+), 22 deletions(-) diff --git a/tests/virstoragetest.c b/tests/virstoragetest.c index 9a7905e28d..955ac64e0b 100644 --- a/tests/virstoragetest.c +++ b/tests/virstoragetest.c @@ -86,7 +86,6 @@ static int testPrepImages(void) { int ret = EXIT_FAILURE; - bool compat = false; g_autoptr(virCommand) cmd = NULL; g_autofree char *buf = NULL; g_autofree char *absraw = g_strdup_printf("%s/raw", datadir); @@ -99,18 +98,6 @@ testPrepImages(void) /* Clean up from any earlier failed tests */ virFileDeleteTree(datadir); - /* See if qemu-img supports '-o compat=xxx'. If so, we force the - * use of both v2 and v3 files; if not, it is v2 only but the test - * still works. */ - cmd = virCommandNewArgList(qemuimg, "create", "-f", "qcow2", - "-o?", "/dev/null", NULL); - virCommandSetOutputBuffer(cmd, &buf); - if (virCommandRun(cmd, NULL) < 0) - goto skip; - if (strstr(buf, "compat ")) - compat = true; - VIR_FREE(buf); - abswrap = g_strdup_printf("%s/wrap", datadir); if (g_mkdir_with_parents(datadir, 0777) < 0) { @@ -131,24 +118,24 @@ testPrepImages(void) /* Create a qcow2 wrapping relative raw; later on, we modify its * metadata to test other configurations */ - virCommandFree(cmd); cmd = virCommandNewArgList(qemuimg, "create", "-f", "qcow2", "-F", "raw", - "-b", absraw, NULL); - if (compat) - virCommandAddArgList(cmd, "-o", "compat=0.10", NULL); - virCommandAddArg(cmd, "qcow2"); + "-b", absraw, + "-o", "compat=0.10", + absqcow2, NULL); if (virCommandRun(cmd, NULL) < 0) goto skip; /* Create a second qcow2 wrapping the first, to be sure that we * can correctly avoid insecure probing. */ virCommandFree(cmd); - cmd = virCommandNewArgList(qemuimg, "create", "-f", "qcow2", NULL); - virCommandAddArgFormat(cmd, "-obacking_file=%s,backing_fmt=qcow2%s", - absqcow2, compat ? ",compat=1.1" : ""); - virCommandAddArg(cmd, "wrap"); + cmd = virCommandNewArgList(qemuimg, "create", + "-f", "qcow2", + "-F", "qcow2", + "-b", absqcow2, + "-o", "compat=1.1", + abswrap, NULL); if (virCommandRun(cmd, NULL) < 0) goto skip; -- 2.31.1

Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- tests/virstoragetest.c | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/tests/virstoragetest.c b/tests/virstoragetest.c index 955ac64e0b..90dde512cf 100644 --- a/tests/virstoragetest.c +++ b/tests/virstoragetest.c @@ -86,7 +86,8 @@ static int testPrepImages(void) { int ret = EXIT_FAILURE; - g_autoptr(virCommand) cmd = NULL; + g_autoptr(virCommand) cmdqcow2 = NULL; + g_autoptr(virCommand) cmdwrap = NULL; g_autofree char *buf = NULL; g_autofree char *absraw = g_strdup_printf("%s/raw", datadir); g_autofree char *absqcow2 = g_strdup_printf("%s/qcow2", datadir); @@ -118,25 +119,24 @@ testPrepImages(void) /* Create a qcow2 wrapping relative raw; later on, we modify its * metadata to test other configurations */ - cmd = virCommandNewArgList(qemuimg, "create", - "-f", "qcow2", - "-F", "raw", - "-b", absraw, - "-o", "compat=0.10", - absqcow2, NULL); - if (virCommandRun(cmd, NULL) < 0) + cmdqcow2 = virCommandNewArgList(qemuimg, "create", + "-f", "qcow2", + "-F", "raw", + "-b", absraw, + "-o", "compat=0.10", + absqcow2, NULL); + if (virCommandRun(cmdqcow2, NULL) < 0) goto skip; /* Create a second qcow2 wrapping the first, to be sure that we * can correctly avoid insecure probing. */ - virCommandFree(cmd); - cmd = virCommandNewArgList(qemuimg, "create", - "-f", "qcow2", - "-F", "qcow2", - "-b", absqcow2, - "-o", "compat=1.1", - abswrap, NULL); - if (virCommandRun(cmd, NULL) < 0) + cmdwrap = virCommandNewArgList(qemuimg, "create", + "-f", "qcow2", + "-F", "qcow2", + "-b", absqcow2, + "-o", "compat=1.1", + abswrap, NULL); + if (virCommandRun(cmdwrap, NULL) < 0) goto skip; ret = 0; -- 2.31.1

Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- tests/virstoragetest.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/virstoragetest.c b/tests/virstoragetest.c index 90dde512cf..c258bc1709 100644 --- a/tests/virstoragetest.c +++ b/tests/virstoragetest.c @@ -86,9 +86,9 @@ static int testPrepImages(void) { int ret = EXIT_FAILURE; + g_autoptr(virCommand) cmdraw = NULL; g_autoptr(virCommand) cmdqcow2 = NULL; g_autoptr(virCommand) cmdwrap = NULL; - g_autofree char *buf = NULL; g_autofree char *absraw = g_strdup_printf("%s/raw", datadir); g_autofree char *absqcow2 = g_strdup_printf("%s/qcow2", datadir); g_autofree char *qemuimg = virFindFileInPath("qemu-img"); @@ -111,11 +111,11 @@ testPrepImages(void) goto cleanup; } - buf = g_strdup_printf("%1024d", 0); - if (virFileWriteStr("raw", buf, 0600) < 0) { - fprintf(stderr, "unable to create raw file\n"); - goto cleanup; - } + cmdraw = virCommandNewArgList(qemuimg, "create", + "-f", "raw", + absraw, "1k", NULL); + if (virCommandRun(cmdraw, NULL) < 0) + goto skip; /* Create a qcow2 wrapping relative raw; later on, we modify its * metadata to test other configurations */ -- 2.31.1

Prepare the test runner for skipping individual tests if images can't be formatted rather than the whole virstoragetest. Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- tests/virstoragetest.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tests/virstoragetest.c b/tests/virstoragetest.c index c258bc1709..d9ab630600 100644 --- a/tests/virstoragetest.c +++ b/tests/virstoragetest.c @@ -176,6 +176,11 @@ testStorageChain(const void *args) g_autofree char *expectpath = g_strdup_printf("%s/virstoragetestdata/out/%s", abs_srcdir, data->testname); + /* If the filename is NULL it means that the images couldn't be created, + * thus skip this particular test. */ + if (!data->start) + return EXIT_AM_SKIP; + meta = testStorageFileGetMetadata(data->start, data->format, -1, -1); if (!meta) { if (data->flags & EXP_FAIL) { -- 2.31.1

We have plenty of other work to do in this test. Skip only the real image testing case when we can't find qemu-img or it failed to format the image. This allows us to also remove the last global variable in the test and move the creation and cleanup of the images closer to the actual test. Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- tests/virstoragetest.c | 73 ++++++++++++++++-------------------------- 1 file changed, 27 insertions(+), 46 deletions(-) diff --git a/tests/virstoragetest.c b/tests/virstoragetest.c index d9ab630600..bbeb5ecd88 100644 --- a/tests/virstoragetest.c +++ b/tests/virstoragetest.c @@ -37,13 +37,9 @@ VIR_LOG_INIT("tests.storagetest"); #define datadir abs_builddir "/virstoragedata" -static char *abswrap; - static void testCleanupImages(void) { - VIR_FREE(abswrap); - if (chdir(abs_builddir) < 0) { fprintf(stderr, "unable to return to correct directory, refusing to " "clean up %s\n", datadir); @@ -82,75 +78,60 @@ testStorageFileGetMetadata(const char *path, return g_steal_pointer(&def); } -static int +static char * testPrepImages(void) { - int ret = EXIT_FAILURE; g_autoptr(virCommand) cmdraw = NULL; g_autoptr(virCommand) cmdqcow2 = NULL; g_autoptr(virCommand) cmdwrap = NULL; g_autofree char *absraw = g_strdup_printf("%s/raw", datadir); g_autofree char *absqcow2 = g_strdup_printf("%s/qcow2", datadir); + g_autofree char *abswrap = g_strdup_printf("%s/wrap", datadir); g_autofree char *qemuimg = virFindFileInPath("qemu-img"); if (!qemuimg) - goto skip; + return NULL; /* Clean up from any earlier failed tests */ virFileDeleteTree(datadir); - abswrap = g_strdup_printf("%s/wrap", datadir); - if (g_mkdir_with_parents(datadir, 0777) < 0) { - fprintf(stderr, "unable to create directory %s\n", datadir); - goto cleanup; - } - - if (chdir(datadir) < 0) { - fprintf(stderr, "unable to test relative backing chains\n"); - goto cleanup; + VIR_TEST_VERBOSE("unable to create directory '%s'\n", datadir); + return NULL; } + /* create the folowing real backing chain with qcow2 images with absolute + * backing and different qcow2 versions: + * datadir/raw <- datadir/qcow2 (qcow2v2) <- datadir/wrap (qcow2v3) */ cmdraw = virCommandNewArgList(qemuimg, "create", "-f", "raw", absraw, "1k", NULL); - if (virCommandRun(cmdraw, NULL) < 0) - goto skip; - /* Create a qcow2 wrapping relative raw; later on, we modify its - * metadata to test other configurations */ cmdqcow2 = virCommandNewArgList(qemuimg, "create", "-f", "qcow2", "-F", "raw", "-b", absraw, "-o", "compat=0.10", absqcow2, NULL); - if (virCommandRun(cmdqcow2, NULL) < 0) - goto skip; - /* Create a second qcow2 wrapping the first, to be sure that we - * can correctly avoid insecure probing. */ cmdwrap = virCommandNewArgList(qemuimg, "create", "-f", "qcow2", "-F", "qcow2", "-b", absqcow2, "-o", "compat=1.1", abswrap, NULL); - if (virCommandRun(cmdwrap, NULL) < 0) - goto skip; - ret = 0; - cleanup: - if (ret) - testCleanupImages(); - return ret; + if (virCommandRun(cmdraw, NULL) < 0 || + virCommandRun(cmdqcow2, NULL) < 0 || + virCommandRun(cmdwrap, NULL) < 0) { + VIR_TEST_VERBOSE("failed to create backing chain in '%s'\n", datadir); + return NULL; + } - skip: - fputs("qemu-img is too old; skipping this test\n", stderr); - ret = EXIT_AM_SKIP; - goto cleanup; + return g_steal_pointer(&abswrap); } + enum { EXP_PASS = 0, EXP_FAIL = 1, @@ -432,11 +413,12 @@ testBackingParse(const void *args) static int mymain(void) { - int ret; + int ret = 0; struct testChainData data; struct testLookupData data2; struct testPathRelativeBacking data4; struct testBackingParseData data5; + g_autofree char *realchain = NULL; virStorageSource fakeChain[4]; virStorageSource *chain = &fakeChain[0]; virStorageSource *chain2 = &fakeChain[1]; @@ -445,11 +427,6 @@ mymain(void) if (storageRegisterAll() < 0) return EXIT_FAILURE; - /* Prep some files with qemu-img; if that is not found on PATH, or - * if it lacks support for qcow2 and qed, skip this test. */ - if ((ret = testPrepImages()) != 0) - return ret; - #define TEST_CHAIN(testname, start, format, flags) \ do { \ data = (struct testChainData){ testname, start, format, flags }; \ @@ -477,8 +454,15 @@ mymain(void) VIR_STORAGE_FILE_AUTO, EXP_PASS); /* qcow2 chain with absolute backing formatted with a real qemu-img */ - TEST_CHAIN("qcow2-qcow2_qcow2-qcow2_raw-raw", abswrap, VIR_STORAGE_FILE_QCOW2, EXP_PASS); - TEST_CHAIN("qcow2-auto_qcow2-qcow2_raw-raw", abswrap, VIR_STORAGE_FILE_AUTO, EXP_PASS); + + /* Prep some files with qemu-img; if that is not found on PATH, the test + * using the data skips itself if the data can't be prepared */ + realchain = testPrepImages(); + + TEST_CHAIN("qcow2-qcow2_qcow2-qcow2_raw-raw", realchain, VIR_STORAGE_FILE_QCOW2, EXP_PASS); + TEST_CHAIN("qcow2-auto_qcow2-qcow2_raw-raw", realchain, VIR_STORAGE_FILE_AUTO, EXP_PASS); + + testCleanupImages(); /* Qcow2 file with missing backing file but specified type */ TEST_CHAIN("qcow2-qcow2_missing", @@ -1188,9 +1172,6 @@ mymain(void) #endif /* WITH_YAJL */ cleanup: - /* Final cleanup */ - testCleanupImages(); - return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE; } -- 2.31.1

Improve the error message and abort the test. Continuing here is not desired as without chdiring into the appropriate directory the test would fail anyways and worse could attempt stat-ing random files on the host. Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- tests/virstoragetest.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/virstoragetest.c b/tests/virstoragetest.c index bbeb5ecd88..513ffdeb41 100644 --- a/tests/virstoragetest.c +++ b/tests/virstoragetest.c @@ -502,8 +502,9 @@ mymain(void) /* setup data for backing chain lookup testing */ if (chdir(abs_srcdir "/virstoragetestdata/lookup") < 0) { - fprintf(stderr, "unable to test relative backing chains\n"); - goto cleanup; + VIR_TEST_VERBOSE("failed to chdir into '%s'\n", + abs_srcdir "/virstoragetestdata/lookup"); + return EXIT_FAILURE; } memset(fakeChain, 0, sizeof(fakeChain)); @@ -1171,7 +1172,6 @@ mymain(void) #endif /* WITH_YAJL */ - cleanup: return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE; } -- 2.31.1

There are important security implications when we'd misprobe those images. This commit reinstates the tests removed by commit 979d1ba3ae13 since 'qemu-img' refused to format them. With the new testing approach with stored images we won't run into that problem. Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- tests/virstoragetest.c | 14 +++++++++ tests/virstoragetestdata/images/qcow2 | Bin 0 -> 196616 bytes .../images/qcow2_qcow2-auto.qcow2 | Bin 0 -> 196616 bytes .../images/qcow2_qcow2-auto_qcow2-auto.qcow2 | Bin 0 -> 196616 bytes .../images/qcow2_qcow2-qcow2_qcow2-auto.qcow2 | Bin 0 -> 196616 bytes .../images/qcow2_qcow2-qcow2_raw-auto.qcow2 | Bin 0 -> 196616 bytes .../images/qcow2_raw-auto.qcow2 | Bin 0 -> 196616 bytes .../out/qcow2-qcow2_qcow2-auto | 19 ++++++++++++ .../out/qcow2-qcow2_qcow2-qcow2_qcow2-auto | 29 ++++++++++++++++++ .../out/qcow2-qcow2_qcow2-qcow2_raw-auto | 29 ++++++++++++++++++ 10 files changed, 91 insertions(+) create mode 100644 tests/virstoragetestdata/images/qcow2 create mode 100644 tests/virstoragetestdata/images/qcow2_qcow2-auto.qcow2 create mode 100644 tests/virstoragetestdata/images/qcow2_qcow2-auto_qcow2-auto.qcow2 create mode 100644 tests/virstoragetestdata/images/qcow2_qcow2-qcow2_qcow2-auto.qcow2 create mode 100644 tests/virstoragetestdata/images/qcow2_qcow2-qcow2_raw-auto.qcow2 create mode 100644 tests/virstoragetestdata/images/qcow2_raw-auto.qcow2 create mode 100644 tests/virstoragetestdata/out/qcow2-qcow2_qcow2-auto create mode 100644 tests/virstoragetestdata/out/qcow2-qcow2_qcow2-qcow2_qcow2-auto create mode 100644 tests/virstoragetestdata/out/qcow2-qcow2_qcow2-qcow2_raw-auto diff --git a/tests/virstoragetest.c b/tests/virstoragetest.c index 513ffdeb41..ec185d8660 100644 --- a/tests/virstoragetest.c +++ b/tests/virstoragetest.c @@ -464,6 +464,20 @@ mymain(void) testCleanupImages(); + /* Test various combinations of qcow2 images with missing 'backing_format' */ + TEST_CHAIN("qcow2-qcow2_qcow2-qcow2_qcow2-auto", + abs_srcdir "/virstoragetestdata/images/qcow2_qcow2-qcow2_qcow2-auto.qcow2", + VIR_STORAGE_FILE_QCOW2, EXP_PASS); + TEST_CHAIN("qcow2-qcow2_qcow2-qcow2_raw-auto", + abs_srcdir "/virstoragetestdata/images/qcow2_qcow2-qcow2_raw-auto.qcow2", + VIR_STORAGE_FILE_QCOW2, EXP_PASS); + TEST_CHAIN("qcow2-qcow2_qcow2-auto_qcow2-auto", + abs_srcdir "/virstoragetestdata/images/qcow2_qcow2-auto_qcow2-auto.qcow2", + VIR_STORAGE_FILE_QCOW2, EXP_FAIL); + TEST_CHAIN("qcow2-qcow2_qcow2-auto", + abs_srcdir "/virstoragetestdata/images/qcow2_qcow2-auto.qcow2", + VIR_STORAGE_FILE_QCOW2, EXP_PASS); + /* Qcow2 file with missing backing file but specified type */ TEST_CHAIN("qcow2-qcow2_missing", abs_srcdir "/virstoragetestdata/images/qcow2_qcow2-missing.qcow2", diff --git a/tests/virstoragetestdata/images/qcow2 b/tests/virstoragetestdata/images/qcow2 new file mode 100644 index 0000000000000000000000000000000000000000..31a144e4b947692c834363797fa34457edc2094c GIT binary patch literal 196616 zcmeIuK~94}6adhH_5dDX&fp<TOx(C~jb$21S|D_c)|JOLabsH~(M8dHAA}j^|Id8p z-QV1Ph7cBq=jU}bE|ycQIK50&<7ynIiu3bvlYUA+Ej}JXDBeS;n<4MxW0R-U{9LTM zVR-KIf4?ZxYfeL3ZDL*JDz2MNnr*OHb=!VOyIs?@G4K2N>JXO4{o6X#@$NdNHV;kO z%`_;&rh41QA+1;4bDQT%PrH=iAhWIdKMTKmmc>xL#9wEg`5P$$1PBlyK!5-N0t5&U zAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C7 z2oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N z0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+ z009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBly zK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF z5FkK+009C72%Hfp&%}iZ5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF z5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk z1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs z0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZ zfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&U zAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAVA=91d1@;mvdq#B|v}x z0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZ zfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&U zAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C7 z2oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N z0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+ a009C72oNAZfB*pk1PBlyK!5;&8G$bzfG}YI literal 0 HcmV?d00001 diff --git a/tests/virstoragetestdata/images/qcow2_qcow2-auto.qcow2 b/tests/virstoragetestdata/images/qcow2_qcow2-auto.qcow2 new file mode 100644 index 0000000000000000000000000000000000000000..490482150d476032cfccd91be403f15430682f67 GIT binary patch literal 196616 zcmeIuK~94}6adhH>fR%8h91Ji#EmQ02sDzkfOMK#S03BMjnL9GE=2b}$S{AH&;QJO zxV`%fAuNV5T<Q3@9>&cWgm875LP(Cmlr^nR@6H)N&tsA9y#2iRcpS>ThfvmiJY-LG zJa5g<NzwNGu8V*DBCTFy)i?P%EAyCVt9o6{Hdqwxrt7Qiwr-m&9=iGLfo81VlvSDC zFSDwNeO+y58YE$zza6r^S{3cCiF2vPDrp#GHhK4J;?y%u`h1^#JM+xnT((|{cE7wV zMFa>CAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+ z009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBly zK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF z5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk z1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs z0RjXF5FkK+009C72oNAZfB*pk1PJ_hf%LxvI6nab1PBlyK!5-N0t5&UAV7cs0RjXF z5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk z1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs z0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZ zfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&U zAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C7 z2!v$1Q4k<NfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBly zK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF z5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk z1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs z0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZ kfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+0D(c^3#qCyQ~&?~ literal 0 HcmV?d00001 diff --git a/tests/virstoragetestdata/images/qcow2_qcow2-auto_qcow2-auto.qcow2 b/tests/virstoragetestdata/images/qcow2_qcow2-auto_qcow2-auto.qcow2 new file mode 100644 index 0000000000000000000000000000000000000000..3b27b256c27e34ceed0e4ae3888d75e532cda451 GIT binary patch literal 196616 zcmeIuO-_SA6ae6XdH`3hxqvQu2on=Gu3Q?VG?KJ{bedXM9^1r?^e>HRMECt5%sl2j z-Z0<8?cG-hVbnkUm2QTs{<+))AzbXH5Rz@MuiC%u)(#cF&zmOgA^kG?eC*qOgfOYP zxXzxdct{P;NzruOvW@@!A}!xy+12?ho8&Rirq!$*++b8R^R_D&i>j%!xNe85dzwxE zdQwiZ`*Bv*v8&3(zy?W}<?rjPE2l-Xtm9DWwo4j%nR(v+S-9UbO}c!Q{W$Z$-yBn~ zMY9?|ZO7|;8JnAJc+86k5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF z5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk z1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs z0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZ zfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&U zAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UI5UCt%+Bk$1PBlyK!5-N z0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+ z009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBly zK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF z5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk z1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs z0RjXF5FkK+009C72oNA}Dv*TTeVVaCfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+ z009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBly zK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF z5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk z1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs z0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009DLDDVvt CzBsS| literal 0 HcmV?d00001 diff --git a/tests/virstoragetestdata/images/qcow2_qcow2-qcow2_qcow2-auto.qcow2 b/tests/virstoragetestdata/images/qcow2_qcow2-qcow2_qcow2-auto.qcow2 new file mode 100644 index 0000000000000000000000000000000000000000..8b9c3cedeacf4aef8c7645314ecb68c992d4b51d GIT binary patch literal 196616 zcmeIvJ5Iwe00v+ug`J5xGZG9O0ttzQi4lc1h)5*~sVgWG=i?Zh0*M9pCB#7JTz!uG zNc_i+zg%BjeuWT5siu-2rRF%*WuMByx(gv&4K}IG-TK)!@pr#mq}xt^EKc6j`0#1m zKA)$-!|3xSE&mq6r0(OQxU1tfI^1XDw(sX%-1UvTdWluvl+$8T#<IAtr`6yFqjCG# z_0?=vw@ncj-EcZlE!S@*)ugyOFRCW?bu}B<APdv-by4)y{kWYsaVWZ4B@apFvF!d0 zZuZQxzI-lzoq6DEex_Fc<#yGcmh;%2ZGY5H#E1X^0t5&UAV7cs0RjXF5FkK+009C7 z2oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N z0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+ z009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBly zK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF z5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB=Dg z7RdMcaLz`6009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZ zfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&U zAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C7 z2oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N z0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+ z009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RlS-WMO^n6c!>tfB*pk1PBlyK!5-N z0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+ z009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBly zK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF z5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk z1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs R0RjXF5FkK+0D*lM_y(Y-Jpcdz literal 0 HcmV?d00001 diff --git a/tests/virstoragetestdata/images/qcow2_qcow2-qcow2_raw-auto.qcow2 b/tests/virstoragetestdata/images/qcow2_qcow2-qcow2_raw-auto.qcow2 new file mode 100644 index 0000000000000000000000000000000000000000..90b0a9a0594bc7e1e00dea41825fcf7996c7fc33 GIT binary patch literal 196616 zcmeIvJx;?g00vMeg`I%|WJZF4Lm(lsFfpRg1`(+wA$0|1;(Q!~Qy{V6{s}P<I#<t; zV<-M>$1m3xmtP@-QL3rrN9lH)>atDcVBLg}tvZ|3=4t(IoA|q3F4Ap>KNctNsekx1 zZlBLn=VA1Dla_xAVN&;TQQXyW8y#-5aohLvF77%buU=x+H|4aLl(8)C>uEK(!D!q* zc6~LQ)ooM6MK_#IRLk|7Ni`|1&WoyveO=84Hps%Xd|ecMbw6(BO&p4@R>?z>c`Uns zgPT3`tS_I7UuPcpnxCQ7f4NO_Ps@31&$hqmC!j}w009C72oNAZfB*pk1PBlyK!5-N z0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+ z009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBly zK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF z5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk z1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7e? zehcLLeLSZlK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&U zAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C7 z2oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N z0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+ z009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBly zK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB=CV1hTNcc8H1)AV7cs0RjXF5FkK+ z009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBly zK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF z5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk z1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs z0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZ SfB*pk1PBlyK!Cvh3w#6G^E_Mt literal 0 HcmV?d00001 diff --git a/tests/virstoragetestdata/images/qcow2_raw-auto.qcow2 b/tests/virstoragetestdata/images/qcow2_raw-auto.qcow2 new file mode 100644 index 0000000000000000000000000000000000000000..c942c3816af0cd506863cecc456691b2418d2863 GIT binary patch literal 196616 zcmeIuO-_SA6ae6XdH|0wXYddvCT?80#xjj0Es!Zj>&j!BxDoo3#)as<9|Y#jyf<&) zd$_&(3Lz}UXS~YkHO1Fc5W>}A2%*>q$ExG(uy(5WeVm%~r}XpU^KoqV5klSMVHcm8 z;gp&mi)EMdOF#T~N15J+l-p_@>uRXts#&Mm0~X6})919^HeDNsT|Zwv(oFr^I@R(1 zCZ=}CP1?>JP=s~$zKc1nmfcG`%$4rDlwp+FRQ;cY$1}?!SFiEMKhJ#4IW_J&PecR= z5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk z1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs z0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZ zfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&U zAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C7 z2oNAZfB*pk1PBlyK!5-N0t5&UC=n1KK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZ zfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&U zAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C7 z2oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N z0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+ z009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfWXBI6yb1R zJOls&1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&U zAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C7 z2oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N z0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+ z009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBly hK!5-N0t5&UAV7cs0RjXF5FkK+009C72oRVAz5&h(F|Yst literal 0 HcmV?d00001 diff --git a/tests/virstoragetestdata/out/qcow2-qcow2_qcow2-auto b/tests/virstoragetestdata/out/qcow2-qcow2_qcow2-auto new file mode 100644 index 0000000000..e23c43f328 --- /dev/null +++ b/tests/virstoragetestdata/out/qcow2-qcow2_qcow2-auto @@ -0,0 +1,19 @@ +path:ABS_SRCDIR/virstoragetestdata/images/qcow2_qcow2-auto.qcow2 +backingStoreRaw: qcow2 +capacity: 1024 +encryption: 0 +relPath:<null> +type:1 +format:14 +protocol:none +hostname:<null> + +path:ABS_SRCDIR/virstoragetestdata/images/qcow2 +backingStoreRaw: <null> +capacity: 1024 +encryption: 0 +relPath:qcow2 +type:1 +format:14 +protocol:none +hostname:<null> diff --git a/tests/virstoragetestdata/out/qcow2-qcow2_qcow2-qcow2_qcow2-auto b/tests/virstoragetestdata/out/qcow2-qcow2_qcow2-qcow2_qcow2-auto new file mode 100644 index 0000000000..17f53f3ed0 --- /dev/null +++ b/tests/virstoragetestdata/out/qcow2-qcow2_qcow2-qcow2_qcow2-auto @@ -0,0 +1,29 @@ +path:ABS_SRCDIR/virstoragetestdata/images/qcow2_qcow2-qcow2_qcow2-auto.qcow2 +backingStoreRaw: qcow2_qcow2-auto.qcow2 +capacity: 1024 +encryption: 0 +relPath:<null> +type:1 +format:14 +protocol:none +hostname:<null> + +path:ABS_SRCDIR/virstoragetestdata/images/qcow2_qcow2-auto.qcow2 +backingStoreRaw: qcow2 +capacity: 1024 +encryption: 0 +relPath:qcow2_qcow2-auto.qcow2 +type:1 +format:14 +protocol:none +hostname:<null> + +path:ABS_SRCDIR/virstoragetestdata/images/qcow2 +backingStoreRaw: <null> +capacity: 1024 +encryption: 0 +relPath:qcow2 +type:1 +format:14 +protocol:none +hostname:<null> diff --git a/tests/virstoragetestdata/out/qcow2-qcow2_qcow2-qcow2_raw-auto b/tests/virstoragetestdata/out/qcow2-qcow2_qcow2-qcow2_raw-auto new file mode 100644 index 0000000000..1be5a82cc9 --- /dev/null +++ b/tests/virstoragetestdata/out/qcow2-qcow2_qcow2-qcow2_raw-auto @@ -0,0 +1,29 @@ +path:ABS_SRCDIR/virstoragetestdata/images/qcow2_qcow2-qcow2_raw-auto.qcow2 +backingStoreRaw: qcow2_raw-auto.qcow2 +capacity: 1024 +encryption: 0 +relPath:<null> +type:1 +format:14 +protocol:none +hostname:<null> + +path:ABS_SRCDIR/virstoragetestdata/images/qcow2_raw-auto.qcow2 +backingStoreRaw: raw +capacity: 1024 +encryption: 0 +relPath:qcow2_raw-auto.qcow2 +type:1 +format:14 +protocol:none +hostname:<null> + +path:ABS_SRCDIR/virstoragetestdata/images/raw +backingStoreRaw: <null> +capacity: 0 +encryption: 0 +relPath:raw +type:1 +format:1 +protocol:none +hostname:<null> -- 2.31.1

On a Thursday in 2021, Peter Krempa wrote:
Most of the series are refactors to make virstoragetest less archaic, the last commit then re-introduces testing of images which don't have backing format recorded in the metadata which can't be formatted using qemu-img any more but have security implications if we'd mishandle them.
Peter Krempa (24): virstoragetest: Drop testing of RBD backends via parsing real images virstoragetest: Drop testing of NBD backends via parsing real images [...] virstoragetest: Remove pointless goto from mymain virstoragetest: Reinstate testing of images without 'backing_fmt'
build-aux/syntax-check.mk | 2 +- tests/testutils.c | 30 + tests/testutils.h | 3 + [...] tests/virstoragetestdata/out/raw-auto | 9 + tests/virstoragetestdata/out/raw-raw | 9 + 42 files changed, 580 insertions(+), 628 deletions(-) create mode 100644 tests/virstoragetestdata/images/loop-1.qcow2 [...]
Reviewed-by: Ján Tomko <jtomko@redhat.com> Jano
participants (2)
-
Ján Tomko
-
Peter Krempa