1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2025-03-07 17:28:15 +00:00

tests: virstoragetest: Remove unneeded relative test plumbing

After we don't test relative paths, remove even more unnecessary cruft
from the test code.
This commit is contained in:
Peter Krempa 2014-05-27 14:15:31 +02:00
parent 0e46f267b7
commit 4074ad2d74

View File

@ -284,8 +284,7 @@ struct _testFileData
bool expEncrypted; bool expEncrypted;
const char *pathRel; const char *pathRel;
const char *path; const char *path;
const char *relDirRel; const char *relDir;
const char *relDirAbs;
int type; int type;
int format; int format;
}; };
@ -295,7 +294,6 @@ enum {
EXP_FAIL = 1, EXP_FAIL = 1,
EXP_WARN = 2, EXP_WARN = 2,
ALLOW_PROBE = 4, ALLOW_PROBE = 4,
ABS_START = 8,
}; };
struct testChainData struct testChainData
@ -328,7 +326,6 @@ testStorageChain(const void *args)
virStorageSourcePtr elt; virStorageSourcePtr elt;
size_t i = 0; size_t i = 0;
char *broken = NULL; char *broken = NULL;
bool isAbs = !!(data->flags & ABS_START);
meta = testStorageFileGetMetadata(data->start, data->format, -1, -1, meta = testStorageFileGetMetadata(data->start, data->format, -1, -1,
(data->flags & ALLOW_PROBE) != 0); (data->flags & ALLOW_PROBE) != 0);
@ -367,15 +364,12 @@ testStorageChain(const void *args)
while (elt) { while (elt) {
char *expect = NULL; char *expect = NULL;
char *actual = NULL; char *actual = NULL;
const char *expRelDir;
if (i == data->nfiles) { if (i == data->nfiles) {
fprintf(stderr, "probed chain was too long\n"); fprintf(stderr, "probed chain was too long\n");
goto cleanup; goto cleanup;
} }
expRelDir = isAbs ? data->files[i]->relDirAbs
: data->files[i]->relDirRel;
if (virAsprintf(&expect, if (virAsprintf(&expect,
testStorageChainFormat, i, testStorageChainFormat, i,
NULLSTR(data->files[i]->path), NULLSTR(data->files[i]->path),
@ -383,7 +377,7 @@ testStorageChain(const void *args)
data->files[i]->expCapacity, data->files[i]->expCapacity,
data->files[i]->expEncrypted, data->files[i]->expEncrypted,
NULLSTR(data->files[i]->pathRel), NULLSTR(data->files[i]->pathRel),
NULLSTR(expRelDir), NULLSTR(data->files[i]->relDir),
data->files[i]->type, data->files[i]->type,
data->files[i]->format) < 0 || data->files[i]->format) < 0 ||
virAsprintf(&actual, virAsprintf(&actual,
@ -709,10 +703,8 @@ mymain(void)
#define TEST_CHAIN(id, path, format, chain1, flags1, chain2, flags2) \ #define TEST_CHAIN(id, path, format, chain1, flags1, chain2, flags2) \
do { \ do { \
TEST_ONE_CHAIN(#id "a", path, format, flags1 | ABS_START, \ TEST_ONE_CHAIN(#id "a", path, format, flags1, VIR_FLATTEN_1(chain1)); \
VIR_FLATTEN_1(chain1)); \ TEST_ONE_CHAIN(#id "b", path, format, flags2, VIR_FLATTEN_1(chain2)); \
TEST_ONE_CHAIN(#id "b", path, format, flags2 | ABS_START, \
VIR_FLATTEN_1(chain2)); \
} while (0) } while (0)
/* The actual tests, in several groups. */ /* The actual tests, in several groups. */
@ -723,8 +715,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 = canonraw,
.relDirRel = ".", .relDir = datadir,
.relDirAbs = datadir,
.type = VIR_STORAGE_TYPE_FILE, .type = VIR_STORAGE_TYPE_FILE,
.format = VIR_STORAGE_FILE_RAW, .format = VIR_STORAGE_FILE_RAW,
}; };
@ -741,15 +732,13 @@ mymain(void)
.expBackingStoreRaw = "raw", .expBackingStoreRaw = "raw",
.expCapacity = 1024, .expCapacity = 1024,
.path = canonqcow2, .path = canonqcow2,
.relDirRel = ".", .relDir = datadir,
.relDirAbs = datadir,
.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 = canonqcow2,
.relDirRel = ".", .relDir = datadir,
.relDirAbs = datadir,
.type = VIR_STORAGE_TYPE_FILE, .type = VIR_STORAGE_TYPE_FILE,
.format = VIR_STORAGE_FILE_RAW, .format = VIR_STORAGE_FILE_RAW,
}; };
@ -768,7 +757,6 @@ mymain(void)
ret = -1; ret = -1;
qcow2.expBackingStoreRaw = absraw; qcow2.expBackingStoreRaw = absraw;
raw.pathRel = NULL; raw.pathRel = NULL;
raw.relDirRel = datadir;
/* Qcow2 file with raw as absolute backing, backing format provided */ /* Qcow2 file with raw as absolute backing, backing format provided */
TEST_CHAIN(5, absqcow2, VIR_STORAGE_FILE_QCOW2, TEST_CHAIN(5, absqcow2, VIR_STORAGE_FILE_QCOW2,
@ -783,12 +771,10 @@ mymain(void)
.expBackingStoreRaw = absqcow2, .expBackingStoreRaw = absqcow2,
.expCapacity = 1024, .expCapacity = 1024,
.path = canonwrap, .path = canonwrap,
.relDirRel = ".", .relDir = datadir,
.relDirAbs = datadir,
.type = VIR_STORAGE_TYPE_FILE, .type = VIR_STORAGE_TYPE_FILE,
.format = VIR_STORAGE_FILE_QCOW2, .format = VIR_STORAGE_FILE_QCOW2,
}; };
qcow2.relDirRel = datadir;
TEST_CHAIN(7, abswrap, VIR_STORAGE_FILE_QCOW2, TEST_CHAIN(7, abswrap, VIR_STORAGE_FILE_QCOW2,
(&wrap, &qcow2, &raw), EXP_PASS, (&wrap, &qcow2, &raw), EXP_PASS,
(&wrap, &qcow2, &raw), ALLOW_PROBE | EXP_PASS); (&wrap, &qcow2, &raw), ALLOW_PROBE | EXP_PASS);
@ -805,15 +791,13 @@ mymain(void)
"-b", absqcow2, "wrap", NULL); "-b", absqcow2, "wrap", NULL);
if (virCommandRun(cmd, NULL) < 0) if (virCommandRun(cmd, NULL) < 0)
ret = -1; ret = -1;
qcow2_as_raw.relDirRel = datadir;
/* Qcow2 file with raw as absolute backing, backing format omitted */ /* Qcow2 file with raw as absolute backing, backing format omitted */
testFileData wrap_as_raw = { testFileData wrap_as_raw = {
.expBackingStoreRaw = absqcow2, .expBackingStoreRaw = absqcow2,
.expCapacity = 1024, .expCapacity = 1024,
.path = canonwrap, .path = canonwrap,
.relDirRel = ".", .relDir = datadir,
.relDirAbs = datadir,
.type = VIR_STORAGE_TYPE_FILE, .type = VIR_STORAGE_TYPE_FILE,
.format = VIR_STORAGE_FILE_QCOW2, .format = VIR_STORAGE_FILE_QCOW2,
}; };
@ -829,7 +813,6 @@ mymain(void)
if (virCommandRun(cmd, NULL) < 0) if (virCommandRun(cmd, NULL) < 0)
ret = -1; ret = -1;
qcow2.expBackingStoreRaw = datadir "/bogus"; qcow2.expBackingStoreRaw = datadir "/bogus";
qcow2.relDirRel = ".";
/* Qcow2 file with missing backing file but specified type */ /* Qcow2 file with missing backing file but specified type */
TEST_CHAIN(9, absqcow2, VIR_STORAGE_FILE_QCOW2, TEST_CHAIN(9, absqcow2, VIR_STORAGE_FILE_QCOW2,
@ -862,8 +845,7 @@ mymain(void)
.path = "blah", .path = "blah",
.type = VIR_STORAGE_TYPE_NETWORK, .type = VIR_STORAGE_TYPE_NETWORK,
.format = VIR_STORAGE_FILE_RAW, .format = VIR_STORAGE_FILE_RAW,
.relDirRel = ".", .relDir = ".",
.relDirAbs = ".",
}; };
TEST_CHAIN(11, absqcow2, VIR_STORAGE_FILE_QCOW2, TEST_CHAIN(11, absqcow2, VIR_STORAGE_FILE_QCOW2,
(&qcow2, &nbd), EXP_PASS, (&qcow2, &nbd), EXP_PASS,
@ -874,15 +856,13 @@ mymain(void)
.expBackingStoreRaw = absraw, .expBackingStoreRaw = absraw,
.expCapacity = 1024, .expCapacity = 1024,
.path = canonqed, .path = canonqed,
.relDirRel = ".", .relDir = datadir,
.relDirAbs = datadir,
.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 = canonqed,
.relDirRel = ".", .relDir = datadir,
.relDirAbs = datadir,
.type = VIR_STORAGE_TYPE_FILE, .type = VIR_STORAGE_TYPE_FILE,
.format = VIR_STORAGE_FILE_RAW, .format = VIR_STORAGE_FILE_RAW,
}; };
@ -893,8 +873,7 @@ mymain(void)
/* directory */ /* directory */
testFileData dir = { testFileData dir = {
.path = canondir, .path = canondir,
.relDirRel = ".", .relDir = datadir,
.relDirAbs = datadir,
.type = VIR_STORAGE_TYPE_DIR, .type = VIR_STORAGE_TYPE_DIR,
.format = VIR_STORAGE_FILE_DIR, .format = VIR_STORAGE_FILE_DIR,
}; };
@ -927,8 +906,7 @@ mymain(void)
.expCapacity = 1024, .expCapacity = 1024,
.pathRel = "../sub/link1", .pathRel = "../sub/link1",
.path = canonqcow2, .path = canonqcow2,
.relDirRel = "sub/../sub", .relDir = datadir "/sub/../sub",
.relDirAbs = datadir "/sub/../sub",
.type = VIR_STORAGE_TYPE_FILE, .type = VIR_STORAGE_TYPE_FILE,
.format = VIR_STORAGE_FILE_QCOW2, .format = VIR_STORAGE_FILE_QCOW2,
}; };
@ -936,14 +914,12 @@ mymain(void)
.expBackingStoreRaw = "../sub/link1", .expBackingStoreRaw = "../sub/link1",
.expCapacity = 1024, .expCapacity = 1024,
.path = canonwrap, .path = canonwrap,
.relDirRel = "sub", .relDir = datadir "/sub",
.relDirAbs = datadir "/sub",
.type = VIR_STORAGE_TYPE_FILE, .type = VIR_STORAGE_TYPE_FILE,
.format = VIR_STORAGE_FILE_QCOW2, .format = VIR_STORAGE_FILE_QCOW2,
}; };
raw.pathRel = "../raw"; raw.pathRel = "../raw";
raw.relDirRel = "sub/../sub/.."; raw.relDir = datadir "/sub/../sub/..";
raw.relDirAbs = datadir "/sub/../sub/..";
TEST_CHAIN(15, abslink2, VIR_STORAGE_FILE_QCOW2, TEST_CHAIN(15, abslink2, VIR_STORAGE_FILE_QCOW2,
(&link2, &link1, &raw), EXP_PASS, (&link2, &link1, &raw), EXP_PASS,
(&link2, &link1, &raw), ALLOW_PROBE | EXP_PASS); (&link2, &link1, &raw), ALLOW_PROBE | EXP_PASS);
@ -975,7 +951,6 @@ mymain(void)
if (virCommandRun(cmd, NULL) < 0) if (virCommandRun(cmd, NULL) < 0)
ret = -1; ret = -1;
qcow2.expBackingStoreRaw = "wrap"; qcow2.expBackingStoreRaw = "wrap";
qcow2.relDirRel = datadir;
/* Behavior of an infinite loop chain */ /* Behavior of an infinite loop chain */
TEST_CHAIN(17, abswrap, VIR_STORAGE_FILE_QCOW2, TEST_CHAIN(17, abswrap, VIR_STORAGE_FILE_QCOW2,