mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
tests: virjson: Reuse VIR_TEST_VERBOSE in testJSONCopy
Use VIR_TEST_VERBOSE instead of calling virTestGetVerbose and conditionally fprintf. Additionally remove redundant setting of 'ret' to -1.
This commit is contained in:
parent
ffdf532328
commit
a1ac4c880b
@ -240,40 +240,31 @@ testJSONCopy(const void *data)
|
|||||||
|
|
||||||
json = virJSONValueFromString(info->doc);
|
json = virJSONValueFromString(info->doc);
|
||||||
if (!json) {
|
if (!json) {
|
||||||
if (virTestGetVerbose())
|
VIR_TEST_VERBOSE("Failed to parse %s\n", info->doc);
|
||||||
fprintf(stderr, "Failed to parse %s\n", info->doc);
|
|
||||||
ret = -1;
|
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
jsonCopy = virJSONValueCopy(json);
|
jsonCopy = virJSONValueCopy(json);
|
||||||
if (!jsonCopy) {
|
if (!jsonCopy) {
|
||||||
if (virTestGetVerbose())
|
VIR_TEST_VERBOSE("Failed to copy JSON data\n");
|
||||||
fprintf(stderr, "Failed to copy JSON data\n");
|
|
||||||
ret = -1;
|
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
result = virJSONValueToString(json, false);
|
result = virJSONValueToString(json, false);
|
||||||
if (!result) {
|
if (!result) {
|
||||||
if (virTestGetVerbose())
|
VIR_TEST_VERBOSE("Failed to format original JSON data\n");
|
||||||
fprintf(stderr, "Failed to format original JSON data\n");
|
|
||||||
ret = -1;
|
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
resultCopy = virJSONValueToString(json, false);
|
resultCopy = virJSONValueToString(json, false);
|
||||||
if (!resultCopy) {
|
if (!resultCopy) {
|
||||||
if (virTestGetVerbose())
|
VIR_TEST_VERBOSE("Failed to format copied JSON data\n");
|
||||||
fprintf(stderr, "Failed to format copied JSON data\n");
|
|
||||||
ret = -1;
|
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (STRNEQ(result, resultCopy)) {
|
if (STRNEQ(result, resultCopy)) {
|
||||||
if (virTestGetVerbose())
|
if (virTestGetVerbose())
|
||||||
virTestDifference(stderr, result, resultCopy);
|
virTestDifference(stderr, result, resultCopy);
|
||||||
ret = -1;
|
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -282,24 +273,19 @@ testJSONCopy(const void *data)
|
|||||||
|
|
||||||
result = virJSONValueToString(json, true);
|
result = virJSONValueToString(json, true);
|
||||||
if (!result) {
|
if (!result) {
|
||||||
if (virTestGetVerbose())
|
VIR_TEST_VERBOSE("Failed to format original JSON data\n");
|
||||||
fprintf(stderr, "Failed to format original JSON data\n");
|
|
||||||
ret = -1;
|
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
resultCopy = virJSONValueToString(json, true);
|
resultCopy = virJSONValueToString(json, true);
|
||||||
if (!resultCopy) {
|
if (!resultCopy) {
|
||||||
if (virTestGetVerbose())
|
VIR_TEST_VERBOSE("Failed to format copied JSON data\n");
|
||||||
fprintf(stderr, "Failed to format copied JSON data\n");
|
|
||||||
ret = -1;
|
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (STRNEQ(result, resultCopy)) {
|
if (STRNEQ(result, resultCopy)) {
|
||||||
if (virTestGetVerbose())
|
if (virTestGetVerbose())
|
||||||
virTestDifference(stderr, result, resultCopy);
|
virTestDifference(stderr, result, resultCopy);
|
||||||
ret = -1;
|
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user