Files
libvirt/tests/storagepoolxml2xmltest.c
T

109 lines
2.5 KiB
C
Raw Normal View History

#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"
#include "virstring.h"
2013-06-07 17:10:28 +02:00
#define VIR_FROM_THIS VIR_FROM_NONE
2011-04-25 00:25:10 +02:00
static int
testCompareXMLToXMLFiles(const char *inxml, const char *outxml)
{
char *actual = NULL;
int ret = -1;
virStoragePoolDefPtr dev = NULL;
2015-04-23 11:10:15 -04:00
if (!(dev = virStoragePoolDefParseFile(inxml)))
goto fail;
if (!(actual = virStoragePoolDefFormat(dev)))
goto fail;
2015-04-23 11:14:26 -04:00
if (virtTestCompareToFile(actual, outxml) < 0)
goto fail;
ret = 0;
fail:
2012-02-02 16:16:43 -07:00
VIR_FREE(actual);
virStoragePoolDefFree(dev);
return ret;
}
2011-04-25 00:25:10 +02:00
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);
cleanup:
2012-02-02 16:16:43 -07:00
VIR_FREE(inxml);
VIR_FREE(outxml);
2011-04-25 00:25:10 +02:00
return result;
}
static int
2011-04-29 10:21:20 -06:00
mymain(void)
{
int ret = 0;
2013-09-20 19:13:35 +01:00
#define DO_TEST(name) \
if (virtTestRun("Storage Pool XML-2-XML " name, \
testCompareXMLToXMLHelper, (name)) < 0) \
ret = -1
DO_TEST("pool-dir");
DO_TEST("pool-dir-naming");
DO_TEST("pool-fs");
DO_TEST("pool-logical");
DO_TEST("pool-logical-nopath");
DO_TEST("pool-logical-create");
DO_TEST("pool-disk");
DO_TEST("pool-disk-device-nopartsep");
DO_TEST("pool-iscsi");
DO_TEST("pool-iscsi-auth");
DO_TEST("pool-netfs");
DO_TEST("pool-netfs-gluster");
DO_TEST("pool-netfs-cifs");
DO_TEST("pool-scsi");
DO_TEST("pool-scsi-type-scsi-host");
DO_TEST("pool-scsi-type-fc-host");
DO_TEST("pool-scsi-type-fc-host-managed");
DO_TEST("pool-mpath");
2010-06-07 16:47:37 -04:00
DO_TEST("pool-iscsi-multiiqn");
DO_TEST("pool-iscsi-vendor-product");
DO_TEST("pool-sheepdog");
2013-10-15 17:06:18 -06:00
DO_TEST("pool-gluster");
DO_TEST("pool-gluster-sub");
DO_TEST("pool-scsi-type-scsi-host-stable");
2015-01-16 17:38:32 +00:00
#ifdef WITH_STORAGE_ZFS
DO_TEST("pool-zfs");
DO_TEST("pool-zfs-sourcedev");
2015-01-16 17:38:32 +00:00
#endif
2014-03-17 10:38:38 +01:00
return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
}
VIRT_TEST_MAIN(mymain)