storagepoolxml2xmltest.c 2.4 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14
#include <config.h>

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>

#include <sys/types.h>
#include <fcntl.h>

#include "internal.h"
#include "testutils.h"
#include "storage_conf.h"
#include "testutilsqemu.h"
15
#include "virstring.h"
16

17 18
#define VIR_FROM_THIS VIR_FROM_NONE

19 20 21
static int
testCompareXMLToXMLFiles(const char *inxml, const char *outxml)
{
22 23 24 25
    char *actual = NULL;
    int ret = -1;
    virStoragePoolDefPtr dev = NULL;

C
Cole Robinson 已提交
26
    if (!(dev = virStoragePoolDefParseFile(inxml)))
27 28
        goto fail;

29
    if (!(actual = virStoragePoolDefFormat(dev)))
30 31
        goto fail;

C
Cole Robinson 已提交
32
    if (virtTestCompareToFile(actual, outxml) < 0)
33 34 35 36 37
        goto fail;

    ret = 0;

 fail:
38
    VIR_FREE(actual);
39 40 41 42
    virStoragePoolDefFree(dev);
    return ret;
}

43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
static int
testCompareXMLToXMLHelper(const void *data)
{
    int result = -1;
    char *inxml = NULL;
    char *outxml = NULL;

    if (virAsprintf(&inxml, "%s/storagepoolxml2xmlin/%s.xml",
                    abs_srcdir, (const char*)data) < 0 ||
        virAsprintf(&outxml, "%s/storagepoolxml2xmlout/%s.xml",
                    abs_srcdir, (const char*)data) < 0) {
        goto cleanup;
    }

    result = testCompareXMLToXMLFiles(inxml, outxml);
58

59
 cleanup:
60 61
    VIR_FREE(inxml);
    VIR_FREE(outxml);
62 63 64

    return result;
}
65 66

static int
E
Eric Blake 已提交
67
mymain(void)
68 69 70
{
    int ret = 0;

71 72 73
#define DO_TEST(name)                                           \
    if (virtTestRun("Storage Pool XML-2-XML " name,             \
                    testCompareXMLToXMLHelper, (name)) < 0)     \
74 75 76
        ret = -1

    DO_TEST("pool-dir");
77
    DO_TEST("pool-dir-naming");
78 79
    DO_TEST("pool-fs");
    DO_TEST("pool-logical");
80
    DO_TEST("pool-logical-nopath");
81 82 83 84 85
    DO_TEST("pool-logical-create");
    DO_TEST("pool-disk");
    DO_TEST("pool-iscsi");
    DO_TEST("pool-iscsi-auth");
    DO_TEST("pool-netfs");
86
    DO_TEST("pool-netfs-gluster");
87
    DO_TEST("pool-netfs-cifs");
88
    DO_TEST("pool-scsi");
89 90
    DO_TEST("pool-scsi-type-scsi-host");
    DO_TEST("pool-scsi-type-fc-host");
91
    DO_TEST("pool-scsi-type-fc-host-managed");
92
    DO_TEST("pool-mpath");
D
David Allan 已提交
93
    DO_TEST("pool-iscsi-multiiqn");
94
    DO_TEST("pool-iscsi-vendor-product");
95
    DO_TEST("pool-sheepdog");
E
Eric Blake 已提交
96 97
    DO_TEST("pool-gluster");
    DO_TEST("pool-gluster-sub");
98
    DO_TEST("pool-scsi-type-scsi-host-stable");
99
#ifdef WITH_STORAGE_ZFS
100 101
    DO_TEST("pool-zfs");
    DO_TEST("pool-zfs-sourcedev");
102
#endif
103

104
    return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
105 106 107
}

VIRT_TEST_MAIN(mymain)