mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-10-05 05:45:46 +00:00
tests: Don't use canonical paths in virstoragetest
The layout of my home directory is somewhat peculiar: I store
all git repositories in ~/src/upstream, but since I spend
almost all of my time hacking on libvirt, I also have a
convenience symlink ~/src/libvirt -> ~/src/upstream/libvirt
that I use to access that specific git repository.
The above setup has served me well for years; however, ever
since commit ca1471622d
dropped our own custom definitions
for abs_{,top_}{src,build}dir and started using the ones
provided by autotools, virstoragetest has started reliably
failing with errors such as
2) Storage backing chain 2 ...
Offset 0
Expect [chain member: 0
path:/home/abologna/src/upstream/libvirt/tests/virstoragedata/raw
backingStoreRaw: <null>
capacity: 0
encryption: 0
relPath:<null>
type:1
format:1
protocol:none
hostname:<null>
]
Actual [chain member: 0
path:/home/abologna/src/libvirt/tests/virstoragedata/raw
backingStoreRaw: <null>
capacity: 0
encryption: 0
relPath:<null>
type:1
format:1
protocol:none
hostname:<null>
]
... FAILED
Using abolute paths instead of canonical ones in the tests makes
the problem go away.
Note that all tests that are specifically designed to test path
canonicalization via TEST_PATH_CANONICALIZE() were passing even
before this patch and are not touched by it.
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Acked-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
e398f5d47a
commit
35d76db2b7
@ -46,21 +46,16 @@ VIR_LOG_INIT("tests.storagetest");
|
|||||||
* sub/link2: symlink to wrap
|
* sub/link2: symlink to wrap
|
||||||
*
|
*
|
||||||
* Relative names to these files are known at compile time, but absolute
|
* Relative names to these files are known at compile time, but absolute
|
||||||
* and canonical names depend on where the test is run; for convenience,
|
* names depend on where the test is run; for convenience,
|
||||||
* we pre-populate the computation of these names for use during the test.
|
* we pre-populate the computation of these names for use during the test.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static char *qemuimg;
|
static char *qemuimg;
|
||||||
static char *absraw;
|
static char *absraw;
|
||||||
static char *canonraw;
|
|
||||||
static char *absqcow2;
|
static char *absqcow2;
|
||||||
static char *canonqcow2;
|
|
||||||
static char *abswrap;
|
static char *abswrap;
|
||||||
static char *canonwrap;
|
|
||||||
static char *absqed;
|
static char *absqed;
|
||||||
static char *canonqed;
|
|
||||||
static char *absdir;
|
static char *absdir;
|
||||||
static char *canondir;
|
|
||||||
static char *abslink2;
|
static char *abslink2;
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -68,15 +63,10 @@ testCleanupImages(void)
|
|||||||
{
|
{
|
||||||
VIR_FREE(qemuimg);
|
VIR_FREE(qemuimg);
|
||||||
VIR_FREE(absraw);
|
VIR_FREE(absraw);
|
||||||
VIR_FREE(canonraw);
|
|
||||||
VIR_FREE(absqcow2);
|
VIR_FREE(absqcow2);
|
||||||
VIR_FREE(canonqcow2);
|
|
||||||
VIR_FREE(abswrap);
|
VIR_FREE(abswrap);
|
||||||
VIR_FREE(canonwrap);
|
|
||||||
VIR_FREE(absqed);
|
VIR_FREE(absqed);
|
||||||
VIR_FREE(canonqed);
|
|
||||||
VIR_FREE(absdir);
|
VIR_FREE(absdir);
|
||||||
VIR_FREE(canondir);
|
|
||||||
VIR_FREE(abslink2);
|
VIR_FREE(abslink2);
|
||||||
|
|
||||||
if (chdir(abs_builddir) < 0) {
|
if (chdir(abs_builddir) < 0) {
|
||||||
@ -165,10 +155,6 @@ testPrepImages(void)
|
|||||||
fprintf(stderr, "unable to create directory %s\n", datadir "/dir");
|
fprintf(stderr, "unable to create directory %s\n", datadir "/dir");
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
if (!(canondir = virFileCanonicalizePath(absdir))) {
|
|
||||||
virReportOOMError();
|
|
||||||
goto cleanup;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (chdir(datadir) < 0) {
|
if (chdir(datadir) < 0) {
|
||||||
fprintf(stderr, "unable to test relative backing chains\n");
|
fprintf(stderr, "unable to test relative backing chains\n");
|
||||||
@ -180,10 +166,6 @@ testPrepImages(void)
|
|||||||
fprintf(stderr, "unable to create raw file\n");
|
fprintf(stderr, "unable to create raw file\n");
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
if (!(canonraw = virFileCanonicalizePath(absraw))) {
|
|
||||||
virReportOOMError();
|
|
||||||
goto cleanup;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* 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 */
|
||||||
@ -200,10 +182,6 @@ testPrepImages(void)
|
|||||||
"-F", "raw", "-b", "raw", "qcow2", NULL);
|
"-F", "raw", "-b", "raw", "qcow2", NULL);
|
||||||
if (virCommandRun(cmd, NULL) < 0)
|
if (virCommandRun(cmd, NULL) < 0)
|
||||||
goto skip;
|
goto skip;
|
||||||
if (!(canonqcow2 = virFileCanonicalizePath(absqcow2))) {
|
|
||||||
virReportOOMError();
|
|
||||||
goto cleanup;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* 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. */
|
||||||
@ -214,10 +192,6 @@ testPrepImages(void)
|
|||||||
virCommandAddArg(cmd, "wrap");
|
virCommandAddArg(cmd, "wrap");
|
||||||
if (virCommandRun(cmd, NULL) < 0)
|
if (virCommandRun(cmd, NULL) < 0)
|
||||||
goto skip;
|
goto skip;
|
||||||
if (!(canonwrap = virFileCanonicalizePath(abswrap))) {
|
|
||||||
virReportOOMError();
|
|
||||||
goto cleanup;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Create a qed file. */
|
/* Create a qed file. */
|
||||||
virCommandFree(cmd);
|
virCommandFree(cmd);
|
||||||
@ -227,10 +201,6 @@ testPrepImages(void)
|
|||||||
virCommandAddArg(cmd, "qed");
|
virCommandAddArg(cmd, "qed");
|
||||||
if (virCommandRun(cmd, NULL) < 0)
|
if (virCommandRun(cmd, NULL) < 0)
|
||||||
goto skip;
|
goto skip;
|
||||||
if (!(canonqed = virFileCanonicalizePath(absqed))) {
|
|
||||||
virReportOOMError();
|
|
||||||
goto cleanup;
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef HAVE_SYMLINK
|
#ifdef HAVE_SYMLINK
|
||||||
/* Create some symlinks in a sub-directory. */
|
/* Create some symlinks in a sub-directory. */
|
||||||
@ -731,7 +701,7 @@ mymain(void)
|
|||||||
|
|
||||||
/* Raw image, whether with right format or no specified format */
|
/* Raw image, whether with right format or no specified format */
|
||||||
testFileData raw = {
|
testFileData raw = {
|
||||||
.path = canonraw,
|
.path = absraw,
|
||||||
.type = VIR_STORAGE_TYPE_FILE,
|
.type = VIR_STORAGE_TYPE_FILE,
|
||||||
.format = VIR_STORAGE_FILE_RAW,
|
.format = VIR_STORAGE_FILE_RAW,
|
||||||
};
|
};
|
||||||
@ -743,12 +713,12 @@ mymain(void)
|
|||||||
testFileData qcow2 = {
|
testFileData qcow2 = {
|
||||||
.expBackingStoreRaw = "raw",
|
.expBackingStoreRaw = "raw",
|
||||||
.expCapacity = 1024,
|
.expCapacity = 1024,
|
||||||
.path = canonqcow2,
|
.path = absqcow2,
|
||||||
.type = VIR_STORAGE_TYPE_FILE,
|
.type = VIR_STORAGE_TYPE_FILE,
|
||||||
.format = VIR_STORAGE_FILE_QCOW2,
|
.format = VIR_STORAGE_FILE_QCOW2,
|
||||||
};
|
};
|
||||||
testFileData qcow2_as_raw = {
|
testFileData qcow2_as_raw = {
|
||||||
.path = canonqcow2,
|
.path = absqcow2,
|
||||||
.type = VIR_STORAGE_TYPE_FILE,
|
.type = VIR_STORAGE_TYPE_FILE,
|
||||||
.format = VIR_STORAGE_FILE_RAW,
|
.format = VIR_STORAGE_FILE_RAW,
|
||||||
};
|
};
|
||||||
@ -772,7 +742,7 @@ mymain(void)
|
|||||||
testFileData wrap = {
|
testFileData wrap = {
|
||||||
.expBackingStoreRaw = absqcow2,
|
.expBackingStoreRaw = absqcow2,
|
||||||
.expCapacity = 1024,
|
.expCapacity = 1024,
|
||||||
.path = canonwrap,
|
.path = abswrap,
|
||||||
.type = VIR_STORAGE_TYPE_FILE,
|
.type = VIR_STORAGE_TYPE_FILE,
|
||||||
.format = VIR_STORAGE_FILE_QCOW2,
|
.format = VIR_STORAGE_FILE_QCOW2,
|
||||||
};
|
};
|
||||||
@ -795,7 +765,7 @@ mymain(void)
|
|||||||
testFileData wrap_as_raw = {
|
testFileData wrap_as_raw = {
|
||||||
.expBackingStoreRaw = absqcow2,
|
.expBackingStoreRaw = absqcow2,
|
||||||
.expCapacity = 1024,
|
.expCapacity = 1024,
|
||||||
.path = canonwrap,
|
.path = abswrap,
|
||||||
.type = VIR_STORAGE_TYPE_FILE,
|
.type = VIR_STORAGE_TYPE_FILE,
|
||||||
.format = VIR_STORAGE_FILE_QCOW2,
|
.format = VIR_STORAGE_FILE_QCOW2,
|
||||||
};
|
};
|
||||||
@ -878,12 +848,12 @@ mymain(void)
|
|||||||
testFileData qed = {
|
testFileData qed = {
|
||||||
.expBackingStoreRaw = absraw,
|
.expBackingStoreRaw = absraw,
|
||||||
.expCapacity = 1024,
|
.expCapacity = 1024,
|
||||||
.path = canonqed,
|
.path = absqed,
|
||||||
.type = VIR_STORAGE_TYPE_FILE,
|
.type = VIR_STORAGE_TYPE_FILE,
|
||||||
.format = VIR_STORAGE_FILE_QED,
|
.format = VIR_STORAGE_FILE_QED,
|
||||||
};
|
};
|
||||||
testFileData qed_as_raw = {
|
testFileData qed_as_raw = {
|
||||||
.path = canonqed,
|
.path = absqed,
|
||||||
.type = VIR_STORAGE_TYPE_FILE,
|
.type = VIR_STORAGE_TYPE_FILE,
|
||||||
.format = VIR_STORAGE_FILE_RAW,
|
.format = VIR_STORAGE_FILE_RAW,
|
||||||
};
|
};
|
||||||
@ -892,12 +862,12 @@ mymain(void)
|
|||||||
|
|
||||||
/* directory */
|
/* directory */
|
||||||
testFileData dir = {
|
testFileData dir = {
|
||||||
.path = canondir,
|
.path = absdir,
|
||||||
.type = VIR_STORAGE_TYPE_DIR,
|
.type = VIR_STORAGE_TYPE_DIR,
|
||||||
.format = VIR_STORAGE_FILE_DIR,
|
.format = VIR_STORAGE_FILE_DIR,
|
||||||
};
|
};
|
||||||
testFileData dir_as_raw = {
|
testFileData dir_as_raw = {
|
||||||
.path = canondir,
|
.path = absdir,
|
||||||
.type = VIR_STORAGE_TYPE_DIR,
|
.type = VIR_STORAGE_TYPE_DIR,
|
||||||
.format = VIR_STORAGE_FILE_RAW,
|
.format = VIR_STORAGE_FILE_RAW,
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user