Some earlier versions of json-c format empty elements differently.
Run the tests who use the pretty formatting for readability and
diffability through a function that unifies the output.
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
g_autofree char *expectpath = NULL;
g_autoptr(virStorageSource) target = NULL;
g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
+ g_autofree char *actual = NULL;
expectpath = g_strdup_printf("%s/%s%s-out.json", abs_srcdir,
backupDataPrefix, data->name);
virBufferAddLit(&buf, "NULL\n");
}
- return virTestCompareToFile(virBufferCurrentContent(&buf), expectpath);
+ actual = virJSONStringPrettifyBlanks(virBufferCurrentContent(&buf));
+
+ return virTestCompareToFile(actual, expectpath);
}
g_autoptr(virJSONValue) paramsIn = NULL;
g_autoptr(virJSONValue) paramsOut = NULL;
g_autoptr(qemuMigrationParams) migParams = NULL;
+ g_autofree char *formattedJSON = NULL;
g_autofree char *actualJSON = NULL;
g_auto(virBuffer) debug = VIR_BUFFER_INITIALIZER;
return -1;
if (!(paramsOut = qemuMigrationParamsToJSON(migParams, false)) ||
- !(actualJSON = virJSONValueToString(paramsOut, true)))
+ !(formattedJSON = virJSONValueToString(paramsOut, true)))
return -1;
+ actualJSON = virJSONStringPrettifyBlanks(formattedJSON);
+
if (testQEMUSchemaValidateCommand("migrate-set-parameters",
paramsOut,
data->qmpschema,
const struct testData *data = opaque;
g_autofree char *file = NULL;
g_autofree char *str = NULL;
+ g_autofree char *actual = NULL;
file = g_strdup_printf("%s/virmacmaptestdata/%s.json", abs_srcdir, data->file);
if (virMacMapDumpStr(data->mgr, &str) < 0)
return -1;
- if (virTestCompareToFile(str, file) < 0)
+ actual = virJSONStringPrettifyBlanks(str);
+
+ if (virTestCompareToFile(actual, file) < 0)
return -1;
return 0;