mirror of
https://github.com/libvirt/libvirt.git
synced 2025-01-06 14:13:27 -06:00
tests: switch to compact empty JSON object formatting
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>
This commit is contained in:
parent
330cf7f492
commit
8eba36d4b1
@ -720,6 +720,7 @@ testQemuBackupIncrementalBitmapCalculate(const void *opaque)
|
||||
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);
|
||||
@ -748,7 +749,9 @@ testQemuBackupIncrementalBitmapCalculate(const void *opaque)
|
||||
virBufferAddLit(&buf, "NULL\n");
|
||||
}
|
||||
|
||||
return virTestCompareToFile(virBufferCurrentContent(&buf), expectpath);
|
||||
actual = virJSONStringPrettifyBlanks(virBufferCurrentContent(&buf));
|
||||
|
||||
return virTestCompareToFile(actual, expectpath);
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,3 +1 @@
|
||||
[
|
||||
|
||||
]
|
||||
[]
|
||||
|
@ -1,3 +1 @@
|
||||
{
|
||||
|
||||
}
|
||||
{}
|
||||
|
@ -137,6 +137,7 @@ qemuMigParamsTestJSON(const void *opaque)
|
||||
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;
|
||||
|
||||
@ -156,9 +157,11 @@ qemuMigParamsTestJSON(const void *opaque)
|
||||
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,
|
||||
|
@ -118,13 +118,16 @@ testMACFlush(const void *opaque)
|
||||
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;
|
||||
|
@ -1,3 +1 @@
|
||||
[
|
||||
|
||||
]
|
||||
[]
|
||||
|
Loading…
Reference in New Issue
Block a user