]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
virstoragetest: Convert symlink and relative image testing use preformatted images
authorPeter Krempa <pkrempa@redhat.com>
Wed, 8 Sep 2021 14:30:52 +0000 (16:30 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Thu, 9 Sep 2021 13:29:00 +0000 (15:29 +0200)
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>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
tests/virstoragetest.c
tests/virstoragetestdata/images/qcow2_qcow2-qcow2-symlink_raw-raw-reldir.qcow2 [new file with mode: 0644]
tests/virstoragetestdata/images/qcow2_raw-raw-reldir.qcow2 [new file with mode: 0644]
tests/virstoragetestdata/images/sub/link1 [new symlink]
tests/virstoragetestdata/images/sub/link2 [new symlink]
tests/virstoragetestdata/out/qcow2-symlinks

index dcb5a8a4270ab6223b724d0b3b1352b890f319b3..15296cc14f3d5eecd03feb4c4aa27a5c1ca5647e 100644 (file)
@@ -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 (file)
index 0000000..9620410
Binary files /dev/null and b/tests/virstoragetestdata/images/qcow2_qcow2-qcow2-symlink_raw-raw-reldir.qcow2 differ
diff --git a/tests/virstoragetestdata/images/qcow2_raw-raw-reldir.qcow2 b/tests/virstoragetestdata/images/qcow2_raw-raw-reldir.qcow2
new file mode 100644 (file)
index 0000000..1e32c78
Binary files /dev/null and b/tests/virstoragetestdata/images/qcow2_raw-raw-reldir.qcow2 differ
diff --git a/tests/virstoragetestdata/images/sub/link1 b/tests/virstoragetestdata/images/sub/link1
new file mode 120000 (symlink)
index 0000000..3532029
--- /dev/null
@@ -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 (symlink)
index 0000000..6fc4405
--- /dev/null
@@ -0,0 +1 @@
+../qcow2_qcow2-qcow2-symlink_raw-raw-reldir.qcow2
\ No newline at end of file
index ed37f61e9fcb7e5e25d08bcb17ade0ae5b7afaf3..34c3a37c2ebbbb6372e0fdd9a28e842e86344b45 100644 (file)
@@ -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