提交 9194679e 编写于 作者: E Eric Blake

tests: skip virstoragetest on RHEL 5

virstoragetest was failing on RHEL 5, but with no good error message:

TEST: virstoragetest
                                        0   FAIL

It turns out that qemu-img was so old, that it lacked support for
-o backing_file.  It didn't help that the test was also using
qemu-img from PATH, even after first probing for kvm-img.

* tests/virstoragetest.c (testPrepImages): Consistently use
discovered binary.  Skip instead of fail if qemu-img fails during
setup.
上级 01207bb7
...@@ -89,10 +89,8 @@ testPrepImages(void) ...@@ -89,10 +89,8 @@ testPrepImages(void)
qemuimg = virFindFileInPath("kvm-img"); qemuimg = virFindFileInPath("kvm-img");
if (!qemuimg) if (!qemuimg)
qemuimg = virFindFileInPath("qemu-img"); qemuimg = virFindFileInPath("qemu-img");
if (!qemuimg) { if (!qemuimg)
fputs("qemu-img missing or too old; skipping this test\n", stderr); goto skip;
return EXIT_AM_SKIP;
}
if (virAsprintf(&absraw, "%s/raw", datadir) < 0 || if (virAsprintf(&absraw, "%s/raw", datadir) < 0 ||
virAsprintf(&absqcow2, "%s/qcow2", datadir) < 0 || virAsprintf(&absqcow2, "%s/qcow2", datadir) < 0 ||
...@@ -116,8 +114,10 @@ testPrepImages(void) ...@@ -116,8 +114,10 @@ testPrepImages(void)
/* I'm lazy enough to use a shell one-liner instead of open/write/close */ /* I'm lazy enough to use a shell one-liner instead of open/write/close */
virCommandFree(cmd); virCommandFree(cmd);
cmd = virCommandNewArgList("sh", "-c", "printf %1024d 0 > raw", NULL); cmd = virCommandNewArgList("sh", "-c", "printf %1024d 0 > raw", NULL);
if (virCommandRun(cmd, NULL) < 0) if (virCommandRun(cmd, NULL) < 0) {
fprintf(stderr, "unable to create raw file\n");
goto cleanup; goto cleanup;
}
if (!(canonraw = canonicalize_file_name(absraw))) { if (!(canonraw = canonicalize_file_name(absraw))) {
virReportOOMError(); virReportOOMError();
goto cleanup; goto cleanup;
...@@ -126,20 +126,17 @@ testPrepImages(void) ...@@ -126,20 +126,17 @@ testPrepImages(void)
/* Create a qcow2 wrapping relative raw; later on, we modify its /* Create a qcow2 wrapping relative raw; later on, we modify its
* metadata to test other configurations */ * metadata to test other configurations */
virCommandFree(cmd); virCommandFree(cmd);
cmd = virCommandNewArgList("qemu-img", "create", "-f", "qcow2", cmd = virCommandNewArgList(qemuimg, "create", "-f", "qcow2",
"-obacking_file=raw,backing_fmt=raw", "qcow2", "-obacking_file=raw,backing_fmt=raw", "qcow2",
NULL); NULL);
if (virCommandRun(cmd, NULL) < 0) if (virCommandRun(cmd, NULL) < 0)
goto cleanup; goto skip;
/* Make sure our later uses of 'qemu-img rebase' will work */ /* Make sure our later uses of 'qemu-img rebase' will work */
virCommandFree(cmd); virCommandFree(cmd);
cmd = virCommandNewArgList("qemu-img", "rebase", "-u", "-f", "qcow2", cmd = virCommandNewArgList(qemuimg, "rebase", "-u", "-f", "qcow2",
"-F", "raw", "-b", "raw", "qcow2", NULL); "-F", "raw", "-b", "raw", "qcow2", NULL);
if (virCommandRun(cmd, NULL) < 0) { if (virCommandRun(cmd, NULL) < 0)
fputs("qemu-img is too old; skipping this test\n", stderr); goto skip;
ret = EXIT_AM_SKIP;
goto cleanup;
}
if (!(canonqcow2 = canonicalize_file_name(absqcow2))) { if (!(canonqcow2 = canonicalize_file_name(absqcow2))) {
virReportOOMError(); virReportOOMError();
goto cleanup; goto cleanup;
...@@ -148,21 +145,21 @@ testPrepImages(void) ...@@ -148,21 +145,21 @@ testPrepImages(void)
/* Create a second qcow2 wrapping the first, to be sure that we /* Create a second qcow2 wrapping the first, to be sure that we
* can correctly avoid insecure probing. */ * can correctly avoid insecure probing. */
virCommandFree(cmd); virCommandFree(cmd);
cmd = virCommandNewArgList("qemu-img", "create", "-f", "qcow2", NULL); cmd = virCommandNewArgList(qemuimg, "create", "-f", "qcow2", NULL);
virCommandAddArgFormat(cmd, "-obacking_file=%s,backing_fmt=qcow2", virCommandAddArgFormat(cmd, "-obacking_file=%s,backing_fmt=qcow2",
absqcow2); absqcow2);
virCommandAddArg(cmd, "wrap"); virCommandAddArg(cmd, "wrap");
if (virCommandRun(cmd, NULL) < 0) if (virCommandRun(cmd, NULL) < 0)
goto cleanup; goto skip;
/* Create a qed file. */ /* Create a qed file. */
virCommandFree(cmd); virCommandFree(cmd);
cmd = virCommandNewArgList("qemu-img", "create", "-f", "qed", NULL); cmd = virCommandNewArgList(qemuimg, "create", "-f", "qed", NULL);
virCommandAddArgFormat(cmd, "-obacking_file=%s,backing_fmt=raw", virCommandAddArgFormat(cmd, "-obacking_file=%s,backing_fmt=raw",
absraw); absraw);
virCommandAddArg(cmd, "qed"); virCommandAddArg(cmd, "qed");
if (virCommandRun(cmd, NULL) < 0) if (virCommandRun(cmd, NULL) < 0)
goto cleanup; goto skip;
/* Create some symlinks in a sub-directory. */ /* Create some symlinks in a sub-directory. */
if (symlink("../qcow2", datadir "/sub/link1") < 0 || if (symlink("../qcow2", datadir "/sub/link1") < 0 ||
...@@ -177,6 +174,11 @@ cleanup: ...@@ -177,6 +174,11 @@ cleanup:
if (ret) if (ret)
testCleanupImages(); testCleanupImages();
return ret; return ret;
skip:
fputs("qemu-img is too old; skipping this test\n", stderr);
ret = EXIT_AM_SKIP;
goto cleanup;
} }
typedef struct _testFileData testFileData; typedef struct _testFileData testFileData;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册