From 229a6d6992a8c05644c3caaf6c14cf06b07cee26 Mon Sep 17 00:00:00 2001 From: Peter Krempa Date: Wed, 8 Sep 2021 16:30:52 +0200 Subject: [PATCH] virstoragetest: Convert symlink and relative image testing use preformatted images MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Use prepared test images instead to simplify and clarify the code instead of rewriting existing images multiple times. Signed-off-by: Peter Krempa Reviewed-by: Ján Tomko --- 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 zc-rmIF;2rU6aY}Cg^htDWM*hZ4}pZl!o-}mu81f}NK!$WI3LI06i6(jr3_u#?0wJj zx4&e6`TPFn_9uie3|oWCE?ji;@-IINJIOW<_p&7Pvnf*jCtvHU&u%$?nU$}TZu2<& ze&|YlgfP$RcAZZ1wqMm`R@U{ZYWv<8#J4uqMYc@mS(~Mcd>Id(AI{3>s*X*QmqpsH zt9Y!-P5ojX=jq)fjYV7Mu{reou*}}qX&o1{a#gg=(dUP*&*!XadVcyKsk7H~ujgL( zMx$}FnvR!w@pK&k00000000000000000000000000000000000000000000000000 z00000000000000000000000000D#jo@C5(>000000000000000000000000000000 z00000000000000000000000000000000000000000000004Fcm4FCWD0000000000 z00000000000000000000000000000000000000000000000000000000000000000 G===iZ1vsJr literal 0 Hc-jL100001 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 zc-rmJK}y3w6b9f)Dz1BktX)*_5Q5;wmFw6}G0-L+G72yRSkyXdCPzTX#S z;K9t#yqBl@hu;vwBl1JzK-X* z+~${yxX2#wvRHOa5!+MG53Bs6&ziWLSDUhH&ptm4eXjGm9Xa$g877<^^*rj{Y<7G2 zH2?qr000000000000000000000000000000000000000000000000000000000000 z00000000000002MB}$C|000000000000000000000000000000000000000000000 z000000000000000000000000000000007|PCHoHm0000000000000000000000000 v00000000000000000000000000000000000000000000000000000Jm^4~S; literal 0 Hc-jL100001 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: -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: -path:ABS_BUILDDIR/virstoragedata/sub/../sub/../raw +path:ABS_SRCDIR/virstoragetestdata/images/sub/../sub/../raw backingStoreRaw: capacity: 0 encryption: 0 -- 2.47.2