storagepoolxml2xmltest.c 2.5 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;

32
    if (virTestCompareToFile(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
#define DO_TEST(name)                                           \
72 73
    if (virTestRun("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
    DO_TEST("pool-logical-create");
    DO_TEST("pool-disk");
83
    DO_TEST("pool-disk-device-nopartsep");
84 85 86
    DO_TEST("pool-iscsi");
    DO_TEST("pool-iscsi-auth");
    DO_TEST("pool-netfs");
87
    DO_TEST("pool-netfs-gluster");
88
    DO_TEST("pool-netfs-cifs");
89
    DO_TEST("pool-scsi");
90 91
    DO_TEST("pool-scsi-type-scsi-host");
    DO_TEST("pool-scsi-type-fc-host");
92
    DO_TEST("pool-scsi-type-fc-host-managed");
93
    DO_TEST("pool-mpath");
D
David Allan 已提交
94
    DO_TEST("pool-iscsi-multiiqn");
95
    DO_TEST("pool-iscsi-vendor-product");
96
    DO_TEST("pool-sheepdog");
E
Eric Blake 已提交
97 98
    DO_TEST("pool-gluster");
    DO_TEST("pool-gluster-sub");
99
    DO_TEST("pool-scsi-type-scsi-host-stable");
100 101
    DO_TEST("pool-zfs");
    DO_TEST("pool-zfs-sourcedev");
102
    DO_TEST("pool-rbd");
103
    DO_TEST("pool-vstorage");
104

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

VIRT_TEST_MAIN(mymain)