mirror of https://gitee.com/openkylin/libvirt.git
tests: Always put '\n' at the end of VIR_TEST_VERBOSE
Similarly to the previous commit, VIR_TEST_VERBOSE should put '\n' at the end of each call so that the output is not broken. Signed-off-by: Michal Privoznik <mprivozn@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
d07ce21610
commit
e3511ee5ec
|
@ -215,7 +215,7 @@ cpuTestCompare(const void *arg)
|
|||
virResetLastError();
|
||||
|
||||
if (data->result != result) {
|
||||
VIR_TEST_VERBOSE("\nExpected result %s, got %s\n",
|
||||
VIR_TEST_VERBOSE("\nExpected result %s, got %s",
|
||||
cpuTestCompResStr(data->result),
|
||||
cpuTestCompResStr(result));
|
||||
/* Pad to line up with test name ... in virTestRun */
|
||||
|
@ -290,7 +290,7 @@ cpuTestGuestCPU(const void *arg)
|
|||
virResetLastError();
|
||||
ret = 0;
|
||||
} else {
|
||||
VIR_TEST_VERBOSE("\nExpected result %d, got %d\n",
|
||||
VIR_TEST_VERBOSE("\nExpected result %d, got %d",
|
||||
data->result, ret);
|
||||
/* Pad to line up with test name ... in virTestRun */
|
||||
VIR_TEST_VERBOSE("%74s", "... ");
|
||||
|
@ -357,7 +357,7 @@ cpuTestBaseline(const void *arg)
|
|||
cmp = virCPUCompare(cpus[i]->arch, cpus[i], baseline, false);
|
||||
if (cmp != VIR_CPU_COMPARE_SUPERSET &&
|
||||
cmp != VIR_CPU_COMPARE_IDENTICAL) {
|
||||
VIR_TEST_VERBOSE("\nbaseline CPU is incompatible with CPU %zu\n",
|
||||
VIR_TEST_VERBOSE("\nbaseline CPU is incompatible with CPU %zu",
|
||||
i);
|
||||
VIR_TEST_VERBOSE("%74s", "... ");
|
||||
ret = -1;
|
||||
|
@ -438,7 +438,7 @@ cpuTestHasFeature(const void *arg)
|
|||
virResetLastError();
|
||||
|
||||
if (data->result != result) {
|
||||
VIR_TEST_VERBOSE("\nExpected result %s, got %s\n",
|
||||
VIR_TEST_VERBOSE("\nExpected result %s, got %s",
|
||||
cpuTestBoolWithErrorStr(data->result),
|
||||
cpuTestBoolWithErrorStr(result));
|
||||
/* Pad to line up with test name ... in virTestRun */
|
||||
|
@ -712,7 +712,7 @@ cpuTestUpdateLiveCompare(virArch arch,
|
|||
return -1;
|
||||
|
||||
if (STRNEQ(actual->model, expected->model)) {
|
||||
VIR_TEST_VERBOSE("Actual CPU model '%s', expected '%s'\n",
|
||||
VIR_TEST_VERBOSE("Actual CPU model '%s', expected '%s'",
|
||||
actual->model, expected->model);
|
||||
return -1;
|
||||
}
|
||||
|
@ -765,7 +765,7 @@ cpuTestUpdateLiveCompare(virArch arch,
|
|||
featExp->policy == VIR_CPU_FEATURE_REQUIRE) ||
|
||||
(cmp > 0 &&
|
||||
featExp->policy == VIR_CPU_FEATURE_REQUIRE)) {
|
||||
VIR_TEST_VERBOSE("Actual CPU lacks feature '%s'\n",
|
||||
VIR_TEST_VERBOSE("Actual CPU lacks feature '%s'",
|
||||
featExp->name);
|
||||
ret = -1;
|
||||
continue;
|
||||
|
@ -778,7 +778,7 @@ cpuTestUpdateLiveCompare(virArch arch,
|
|||
featAct->policy == VIR_CPU_FEATURE_REQUIRE) ||
|
||||
(cmp > 0 &&
|
||||
featExp->policy == VIR_CPU_FEATURE_DISABLE)) {
|
||||
VIR_TEST_VERBOSE("Actual CPU has extra feature '%s'\n",
|
||||
VIR_TEST_VERBOSE("Actual CPU has extra feature '%s'",
|
||||
cmp <= 0 ? featAct->name : featExp->name);
|
||||
ret = -1;
|
||||
}
|
||||
|
|
|
@ -212,7 +212,7 @@ testQemuDiskXMLToProps(const void *opaque)
|
|||
|
||||
if (qemuCheckDiskConfig(disk, data->qemuCaps) < 0 ||
|
||||
qemuDomainDeviceDefValidateDisk(disk, data->qemuCaps) < 0) {
|
||||
VIR_TEST_VERBOSE("invalid configuration for disk\n");
|
||||
VIR_TEST_VERBOSE("invalid configuration for disk");
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
|
@ -230,11 +230,11 @@ testQemuDiskXMLToProps(const void *opaque)
|
|||
!(storageSrcOnlyProps = qemuBlockStorageSourceGetBackendProps(n, false, true, true)) ||
|
||||
!(storageProps = qemuBlockStorageSourceGetBackendProps(n, false, false, true))) {
|
||||
if (!data->fail) {
|
||||
VIR_TEST_VERBOSE("failed to generate qemu blockdev props\n");
|
||||
VIR_TEST_VERBOSE("failed to generate qemu blockdev props");
|
||||
goto cleanup;
|
||||
}
|
||||
} else if (data->fail) {
|
||||
VIR_TEST_VERBOSE("qemu blockdev props should have failed\n");
|
||||
VIR_TEST_VERBOSE("qemu blockdev props should have failed");
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
|
@ -532,7 +532,7 @@ mymain(void)
|
|||
if (!(capslatest_x86_64 = testQemuGetLatestCapsForArch("x86_64", "xml")))
|
||||
return EXIT_FAILURE;
|
||||
|
||||
VIR_TEST_VERBOSE("\nlatest caps x86_64: %s\n", capslatest_x86_64);
|
||||
VIR_TEST_VERBOSE("\nlatest caps x86_64: %s", capslatest_x86_64);
|
||||
|
||||
if (!(caps_x86_64 = qemuTestParseCapabilitiesArch(virArchFromString("x86_64"),
|
||||
capslatest_x86_64)))
|
||||
|
@ -642,7 +642,7 @@ mymain(void)
|
|||
diskxmljsondata.schema,
|
||||
&diskxmljsondata.schemaroot) < 0 ||
|
||||
!diskxmljsondata.schemaroot) {
|
||||
VIR_TEST_VERBOSE("failed to find schema entry for blockdev-add\n");
|
||||
VIR_TEST_VERBOSE("failed to find schema entry for blockdev-add");
|
||||
ret = -1;
|
||||
goto cleanup;
|
||||
}
|
||||
|
|
|
@ -131,7 +131,7 @@ testQemuHotplugAttach(virDomainObjPtr vm,
|
|||
ret = qemuDomainAttachWatchdog(&driver, vm, dev->data.watchdog);
|
||||
break;
|
||||
default:
|
||||
VIR_TEST_VERBOSE("device type '%s' cannot be attached\n",
|
||||
VIR_TEST_VERBOSE("device type '%s' cannot be attached",
|
||||
virDomainDeviceTypeToString(dev->type));
|
||||
break;
|
||||
}
|
||||
|
@ -154,7 +154,7 @@ testQemuHotplugDetach(virDomainObjPtr vm,
|
|||
ret = qemuDomainDetachDeviceLive(vm, dev, &driver, async);
|
||||
break;
|
||||
default:
|
||||
VIR_TEST_VERBOSE("device type '%s' cannot be detached\n",
|
||||
VIR_TEST_VERBOSE("device type '%s' cannot be detached",
|
||||
virDomainDeviceTypeToString(dev->type));
|
||||
break;
|
||||
}
|
||||
|
@ -178,7 +178,7 @@ testQemuHotplugUpdate(virDomainObjPtr vm,
|
|||
ret = qemuDomainChangeGraphics(&driver, vm, dev->data.graphics);
|
||||
break;
|
||||
default:
|
||||
VIR_TEST_VERBOSE("device type '%s' cannot be updated\n",
|
||||
VIR_TEST_VERBOSE("device type '%s' cannot be updated",
|
||||
virDomainDeviceTypeToString(dev->type));
|
||||
break;
|
||||
}
|
||||
|
@ -203,7 +203,7 @@ testQemuHotplugCheckResult(virDomainObjPtr vm,
|
|||
|
||||
if (STREQ(expected, actual)) {
|
||||
if (fail)
|
||||
VIR_TEST_VERBOSE("domain XML should not match the expected result\n");
|
||||
VIR_TEST_VERBOSE("domain XML should not match the expected result");
|
||||
ret = 0;
|
||||
} else {
|
||||
if (!fail)
|
||||
|
@ -262,7 +262,7 @@ testQemuHotplug(const void *data)
|
|||
if (test->vm) {
|
||||
vm = test->vm;
|
||||
if (!vm->def) {
|
||||
VIR_TEST_VERBOSE("test skipped due to failure of dependent test\n");
|
||||
VIR_TEST_VERBOSE("test skipped due to failure of dependent test");
|
||||
goto cleanup;
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -1643,7 +1643,7 @@ static void
|
|||
testQemuMonitorJSONGetBlockInfoPrint(const struct qemuDomainDiskInfo *d)
|
||||
{
|
||||
VIR_TEST_VERBOSE("removable: %d, tray: %d, tray_open: %d, empty: %d, "
|
||||
"io_status: %d, nodename: '%s'\n",
|
||||
"io_status: %d, nodename: '%s'",
|
||||
d->removable, d->tray, d->tray_open, d->empty,
|
||||
d->io_status, NULLSTR(d->nodename));
|
||||
}
|
||||
|
@ -2905,7 +2905,7 @@ testQAPISchemaValidate(const void *opaque)
|
|||
|
||||
if ((testQEMUSchemaValidate(json, schemaroot, data->schema, &debug) == 0) != data->success) {
|
||||
if (!data->success)
|
||||
VIR_TEST_VERBOSE("\nschema validation should have failed\n");
|
||||
VIR_TEST_VERBOSE("\nschema validation should have failed");
|
||||
} else {
|
||||
ret = 0;
|
||||
}
|
||||
|
@ -3026,7 +3026,7 @@ mymain(void)
|
|||
virEventRegisterDefaultImpl();
|
||||
|
||||
if (!(qapiData.schema = testQEMUSchemaLoad())) {
|
||||
VIR_TEST_VERBOSE("failed to load qapi schema\n");
|
||||
VIR_TEST_VERBOSE("failed to load qapi schema");
|
||||
ret = -1;
|
||||
goto cleanup;
|
||||
}
|
||||
|
@ -3267,7 +3267,7 @@ mymain(void)
|
|||
|
||||
if (!(metaschema = testQEMUSchemaGetLatest()) ||
|
||||
!(metaschemastr = virJSONValueToString(metaschema, false))) {
|
||||
VIR_TEST_VERBOSE("failed to load latest qapi schema\n");
|
||||
VIR_TEST_VERBOSE("failed to load latest qapi schema");
|
||||
ret = -1;
|
||||
goto cleanup;
|
||||
}
|
||||
|
|
|
@ -329,7 +329,7 @@ testSELinuxLabeling(const void *opaque)
|
|||
}
|
||||
VIR_FREE(files);
|
||||
if (ret < 0)
|
||||
VIR_TEST_VERBOSE("%s\n", virGetLastErrorMessage());
|
||||
VIR_TEST_VERBOSE("%s", virGetLastErrorMessage());
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -349,7 +349,7 @@ mymain(void)
|
|||
if (!(mgr = virSecurityManagerNew("selinux", "QEMU",
|
||||
VIR_SECURITY_MANAGER_DEFAULT_CONFINED |
|
||||
VIR_SECURITY_MANAGER_PRIVILEGED))) {
|
||||
VIR_TEST_VERBOSE("Unable to initialize security driver: %s\n",
|
||||
VIR_TEST_VERBOSE("Unable to initialize security driver: %s",
|
||||
virGetLastErrorMessage());
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
|
|
@ -93,10 +93,10 @@ unsigned int virTestGetRegenerate(void);
|
|||
fprintf(stderr, fmt "\n", ## __VA_ARGS__); \
|
||||
} while (0)
|
||||
|
||||
#define VIR_TEST_VERBOSE(...) \
|
||||
#define VIR_TEST_VERBOSE(fmt, ...) \
|
||||
do { \
|
||||
if (virTestGetVerbose()) \
|
||||
fprintf(stderr, __VA_ARGS__); \
|
||||
fprintf(stderr, fmt "\n", ## __VA_ARGS__); \
|
||||
} while (0)
|
||||
|
||||
char *virTestLogContentAndReset(void);
|
||||
|
|
|
@ -851,7 +851,7 @@ testQemuGetLatestCapsForArch(const char *arch,
|
|||
goto cleanup;
|
||||
|
||||
if (!maxname) {
|
||||
VIR_TEST_VERBOSE("failed to find capabilities for '%s' in '%s'\n",
|
||||
VIR_TEST_VERBOSE("failed to find capabilities for '%s' in '%s'",
|
||||
arch, TEST_QEMU_CAPS_PATH);
|
||||
goto cleanup;
|
||||
}
|
||||
|
@ -882,7 +882,7 @@ testQemuGetLatestCaps(void)
|
|||
if (!(capslatest = virHashCreate(4, virHashValueFree)))
|
||||
goto error;
|
||||
|
||||
VIR_TEST_VERBOSE("\n");
|
||||
VIR_TEST_VERBOSE("");
|
||||
|
||||
for (i = 0; i < ARRAY_CARDINALITY(archs); ++i) {
|
||||
char *cap = testQemuGetLatestCapsForArch(archs[i], "xml");
|
||||
|
@ -890,10 +890,11 @@ testQemuGetLatestCaps(void)
|
|||
if (!cap || virHashAddEntry(capslatest, archs[i], cap) < 0)
|
||||
goto error;
|
||||
|
||||
VIR_TEST_VERBOSE("latest caps for %s: %s\n", archs[i], cap);
|
||||
VIR_TEST_VERBOSE("latest caps for %s: %s", archs[i], cap);
|
||||
}
|
||||
|
||||
VIR_TEST_VERBOSE("\n");
|
||||
VIR_TEST_VERBOSE("");
|
||||
|
||||
return capslatest;
|
||||
|
||||
error:
|
||||
|
|
|
@ -534,7 +534,7 @@ testQEMUSchemaGetLatest(void)
|
|||
virJSONValuePtr schema = NULL;
|
||||
|
||||
if (!(capsLatestFile = testQemuGetLatestCapsForArch("x86_64", "replies"))) {
|
||||
VIR_TEST_VERBOSE("failed to find latest caps replies\n");
|
||||
VIR_TEST_VERBOSE("failed to find latest caps replies");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -546,7 +546,7 @@ testQEMUSchemaGetLatest(void)
|
|||
if (!(schemaReply = strstr(capsLatest, "\"execute\": \"query-qmp-schema\"")) ||
|
||||
!(schemaReply = strstr(schemaReply, "\n\n")) ||
|
||||
!(end = strstr(schemaReply + 2, "\n\n"))) {
|
||||
VIR_TEST_VERBOSE("failed to find reply to 'query-qmp-schema' in '%s'\n",
|
||||
VIR_TEST_VERBOSE("failed to find reply to 'query-qmp-schema' in '%s'",
|
||||
capsLatestFile);
|
||||
goto cleanup;
|
||||
}
|
||||
|
@ -555,13 +555,13 @@ testQEMUSchemaGetLatest(void)
|
|||
*end = '\0';
|
||||
|
||||
if (!(reply = virJSONValueFromString(schemaReply))) {
|
||||
VIR_TEST_VERBOSE("failed to parse 'query-qmp-schema' reply from '%s'\n",
|
||||
VIR_TEST_VERBOSE("failed to parse 'query-qmp-schema' reply from '%s'",
|
||||
capsLatestFile);
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
if (!(schema = virJSONValueObjectStealArray(reply, "return"))) {
|
||||
VIR_TEST_VERBOSE("missing qapi schema data in reply in '%s'\n",
|
||||
VIR_TEST_VERBOSE("missing qapi schema data in reply in '%s'",
|
||||
capsLatestFile);
|
||||
goto cleanup;
|
||||
}
|
||||
|
|
|
@ -31,11 +31,11 @@ virErrorTestMsgFormatInfoOne(const char *msg)
|
|||
|
||||
for (next = (char *)msg; (next = strchr(next, '%')); next++) {
|
||||
if (next[1] != 's') {
|
||||
VIR_TEST_VERBOSE("\nerror message '%s' contains disallowed printf modifiers\n", msg);
|
||||
VIR_TEST_VERBOSE("\nerror message '%s' contains disallowed printf modifiers", msg);
|
||||
ret = -1;
|
||||
} else {
|
||||
if (found) {
|
||||
VIR_TEST_VERBOSE("\nerror message '%s' contains multiple %%s modifiers\n", msg);
|
||||
VIR_TEST_VERBOSE("\nerror message '%s' contains multiple %%s modifiers", msg);
|
||||
ret = -1;
|
||||
} else {
|
||||
found = true;
|
||||
|
@ -44,7 +44,7 @@ virErrorTestMsgFormatInfoOne(const char *msg)
|
|||
}
|
||||
|
||||
if (!found) {
|
||||
VIR_TEST_VERBOSE("\nerror message '%s' does not contain any %%s modifiers\n", msg);
|
||||
VIR_TEST_VERBOSE("\nerror message '%s' does not contain any %%s modifiers", msg);
|
||||
ret = -1;
|
||||
}
|
||||
|
||||
|
@ -65,17 +65,17 @@ virErrorTestMsgs(const void *opaque ATTRIBUTE_UNUSED)
|
|||
err_info = virErrorMsg(i, "");
|
||||
|
||||
if (!err_noinfo) {
|
||||
VIR_TEST_VERBOSE("\nmissing string without info for error id %zu\n", i);
|
||||
VIR_TEST_VERBOSE("\nmissing string without info for error id %zu", i);
|
||||
ret = -1;
|
||||
}
|
||||
|
||||
if (!err_info) {
|
||||
VIR_TEST_VERBOSE("\nmissing string with info for error id %zu\n", i);
|
||||
VIR_TEST_VERBOSE("\nmissing string with info for error id %zu", i);
|
||||
ret = -1;
|
||||
}
|
||||
|
||||
if (err_noinfo && strchr(err_noinfo, '%')) {
|
||||
VIR_TEST_VERBOSE("\nerror message id %zu contains formatting characters: '%s'\n",
|
||||
VIR_TEST_VERBOSE("\nerror message id %zu contains formatting characters: '%s'",
|
||||
i, err_noinfo);
|
||||
ret = -1;
|
||||
}
|
||||
|
|
|
@ -41,7 +41,7 @@ testHashInit(int size)
|
|||
|
||||
for (i = 0; i < ARRAY_CARDINALITY(uuids); i++) {
|
||||
if (!virHashLookup(hash, uuids[i])) {
|
||||
VIR_TEST_VERBOSE("\nentry \"%s\" could not be found\n", uuids[i]);
|
||||
VIR_TEST_VERBOSE("\nentry \"%s\" could not be found", uuids[i]);
|
||||
virHashFree(hash);
|
||||
return NULL;
|
||||
}
|
||||
|
@ -69,7 +69,7 @@ testHashCheckCount(virHashTablePtr hash, size_t count)
|
|||
size_t iter_count = 0;
|
||||
|
||||
if (virHashSize(hash) != count) {
|
||||
VIR_TEST_VERBOSE("\nhash contains %zd instead of %zu elements\n",
|
||||
VIR_TEST_VERBOSE("\nhash contains %zd instead of %zu elements",
|
||||
virHashSize(hash), count);
|
||||
return -1;
|
||||
}
|
||||
|
@ -77,7 +77,7 @@ testHashCheckCount(virHashTablePtr hash, size_t count)
|
|||
virHashForEach(hash, testHashCheckForEachCount, &iter_count);
|
||||
if (count != iter_count) {
|
||||
VIR_TEST_VERBOSE("\nhash claims to have %zu elements but iteration"
|
||||
"finds %zu\n", count, iter_count);
|
||||
"finds %zu", count, iter_count);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -125,7 +125,7 @@ testHashUpdate(const void *data ATTRIBUTE_UNUSED)
|
|||
|
||||
for (i = 0; i < ARRAY_CARDINALITY(uuids_subset); i++) {
|
||||
if (virHashUpdateEntry(hash, uuids_subset[i], (void *) 1) < 0) {
|
||||
VIR_TEST_VERBOSE("\nentry \"%s\" could not be updated\n",
|
||||
VIR_TEST_VERBOSE("\nentry \"%s\" could not be updated",
|
||||
uuids_subset[i]);
|
||||
goto cleanup;
|
||||
}
|
||||
|
@ -133,7 +133,7 @@ testHashUpdate(const void *data ATTRIBUTE_UNUSED)
|
|||
|
||||
for (i = 0; i < ARRAY_CARDINALITY(uuids_new); i++) {
|
||||
if (virHashUpdateEntry(hash, uuids_new[i], (void *) 1) < 0) {
|
||||
VIR_TEST_VERBOSE("\nnew entry \"%s\" could not be updated\n",
|
||||
VIR_TEST_VERBOSE("\nnew entry \"%s\" could not be updated",
|
||||
uuids_new[i]);
|
||||
goto cleanup;
|
||||
}
|
||||
|
@ -163,7 +163,7 @@ testHashRemove(const void *data ATTRIBUTE_UNUSED)
|
|||
|
||||
for (i = 0; i < ARRAY_CARDINALITY(uuids_subset); i++) {
|
||||
if (virHashRemoveEntry(hash, uuids_subset[i]) < 0) {
|
||||
VIR_TEST_VERBOSE("\nentry \"%s\" could not be removed\n",
|
||||
VIR_TEST_VERBOSE("\nentry \"%s\" could not be removed",
|
||||
uuids_subset[i]);
|
||||
goto cleanup;
|
||||
}
|
||||
|
@ -257,7 +257,7 @@ testHashSteal(const void *data ATTRIBUTE_UNUSED)
|
|||
|
||||
for (i = 0; i < ARRAY_CARDINALITY(uuids_subset); i++) {
|
||||
if (!virHashSteal(hash, uuids_subset[i])) {
|
||||
VIR_TEST_VERBOSE("\nentry \"%s\" could not be stolen\n",
|
||||
VIR_TEST_VERBOSE("\nentry \"%s\" could not be stolen",
|
||||
uuids_subset[i]);
|
||||
goto cleanup;
|
||||
}
|
||||
|
@ -316,7 +316,7 @@ testHashRemoveSet(const void *data ATTRIBUTE_UNUSED)
|
|||
|
||||
if (count != rcount) {
|
||||
VIR_TEST_VERBOSE("\nvirHashRemoveSet didn't remove expected number of"
|
||||
" entries, %d != %u\n",
|
||||
" entries, %d != %u",
|
||||
rcount, count);
|
||||
goto cleanup;
|
||||
}
|
||||
|
@ -355,7 +355,7 @@ testHashSearch(const void *data ATTRIBUTE_UNUSED)
|
|||
entry = virHashSearch(hash, testHashSearchIter, NULL, NULL);
|
||||
|
||||
if (!entry || STRNEQ(uuids_subset[testSearchIndex], entry)) {
|
||||
VIR_TEST_VERBOSE("\nvirHashSearch didn't find entry '%s'\n",
|
||||
VIR_TEST_VERBOSE("\nvirHashSearch didn't find entry '%s'",
|
||||
uuids_subset[testSearchIndex]);
|
||||
goto cleanup;
|
||||
}
|
||||
|
|
|
@ -39,7 +39,7 @@ testJSONFromFile(const void *data)
|
|||
|
||||
if (!injson) {
|
||||
if (info->pass) {
|
||||
VIR_TEST_VERBOSE("Failed to parse %s\n", info->doc);
|
||||
VIR_TEST_VERBOSE("Failed to parse %s", info->doc);
|
||||
return -1;
|
||||
} else {
|
||||
VIR_TEST_DEBUG("As expected, failed to parse %s", info->doc);
|
||||
|
@ -47,7 +47,7 @@ testJSONFromFile(const void *data)
|
|||
}
|
||||
} else {
|
||||
if (!info->pass) {
|
||||
VIR_TEST_VERBOSE("Unexpected success while parsing %s\n", info->doc);
|
||||
VIR_TEST_VERBOSE("Unexpected success while parsing %s", info->doc);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
@ -74,7 +74,7 @@ testJSONFromString(const void *data)
|
|||
|
||||
if (!json) {
|
||||
if (info->pass) {
|
||||
VIR_TEST_VERBOSE("Failed to parse %s\n", info->doc);
|
||||
VIR_TEST_VERBOSE("Failed to parse %s", info->doc);
|
||||
return -1;
|
||||
} else {
|
||||
VIR_TEST_DEBUG("As expected, failed to parse %s", info->doc);
|
||||
|
@ -82,7 +82,7 @@ testJSONFromString(const void *data)
|
|||
}
|
||||
} else {
|
||||
if (!info->pass) {
|
||||
VIR_TEST_VERBOSE("Unexpected success while parsing %s\n", info->doc);
|
||||
VIR_TEST_VERBOSE("Unexpected success while parsing %s", info->doc);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
@ -90,7 +90,7 @@ testJSONFromString(const void *data)
|
|||
VIR_TEST_DEBUG("Parsed %s", info->doc);
|
||||
|
||||
if (!(formatted = virJSONValueToString(json, false))) {
|
||||
VIR_TEST_VERBOSE("Failed to format json data\n");
|
||||
VIR_TEST_VERBOSE("Failed to format json data");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -125,14 +125,14 @@ testJSONAddRemove(const void *data)
|
|||
|
||||
json = virJSONValueFromString(indata);
|
||||
if (!json) {
|
||||
VIR_TEST_VERBOSE("Fail to parse %s\n", info->name);
|
||||
VIR_TEST_VERBOSE("Fail to parse %s", info->name);
|
||||
return -1;
|
||||
}
|
||||
|
||||
switch (virJSONValueObjectRemoveKey(json, "name", &name)) {
|
||||
case 1:
|
||||
if (!info->pass) {
|
||||
VIR_TEST_VERBOSE("should not remove from non-object %s\n",
|
||||
VIR_TEST_VERBOSE("should not remove from non-object %s",
|
||||
info->name);
|
||||
return -1;
|
||||
}
|
||||
|
@ -141,29 +141,29 @@ testJSONAddRemove(const void *data)
|
|||
if (!info->pass)
|
||||
return 0;
|
||||
else
|
||||
VIR_TEST_VERBOSE("Fail to recognize non-object %s\n", info->name);
|
||||
VIR_TEST_VERBOSE("Fail to recognize non-object %s", info->name);
|
||||
return -1;
|
||||
default:
|
||||
VIR_TEST_VERBOSE("unexpected result when removing from %s\n",
|
||||
VIR_TEST_VERBOSE("unexpected result when removing from %s",
|
||||
info->name);
|
||||
return -1;
|
||||
}
|
||||
if (STRNEQ_NULLABLE(virJSONValueGetString(name), "sample")) {
|
||||
VIR_TEST_VERBOSE("unexpected value after removing name: %s\n",
|
||||
VIR_TEST_VERBOSE("unexpected value after removing name: %s",
|
||||
NULLSTR(virJSONValueGetString(name)));
|
||||
return -1;
|
||||
}
|
||||
if (virJSONValueObjectRemoveKey(json, "name", NULL)) {
|
||||
VIR_TEST_VERBOSE("%s",
|
||||
"unexpected success when removing missing key\n");
|
||||
"unexpected success when removing missing key");
|
||||
return -1;
|
||||
}
|
||||
if (virJSONValueObjectAppendString(json, "newname", "foo") < 0) {
|
||||
VIR_TEST_VERBOSE("%s", "unexpected failure adding new key\n");
|
||||
VIR_TEST_VERBOSE("%s", "unexpected failure adding new key");
|
||||
return -1;
|
||||
}
|
||||
if (!(actual = virJSONValueToString(json, false))) {
|
||||
VIR_TEST_VERBOSE("%s", "failed to stringize result\n");
|
||||
VIR_TEST_VERBOSE("%s", "failed to stringize result");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -187,28 +187,28 @@ testJSONLookup(const void *data)
|
|||
|
||||
json = virJSONValueFromString(info->doc);
|
||||
if (!json) {
|
||||
VIR_TEST_VERBOSE("Fail to parse %s\n", info->doc);
|
||||
VIR_TEST_VERBOSE("Fail to parse %s", info->doc);
|
||||
return -1;
|
||||
}
|
||||
|
||||
value = virJSONValueObjectGetObject(json, "a");
|
||||
if (value) {
|
||||
if (!info->pass) {
|
||||
VIR_TEST_VERBOSE("lookup for 'a' in '%s' should have failed\n",
|
||||
VIR_TEST_VERBOSE("lookup for 'a' in '%s' should have failed",
|
||||
info->doc);
|
||||
return -1;
|
||||
} else {
|
||||
result = virJSONValueToString(value, false);
|
||||
if (STRNEQ_NULLABLE(result, "{}")) {
|
||||
VIR_TEST_VERBOSE("lookup for 'a' in '%s' found '%s' but "
|
||||
"should have found '{}'\n",
|
||||
"should have found '{}'",
|
||||
info->doc, NULLSTR(result));
|
||||
return -1;
|
||||
}
|
||||
VIR_FREE(result);
|
||||
}
|
||||
} else if (info->pass) {
|
||||
VIR_TEST_VERBOSE("lookup for 'a' in '%s' should have succeeded\n",
|
||||
VIR_TEST_VERBOSE("lookup for 'a' in '%s' should have succeeded",
|
||||
info->doc);
|
||||
return -1;
|
||||
}
|
||||
|
@ -217,17 +217,17 @@ testJSONLookup(const void *data)
|
|||
rc = virJSONValueObjectGetNumberInt(json, "b", &number);
|
||||
if (rc == 0) {
|
||||
if (!info->pass) {
|
||||
VIR_TEST_VERBOSE("lookup for 'b' in '%s' should have failed\n",
|
||||
VIR_TEST_VERBOSE("lookup for 'b' in '%s' should have failed",
|
||||
info->doc);
|
||||
return -1;
|
||||
} else if (number != 1) {
|
||||
VIR_TEST_VERBOSE("lookup for 'b' in '%s' found %d but "
|
||||
"should have found 1\n",
|
||||
"should have found 1",
|
||||
info->doc, number);
|
||||
return -1;
|
||||
}
|
||||
} else if (info->pass) {
|
||||
VIR_TEST_VERBOSE("lookup for 'b' in '%s' should have succeeded\n",
|
||||
VIR_TEST_VERBOSE("lookup for 'b' in '%s' should have succeeded",
|
||||
info->doc);
|
||||
return -1;
|
||||
}
|
||||
|
@ -235,16 +235,16 @@ testJSONLookup(const void *data)
|
|||
str = virJSONValueObjectGetString(json, "c");
|
||||
if (str) {
|
||||
if (!info->pass) {
|
||||
VIR_TEST_VERBOSE("lookup for 'c' in '%s' should have failed\n",
|
||||
VIR_TEST_VERBOSE("lookup for 'c' in '%s' should have failed",
|
||||
info->doc);
|
||||
return -1;
|
||||
} else if (STRNEQ(str, "str")) {
|
||||
VIR_TEST_VERBOSE("lookup for 'c' in '%s' found '%s' but "
|
||||
"should have found 'str'\n", info->doc, str);
|
||||
"should have found 'str'", info->doc, str);
|
||||
return -1;
|
||||
}
|
||||
} else if (info->pass) {
|
||||
VIR_TEST_VERBOSE("lookup for 'c' in '%s' should have succeeded\n",
|
||||
VIR_TEST_VERBOSE("lookup for 'c' in '%s' should have succeeded",
|
||||
info->doc);
|
||||
return -1;
|
||||
}
|
||||
|
@ -252,21 +252,21 @@ testJSONLookup(const void *data)
|
|||
value = virJSONValueObjectGetArray(json, "d");
|
||||
if (value) {
|
||||
if (!info->pass) {
|
||||
VIR_TEST_VERBOSE("lookup for 'd' in '%s' should have failed\n",
|
||||
VIR_TEST_VERBOSE("lookup for 'd' in '%s' should have failed",
|
||||
info->doc);
|
||||
return -1;
|
||||
} else {
|
||||
result = virJSONValueToString(value, false);
|
||||
if (STRNEQ_NULLABLE(result, "[]")) {
|
||||
VIR_TEST_VERBOSE("lookup for 'd' in '%s' found '%s' but "
|
||||
"should have found '[]'\n",
|
||||
"should have found '[]'",
|
||||
info->doc, NULLSTR(result));
|
||||
return -1;
|
||||
}
|
||||
VIR_FREE(result);
|
||||
}
|
||||
} else if (info->pass) {
|
||||
VIR_TEST_VERBOSE("lookup for 'd' in '%s' should have succeeded\n",
|
||||
VIR_TEST_VERBOSE("lookup for 'd' in '%s' should have succeeded",
|
||||
info->doc);
|
||||
return -1;
|
||||
}
|
||||
|
@ -286,25 +286,25 @@ testJSONCopy(const void *data)
|
|||
|
||||
json = virJSONValueFromString(info->doc);
|
||||
if (!json) {
|
||||
VIR_TEST_VERBOSE("Failed to parse %s\n", info->doc);
|
||||
VIR_TEST_VERBOSE("Failed to parse %s", info->doc);
|
||||
return -1;
|
||||
}
|
||||
|
||||
jsonCopy = virJSONValueCopy(json);
|
||||
if (!jsonCopy) {
|
||||
VIR_TEST_VERBOSE("Failed to copy JSON data\n");
|
||||
VIR_TEST_VERBOSE("Failed to copy JSON data");
|
||||
return -1;
|
||||
}
|
||||
|
||||
result = virJSONValueToString(json, false);
|
||||
if (!result) {
|
||||
VIR_TEST_VERBOSE("Failed to format original JSON data\n");
|
||||
VIR_TEST_VERBOSE("Failed to format original JSON data");
|
||||
return -1;
|
||||
}
|
||||
|
||||
resultCopy = virJSONValueToString(json, false);
|
||||
if (!resultCopy) {
|
||||
VIR_TEST_VERBOSE("Failed to format copied JSON data\n");
|
||||
VIR_TEST_VERBOSE("Failed to format copied JSON data");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -319,13 +319,13 @@ testJSONCopy(const void *data)
|
|||
|
||||
result = virJSONValueToString(json, true);
|
||||
if (!result) {
|
||||
VIR_TEST_VERBOSE("Failed to format original JSON data\n");
|
||||
VIR_TEST_VERBOSE("Failed to format original JSON data");
|
||||
return -1;
|
||||
}
|
||||
|
||||
resultCopy = virJSONValueToString(json, true);
|
||||
if (!resultCopy) {
|
||||
VIR_TEST_VERBOSE("Failed to format copied JSON data\n");
|
||||
VIR_TEST_VERBOSE("Failed to format copied JSON data");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -364,7 +364,7 @@ testJSONDeflatten(const void *data)
|
|||
|
||||
if ((deflattened = virJSONValueObjectDeflatten(injson))) {
|
||||
if (!info->pass) {
|
||||
VIR_TEST_VERBOSE("%s: deflattening should have failed\n", info->name);
|
||||
VIR_TEST_VERBOSE("%s: deflattening should have failed", info->name);
|
||||
return -1;
|
||||
}
|
||||
} else {
|
||||
|
@ -450,22 +450,22 @@ testJSONObjectFormatSteal(const void *opaque ATTRIBUTE_UNUSED)
|
|||
}
|
||||
|
||||
if (virJSONValueObjectCreate(&t1, "a:t", &a1, "s:f", NULL, NULL) != -1) {
|
||||
VIR_TEST_VERBOSE("virJSONValueObjectCreate(t1) should have failed\n");
|
||||
VIR_TEST_VERBOSE("virJSONValueObjectCreate(t1) should have failed");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (a1) {
|
||||
VIR_TEST_VERBOSE("appended object a1 was not consumed\n");
|
||||
VIR_TEST_VERBOSE("appended object a1 was not consumed");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (virJSONValueObjectCreate(&t2, "s:f", NULL, "a:t", &a1, NULL) != -1) {
|
||||
VIR_TEST_VERBOSE("virJSONValueObjectCreate(t2) should have failed\n");
|
||||
VIR_TEST_VERBOSE("virJSONValueObjectCreate(t2) should have failed");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!a2) {
|
||||
VIR_TEST_VERBOSE("appended object a2 was consumed\n");
|
||||
VIR_TEST_VERBOSE("appended object a2 was consumed");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue