mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-23 14:15:28 +00:00
3e7db8d3e8
Right-aligning backslashes when defining macros or using complex commands in Makefiles looks cute, but as soon as any changes is required to the code you end up with either distractingly broken alignment or unnecessarily big diffs where most of the changes are just pushing all backslashes a few characters to one side. Generated using $ git grep -El '[[:blank:]][[:blank:]]\\$' | \ grep -E '*\.([chx]|am|mk)$$' | \ while read f; do \ sed -Ei 's/[[:blank:]]*[[:blank:]]\\$/ \\/g' "$f"; \ done Signed-off-by: Andrea Bolognani <abologna@redhat.com>
89 lines
1.8 KiB
C
89 lines
1.8 KiB
C
#include <config.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include "internal.h"
|
|
#include "testutils.h"
|
|
#include "secret_conf.h"
|
|
|
|
#define VIR_FROM_THIS VIR_FROM_NONE
|
|
|
|
static int
|
|
testCompareXMLToXMLFiles(const char *inxml, const char *outxml)
|
|
{
|
|
char *actual = NULL;
|
|
int ret = -1;
|
|
virSecretDefPtr secret = NULL;
|
|
|
|
if (!(secret = virSecretDefParseFile(inxml)))
|
|
goto fail;
|
|
|
|
if (!(actual = virSecretDefFormat(secret)))
|
|
goto fail;
|
|
|
|
if (virTestCompareToFile(actual, outxml) < 0)
|
|
goto fail;
|
|
|
|
ret = 0;
|
|
|
|
fail:
|
|
VIR_FREE(actual);
|
|
virSecretDefFree(secret);
|
|
return ret;
|
|
}
|
|
|
|
struct testInfo {
|
|
const char *name;
|
|
bool different;
|
|
};
|
|
|
|
static int
|
|
testCompareXMLToXMLHelper(const void *data)
|
|
{
|
|
int result = -1;
|
|
char *inxml = NULL;
|
|
char *outxml = NULL;
|
|
const struct testInfo *info = data;
|
|
|
|
if (virAsprintf(&inxml, "%s/secretxml2xmlin/%s.xml",
|
|
abs_srcdir, info->name) < 0 ||
|
|
virAsprintf(&outxml, "%s/secretxml2xml%s/%s.xml",
|
|
abs_srcdir,
|
|
info->different ? "out" : "in",
|
|
info->name) < 0) {
|
|
goto cleanup;
|
|
}
|
|
|
|
result = testCompareXMLToXMLFiles(inxml, outxml);
|
|
|
|
cleanup:
|
|
VIR_FREE(inxml);
|
|
VIR_FREE(outxml);
|
|
|
|
return result;
|
|
}
|
|
|
|
static int
|
|
mymain(void)
|
|
{
|
|
int ret = 0;
|
|
|
|
#define DO_TEST(name) \
|
|
do { \
|
|
const struct testInfo info = {name, false}; \
|
|
if (virTestRun("Secret XML->XML " name, \
|
|
testCompareXMLToXMLHelper, &info) < 0) \
|
|
ret = -1; \
|
|
} while (0)
|
|
|
|
DO_TEST("ephemeral-usage-volume");
|
|
DO_TEST("usage-volume");
|
|
DO_TEST("usage-ceph");
|
|
DO_TEST("usage-iscsi");
|
|
DO_TEST("usage-tls");
|
|
|
|
return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
|
|
}
|
|
|
|
VIR_TEST_MAIN(mymain)
|