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

#include <unistd.h>

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

#include "internal.h"
#include "testutils.h"
#include "storage_conf.h"
#include "testutilsqemu.h"
12
#include "virstring.h"
13

14 15
#define VIR_FROM_THIS VIR_FROM_NONE

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

C
Cole Robinson 已提交
23
    if (!(dev = virStoragePoolDefParseFile(inxml)))
24 25
        goto fail;

26
    if (!(actual = virStoragePoolDefFormat(dev)))
27 28
        goto fail;

29
    if (virTestCompareToFile(actual, outxml) < 0)
30 31 32 33 34
        goto fail;

    ret = 0;

 fail:
35
    VIR_FREE(actual);
36 37 38 39
    virStoragePoolDefFree(dev);
    return ret;
}

40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
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);
55

56
 cleanup:
57 58
    VIR_FREE(inxml);
    VIR_FREE(outxml);
59 60 61

    return result;
}
62 63

static int
E
Eric Blake 已提交
64
mymain(void)
65 66 67
{
    int ret = 0;

68 69 70
#define DO_TEST(name) \
    if (virTestRun("Storage Pool XML-2-XML " name, \
                   testCompareXMLToXMLHelper, (name)) < 0) \
71 72 73
        ret = -1

    DO_TEST("pool-dir");
74
    DO_TEST("pool-dir-naming");
75 76
    DO_TEST("pool-fs");
    DO_TEST("pool-logical");
77
    DO_TEST("pool-logical-nopath");
78
    DO_TEST("pool-logical-create");
79
    DO_TEST("pool-logical-noname");
80
    DO_TEST("pool-disk");
81
    DO_TEST("pool-disk-device-nopartsep");
82 83 84
    DO_TEST("pool-iscsi");
    DO_TEST("pool-iscsi-auth");
    DO_TEST("pool-netfs");
85
    DO_TEST("pool-netfs-auto");
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 100
    DO_TEST("pool-zfs");
    DO_TEST("pool-zfs-sourcedev");
101
    DO_TEST("pool-rbd");
102
    DO_TEST("pool-vstorage");
103 104
    DO_TEST("pool-iscsi-direct-auth");
    DO_TEST("pool-iscsi-direct");
105

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

109
VIR_TEST_MAIN(mymain)