mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 13:45:38 +00:00
Re-factor and pretty print differences
This commit is contained in:
parent
484559148d
commit
94353ef660
@ -1,3 +1,12 @@
|
|||||||
|
Fri Apr 18 11:26:24 EST 2008 Daniel P. Berrange <berrange@redhat.com>
|
||||||
|
|
||||||
|
* tests/Makefile.am: Add abs_srcdir and abs_builddir to test
|
||||||
|
environment
|
||||||
|
* tests/test_conf.sh: Refactor to pretty print
|
||||||
|
* tests/statstest.c, tests/xencapstest.c, tests/xmconfigtest.c:
|
||||||
|
Use new virtTestDifference for display. Autoset abs_srcdir if
|
||||||
|
not in environment. Refactor common code into macros
|
||||||
|
|
||||||
Fri Apr 18 11:04:24 EST 2008 Daniel P. Berrange <berrange@redhat.com>
|
Fri Apr 18 11:04:24 EST 2008 Daniel P. Berrange <berrange@redhat.com>
|
||||||
|
|
||||||
* tests/testutils.h, tests/testutils.c: Add virtTestDifference
|
* tests/testutils.h, tests/testutils.c: Add virtTestDifference
|
||||||
|
@ -66,6 +66,8 @@ path_add = $$abs_top_builddir/src$(PATH_SEPARATOR)$$abs_top_builddir/qemud
|
|||||||
TESTS_ENVIRONMENT = \
|
TESTS_ENVIRONMENT = \
|
||||||
abs_top_builddir=`cd '$(top_builddir)'; pwd` \
|
abs_top_builddir=`cd '$(top_builddir)'; pwd` \
|
||||||
abs_top_srcdir=`cd '$(top_srcdir)'; pwd` \
|
abs_top_srcdir=`cd '$(top_srcdir)'; pwd` \
|
||||||
|
abs_builddir=`cd '$(builddir)'; pwd` \
|
||||||
|
abs_srcdir=`cd '$(srcdir)'; pwd` \
|
||||||
PATH="$(path_add)$(PATH_SEPARATOR)$$PATH" \
|
PATH="$(path_add)$(PATH_SEPARATOR)$$PATH" \
|
||||||
SHELL="$(SHELL)" \
|
SHELL="$(SHELL)" \
|
||||||
$(VG)
|
$(VG)
|
||||||
|
@ -7,6 +7,8 @@
|
|||||||
#include "stats_linux.h"
|
#include "stats_linux.h"
|
||||||
#include "internal.h"
|
#include "internal.h"
|
||||||
|
|
||||||
|
#include "testutils.h"
|
||||||
|
|
||||||
#if WITH_XEN
|
#if WITH_XEN
|
||||||
static void testQuietError(void *userData ATTRIBUTE_UNUSED,
|
static void testQuietError(void *userData ATTRIBUTE_UNUSED,
|
||||||
virErrorPtr error ATTRIBUTE_UNUSED)
|
virErrorPtr error ATTRIBUTE_UNUSED)
|
||||||
@ -21,13 +23,26 @@ static int testDevice(const char *path, int expect)
|
|||||||
int actual = xenLinuxDomainDeviceID(NULL, 1, path);
|
int actual = xenLinuxDomainDeviceID(NULL, 1, path);
|
||||||
|
|
||||||
if (actual == expect) {
|
if (actual == expect) {
|
||||||
fprintf(stderr, "%-14s == %-6d OK\n", path, expect);
|
|
||||||
return 0;
|
return 0;
|
||||||
} else {
|
} else {
|
||||||
fprintf(stderr, "%-14s == %-6d (%-6d) FAILED\n", path, expect, actual);
|
if (getenv("DEBUG_TESTS"))
|
||||||
|
fprintf(stderr, "Expect %-6d Actual %-6d\n", expect, actual);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct testInfo
|
||||||
|
{
|
||||||
|
const char *dev;
|
||||||
|
int num;
|
||||||
|
};
|
||||||
|
|
||||||
|
static int testDeviceHelper(const void *data)
|
||||||
|
{
|
||||||
|
const struct testInfo *info = data;
|
||||||
|
return testDevice(info->dev, info->num);
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int
|
int
|
||||||
@ -42,85 +57,67 @@ main(void)
|
|||||||
if (!getenv("DEBUG_TESTS"))
|
if (!getenv("DEBUG_TESTS"))
|
||||||
virSetErrorFunc(NULL, testQuietError);
|
virSetErrorFunc(NULL, testQuietError);
|
||||||
|
|
||||||
|
#define DO_TEST(dev, num) \
|
||||||
|
do { \
|
||||||
|
struct testInfo info = { dev, num }; \
|
||||||
|
if (virtTestRun("Device " dev " -> " # num, \
|
||||||
|
1, testDeviceHelper, &info) < 0) \
|
||||||
|
ret = -1; \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
/********************************
|
/********************************
|
||||||
* Xen paravirt disks
|
* Xen paravirt disks
|
||||||
********************************/
|
********************************/
|
||||||
|
|
||||||
/* first valid disk */
|
/* first valid disk */
|
||||||
if (testDevice("xvda", 51712) < 0)
|
DO_TEST("xvda", 51712);
|
||||||
ret = -1;
|
DO_TEST("xvda1", 51713);
|
||||||
if (testDevice("xvda1", 51713) < 0)
|
DO_TEST("xvda15", 51727);
|
||||||
ret = -1;
|
|
||||||
if (testDevice("xvda15", 51727) < 0)
|
|
||||||
ret = -1;
|
|
||||||
/* Last valid disk */
|
/* Last valid disk */
|
||||||
if (testDevice("xvdp", 51952) < 0)
|
DO_TEST("xvdp", 51952);
|
||||||
ret = -1;
|
DO_TEST("xvdp1", 51953);
|
||||||
if (testDevice("xvdp1", 51953) < 0)
|
DO_TEST("xvdp15", 51967);
|
||||||
ret = -1;
|
|
||||||
if (testDevice("xvdp15", 51967) < 0)
|
|
||||||
ret = -1;
|
|
||||||
|
|
||||||
/* Disk letter to large */
|
/* Disk letter to large */
|
||||||
if (testDevice("xvdq", -1) < 0)
|
DO_TEST("xvdq", -1);
|
||||||
ret = -1;
|
|
||||||
/* missing disk letter */
|
/* missing disk letter */
|
||||||
if (testDevice("xvd1", -1) < 0)
|
DO_TEST("xvd1", -1);
|
||||||
ret = -1;
|
|
||||||
/* partition to large */
|
/* partition to large */
|
||||||
if (testDevice("xvda16", -1) < 0)
|
DO_TEST("xvda16", -1);
|
||||||
ret = -1;
|
|
||||||
/* partition to small */
|
/* partition to small */
|
||||||
if (testDevice("xvda0", -1) < 0)
|
DO_TEST("xvda0", -1);
|
||||||
ret = -1;
|
|
||||||
/* leading zeros */
|
/* leading zeros */
|
||||||
if (testDevice("xvda01", -1) < 0)
|
DO_TEST("xvda01", -1);
|
||||||
ret = -1;
|
|
||||||
/* leading + */
|
/* leading + */
|
||||||
if (testDevice("xvda+1", -1) < 0)
|
DO_TEST("xvda+1", -1);
|
||||||
ret = -1;
|
|
||||||
/* leading - */
|
/* leading - */
|
||||||
if (testDevice("xvda-1", -1) < 0)
|
DO_TEST("xvda-1", -1);
|
||||||
ret = -1;
|
|
||||||
|
|
||||||
/********************************
|
/********************************
|
||||||
* IDE disks
|
* IDE disks
|
||||||
********************************/
|
********************************/
|
||||||
|
|
||||||
/* odd numbered disk */
|
/* odd numbered disk */
|
||||||
if (testDevice("hda", 768) < 0)
|
DO_TEST("hda", 768);
|
||||||
ret = -1;
|
DO_TEST("hda1", 769);
|
||||||
if (testDevice("hda1", 769) < 0)
|
DO_TEST("hda63", 831);
|
||||||
ret = -1;
|
|
||||||
if (testDevice("hda63", 831) < 0)
|
|
||||||
ret = -1;
|
|
||||||
/* even number disk */
|
/* even number disk */
|
||||||
if (testDevice("hdd", 5695) < 0)
|
DO_TEST("hdd", 5695);
|
||||||
ret = -1;
|
DO_TEST("hdd1", 5696);
|
||||||
if (testDevice("hdd1", 5696) < 0)
|
DO_TEST("hdd63", 5758);
|
||||||
ret = -1;
|
|
||||||
if (testDevice("hdd63", 5758) < 0)
|
|
||||||
ret = -1;
|
|
||||||
/* last valid disk */
|
/* last valid disk */
|
||||||
if (testDevice("hdt", 23359) < 0)
|
DO_TEST("hdt", 23359);
|
||||||
ret = -1;
|
DO_TEST("hdt1", 23360);
|
||||||
if (testDevice("hdt1", 23360) < 0)
|
DO_TEST("hdt63", 23422);
|
||||||
ret = -1;
|
|
||||||
if (testDevice("hdt63", 23422) < 0)
|
|
||||||
ret = -1;
|
|
||||||
|
|
||||||
/* Disk letter to large */
|
/* Disk letter to large */
|
||||||
if (testDevice("hdu", -1) < 0)
|
DO_TEST("hdu", -1);
|
||||||
ret = -1;
|
|
||||||
/* missing disk letter */
|
/* missing disk letter */
|
||||||
if (testDevice("hd1", -1) < 0)
|
DO_TEST("hd1", -1);
|
||||||
ret = -1;
|
|
||||||
/* partition to large */
|
/* partition to large */
|
||||||
if (testDevice("hda64", -1) < 0)
|
DO_TEST("hda64", -1);
|
||||||
ret = -1;
|
|
||||||
/* partition to small */
|
/* partition to small */
|
||||||
if (testDevice("hda0", -1) < 0)
|
DO_TEST("hda0", -1);
|
||||||
ret = -1;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -129,89 +126,55 @@ main(void)
|
|||||||
********************************/
|
********************************/
|
||||||
|
|
||||||
/* first valid disk */
|
/* first valid disk */
|
||||||
if (testDevice("sda", 2048) < 0)
|
DO_TEST("sda", 2048);
|
||||||
ret = -1;
|
DO_TEST("sda1", 2049);
|
||||||
if (testDevice("sda1", 2049) < 0)
|
DO_TEST("sda15", 2063);
|
||||||
ret = -1;
|
|
||||||
if (testDevice("sda15", 2063) < 0)
|
|
||||||
ret = -1;
|
|
||||||
/* last valid disk of first SCSI major number */
|
/* last valid disk of first SCSI major number */
|
||||||
if (testDevice("sdp", 2288) < 0)
|
DO_TEST("sdp", 2288);
|
||||||
ret = -1;
|
DO_TEST("sdp1", 2289);
|
||||||
if (testDevice("sdp1", 2289) < 0)
|
DO_TEST("sdp15", 2303);
|
||||||
ret = -1;
|
|
||||||
if (testDevice("sdp15", 2303) < 0)
|
|
||||||
ret = -1;
|
|
||||||
/* first valid disk of second SCSI major number */
|
/* first valid disk of second SCSI major number */
|
||||||
if (testDevice("sdq", 16640) < 0)
|
DO_TEST("sdq", 16640);
|
||||||
ret = -1;
|
DO_TEST("sdq1", 16641);
|
||||||
if (testDevice("sdq1", 16641) < 0)
|
DO_TEST("sdq15", 16655);
|
||||||
ret = -1;
|
|
||||||
if (testDevice("sdq15", 16655) < 0)
|
|
||||||
ret = -1;
|
|
||||||
/* last valid single letter disk */
|
/* last valid single letter disk */
|
||||||
if (testDevice("sdz", 16784) < 0)
|
DO_TEST("sdz", 16784);
|
||||||
ret = -1;
|
DO_TEST("sdz1", 16785);
|
||||||
if (testDevice("sdz1", 16785) < 0)
|
DO_TEST("sdz15", 16799);
|
||||||
ret = -1;
|
|
||||||
if (testDevice("sdz15", 16799) < 0)
|
|
||||||
ret = -1;
|
|
||||||
/* first valid dual letter disk */
|
/* first valid dual letter disk */
|
||||||
if (testDevice("sdaa", 16800) < 0)
|
DO_TEST("sdaa", 16800);
|
||||||
ret = -1;
|
DO_TEST("sdaa1", 16801);
|
||||||
if (testDevice("sdaa1", 16801) < 0)
|
DO_TEST("sdaa15", 16815);
|
||||||
ret = -1;
|
|
||||||
if (testDevice("sdaa15", 16815) < 0)
|
|
||||||
ret = -1;
|
|
||||||
/* second valid dual letter disk */
|
/* second valid dual letter disk */
|
||||||
if (testDevice("sdab", 16816) < 0)
|
DO_TEST("sdab", 16816);
|
||||||
ret = -1;
|
DO_TEST("sdab1", 16817);
|
||||||
if (testDevice("sdab1", 16817) < 0)
|
DO_TEST("sdab15", 16831);
|
||||||
ret = -1;
|
|
||||||
if (testDevice("sdab15", 16831) < 0)
|
|
||||||
ret = -1;
|
|
||||||
/* first letter of second sequence of dual letter disk */
|
/* first letter of second sequence of dual letter disk */
|
||||||
if (testDevice("sdba", 17216) < 0)
|
DO_TEST("sdba", 17216);
|
||||||
ret = -1;
|
DO_TEST("sdba1", 17217);
|
||||||
if (testDevice("sdba1", 17217) < 0)
|
DO_TEST("sdba15", 17231);
|
||||||
ret = -1;
|
|
||||||
if (testDevice("sdba15", 17231) < 0)
|
|
||||||
ret = -1;
|
|
||||||
/* last valid dual letter disk */
|
/* last valid dual letter disk */
|
||||||
if (testDevice("sdiv", 34800) < 0)
|
DO_TEST("sdiv", 34800);
|
||||||
ret = -1;
|
DO_TEST("sdiv1", 34801);
|
||||||
if (testDevice("sdiv1", 34801) < 0)
|
DO_TEST("sdiv15", 34815);
|
||||||
ret = -1;
|
|
||||||
if (testDevice("sdiv15", 34815) < 0)
|
|
||||||
ret = -1;
|
|
||||||
|
|
||||||
/* Disk letter to large */
|
/* Disk letter to large */
|
||||||
if (testDevice("sdix", -1) < 0)
|
DO_TEST("sdix", -1);
|
||||||
ret = -1;
|
|
||||||
/* missing disk letter */
|
/* missing disk letter */
|
||||||
if (testDevice("sd1", -1) < 0)
|
DO_TEST("sd1", -1);
|
||||||
ret = -1;
|
|
||||||
/* partition to large */
|
/* partition to large */
|
||||||
if (testDevice("sda16", -1) < 0)
|
DO_TEST("sda16", -1);
|
||||||
ret = -1;
|
|
||||||
/* partition to small */
|
/* partition to small */
|
||||||
if (testDevice("sda0", -1) < 0)
|
DO_TEST("sda0", -1);
|
||||||
ret = -1;
|
|
||||||
|
|
||||||
|
|
||||||
/* Path stripping */
|
/* Path stripping */
|
||||||
if (testDevice("/dev", -1) < 0)
|
DO_TEST("/dev", -1);
|
||||||
ret = -1;
|
DO_TEST("/dev/", -1);
|
||||||
if (testDevice("/dev/", -1) < 0)
|
DO_TEST("/dev/xvd", -1);
|
||||||
ret = -1;
|
DO_TEST("/dev/xvda", 51712);
|
||||||
if (testDevice("/dev/xvd", -1) < 0)
|
DO_TEST("/dev/xvda1", 51713);
|
||||||
ret = -1;
|
DO_TEST("/dev/xvda15", 51727);
|
||||||
if (testDevice("/dev/xvda", 51712) < 0)
|
|
||||||
ret = -1;
|
|
||||||
if (testDevice("/dev/xvda1", 51713) < 0)
|
|
||||||
ret = -1;
|
|
||||||
if (testDevice("/dev/xvda15", 51727) < 0)
|
|
||||||
ret = -1;
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
exit(ret==0 ? EXIT_SUCCESS : EXIT_FAILURE);
|
exit(ret==0 ? EXIT_SUCCESS : EXIT_FAILURE);
|
||||||
|
@ -1,21 +1,33 @@
|
|||||||
#!/bin/bash
|
#!/bin/sh
|
||||||
set -x
|
|
||||||
NOK=0
|
if test "$VERBOSE" = yes; then
|
||||||
for f in $abs_top_srcdir/tests/confdata/*.conf
|
set -x
|
||||||
|
virsh --version
|
||||||
|
fi
|
||||||
|
|
||||||
|
. $srcdir/test-lib.sh
|
||||||
|
|
||||||
|
set -e
|
||||||
|
if test "x$abs_srcdir" = x; then
|
||||||
|
abs_srcdir=`pwd`
|
||||||
|
abs_builddir=`pwd`
|
||||||
|
fi
|
||||||
|
|
||||||
|
fail=0
|
||||||
|
i=1
|
||||||
|
data_dir=$abs_srcdir/confdata
|
||||||
|
for f in $(cd "$data_dir" && echo *.conf)
|
||||||
do
|
do
|
||||||
./conftest $f > conftest.$$
|
"$abs_builddir/conftest" "$data_dir/$f" > "$f-actual"
|
||||||
outfile=`echo "$f" | sed s+\.conf$+\.out+`
|
expected="$data_dir"/`echo "$f" | sed s+\.conf$+\.out+`
|
||||||
diff $outfile conftest.$$ > /dev/null
|
if compare "$expected" "$f-actual"; then
|
||||||
if [ $? != 0 ]
|
msg=OK
|
||||||
then
|
|
||||||
if [ -n "$DEBUG_TESTS" ]; then
|
|
||||||
diff -u $outfile conftest.$$
|
|
||||||
fi
|
|
||||||
echo "$f FAILED"
|
|
||||||
NOK=1
|
|
||||||
else
|
else
|
||||||
echo "$f OK"
|
msg=FAILED
|
||||||
|
fail=1
|
||||||
fi
|
fi
|
||||||
|
printf "%2d) %-60s ... %s\n" $i "$f" $msg
|
||||||
|
i=`expr $i + 1`
|
||||||
done
|
done
|
||||||
rm -f conftest.$$
|
|
||||||
exit $NOK
|
(exit $fail); exit $fail
|
||||||
|
@ -50,14 +50,10 @@ static int testCompareFiles(const char *hostmachine,
|
|||||||
if (!(actualxml = xenHypervisorMakeCapabilitiesXML(NULL, hostmachine, fp1, fp2)))
|
if (!(actualxml = xenHypervisorMakeCapabilitiesXML(NULL, hostmachine, fp1, fp2)))
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
if (getenv("DEBUG_TESTS") &&
|
if (STRNEQ(expectxml, actualxml)) {
|
||||||
STRNEQ(expectxml, actualxml)) {
|
virtTestDifference(stderr, expectxml, actualxml);
|
||||||
printf("In test file %s:\n", capabilities);
|
goto fail;
|
||||||
printf("Expect %d '%s'\n", (int)strlen(expectxml), expectxml);
|
|
||||||
printf("Actual %d '%s'\n", (int)strlen(actualxml), actualxml);
|
|
||||||
}
|
}
|
||||||
if (strcmp(expectxml, actualxml))
|
|
||||||
goto fail;
|
|
||||||
|
|
||||||
ret = 0;
|
ret = 0;
|
||||||
|
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
#ifdef WITH_XEN
|
#ifdef WITH_XEN
|
||||||
|
|
||||||
@ -35,11 +36,11 @@
|
|||||||
#include "conf.h"
|
#include "conf.h"
|
||||||
|
|
||||||
static char *progname;
|
static char *progname;
|
||||||
static char *abs_top_srcdir;
|
static char *abs_srcdir;
|
||||||
|
|
||||||
#define MAX_FILE 4096
|
#define MAX_FILE 4096
|
||||||
|
|
||||||
static int testCompareParseXML(const char *xmcfg_rel, const char *xml_rel,
|
static int testCompareParseXML(const char *xmcfg, const char *xml,
|
||||||
int xendConfigVersion) {
|
int xendConfigVersion) {
|
||||||
char xmlData[MAX_FILE];
|
char xmlData[MAX_FILE];
|
||||||
char xmcfgData[MAX_FILE];
|
char xmcfgData[MAX_FILE];
|
||||||
@ -53,11 +54,6 @@ static int testCompareParseXML(const char *xmcfg_rel, const char *xml_rel,
|
|||||||
int wrote = MAX_FILE;
|
int wrote = MAX_FILE;
|
||||||
void *old_priv = NULL;
|
void *old_priv = NULL;
|
||||||
struct _xenUnifiedPrivate priv;
|
struct _xenUnifiedPrivate priv;
|
||||||
char xmcfg[PATH_MAX];
|
|
||||||
char xml[PATH_MAX];
|
|
||||||
|
|
||||||
snprintf(xmcfg, sizeof xmcfg - 1, "%s/tests/%s", abs_top_srcdir, xmcfg_rel);
|
|
||||||
snprintf(xml, sizeof xml - 1, "%s/tests/%s", abs_top_srcdir, xml_rel);
|
|
||||||
|
|
||||||
conn = virConnectOpenReadOnly("test:///default");
|
conn = virConnectOpenReadOnly("test:///default");
|
||||||
if (!conn) goto fail;
|
if (!conn) goto fail;
|
||||||
@ -80,11 +76,8 @@ static int testCompareParseXML(const char *xmcfg_rel, const char *xml_rel,
|
|||||||
goto fail;
|
goto fail;
|
||||||
gotxmcfgPtr[wrote] = '\0';
|
gotxmcfgPtr[wrote] = '\0';
|
||||||
|
|
||||||
if (strcmp(xmcfgData, gotxmcfgData)) {
|
if (STRNEQ(xmcfgData, gotxmcfgData)) {
|
||||||
if (getenv("DEBUG_TESTS")) {
|
virtTestDifference(stderr, xmcfgData, gotxmcfgData);
|
||||||
printf("Expect %d '%s'\n", (int)strlen(xmcfgData), xmcfgData);
|
|
||||||
printf("Actual %d '%s'\n", (int)strlen(gotxmcfgData), gotxmcfgData);
|
|
||||||
}
|
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -102,7 +95,7 @@ static int testCompareParseXML(const char *xmcfg_rel, const char *xml_rel,
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int testCompareFormatXML(const char *xmcfg_rel, const char *xml_rel,
|
static int testCompareFormatXML(const char *xmcfg, const char *xml,
|
||||||
int xendConfigVersion) {
|
int xendConfigVersion) {
|
||||||
char xmlData[MAX_FILE];
|
char xmlData[MAX_FILE];
|
||||||
char xmcfgData[MAX_FILE];
|
char xmcfgData[MAX_FILE];
|
||||||
@ -114,11 +107,6 @@ static int testCompareFormatXML(const char *xmcfg_rel, const char *xml_rel,
|
|||||||
virConnectPtr conn;
|
virConnectPtr conn;
|
||||||
void *old_priv;
|
void *old_priv;
|
||||||
struct _xenUnifiedPrivate priv;
|
struct _xenUnifiedPrivate priv;
|
||||||
char xmcfg[PATH_MAX];
|
|
||||||
char xml[PATH_MAX];
|
|
||||||
|
|
||||||
snprintf(xmcfg, sizeof xmcfg - 1, "%s/tests/%s", abs_top_srcdir, xmcfg_rel);
|
|
||||||
snprintf(xml, sizeof xml - 1, "%s/tests/%s", abs_top_srcdir, xml_rel);
|
|
||||||
|
|
||||||
conn = virConnectOpenReadOnly("test:///default");
|
conn = virConnectOpenReadOnly("test:///default");
|
||||||
if (!conn) goto fail;
|
if (!conn) goto fail;
|
||||||
@ -163,102 +151,25 @@ static int testCompareFormatXML(const char *xmcfg_rel, const char *xml_rel,
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int testCompareParavirtOldPVFBFormat(const void *data ATTRIBUTE_UNUSED) {
|
|
||||||
return testCompareFormatXML("xmconfigdata/test-paravirt-old-pvfb.cfg",
|
|
||||||
"xmconfigdata/test-paravirt-old-pvfb.xml",
|
|
||||||
2);
|
|
||||||
}
|
|
||||||
static int testCompareParavirtOldPVFBParse(const void *data ATTRIBUTE_UNUSED) {
|
|
||||||
return testCompareParseXML("xmconfigdata/test-paravirt-old-pvfb.cfg",
|
|
||||||
"xmconfigdata/test-paravirt-old-pvfb.xml",
|
|
||||||
2);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int testCompareParavirtNewPVFBFormat(const void *data ATTRIBUTE_UNUSED) {
|
struct testInfo {
|
||||||
return testCompareFormatXML("xmconfigdata/test-paravirt-new-pvfb.cfg",
|
const char *name;
|
||||||
"xmconfigdata/test-paravirt-new-pvfb.xml",
|
int version;
|
||||||
3);
|
int mode;
|
||||||
}
|
};
|
||||||
static int testCompareParavirtNewPVFBParse(const void *data ATTRIBUTE_UNUSED) {
|
|
||||||
return testCompareParseXML("xmconfigdata/test-paravirt-new-pvfb.cfg",
|
|
||||||
"xmconfigdata/test-paravirt-new-pvfb.xml",
|
|
||||||
3);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int testCompareFullvirtOldCDROMFormat(const void *data ATTRIBUTE_UNUSED) {
|
static int testCompareHelper(const void *data) {
|
||||||
return testCompareFormatXML("xmconfigdata/test-fullvirt-old-cdrom.cfg",
|
const struct testInfo *info = data;
|
||||||
"xmconfigdata/test-fullvirt-old-cdrom.xml",
|
char xml[PATH_MAX];
|
||||||
1);
|
char cfg[PATH_MAX];
|
||||||
}
|
snprintf(xml, PATH_MAX, "%s/xmconfigdata/test-%s.xml",
|
||||||
static int testCompareFullvirtOldCDROMParse(const void *data ATTRIBUTE_UNUSED) {
|
abs_srcdir, info->name);
|
||||||
return testCompareParseXML("xmconfigdata/test-fullvirt-old-cdrom.cfg",
|
snprintf(cfg, PATH_MAX, "%s/xmconfigdata/test-%s.cfg",
|
||||||
"xmconfigdata/test-fullvirt-old-cdrom.xml",
|
abs_srcdir, info->name);
|
||||||
1);
|
if (info->mode == 0)
|
||||||
}
|
return testCompareParseXML(cfg, xml, info->version);
|
||||||
|
else
|
||||||
static int testCompareFullvirtNewCDROMFormat(const void *data ATTRIBUTE_UNUSED) {
|
return testCompareFormatXML(cfg, xml, info->version);
|
||||||
return testCompareFormatXML("xmconfigdata/test-fullvirt-new-cdrom.cfg",
|
|
||||||
"xmconfigdata/test-fullvirt-new-cdrom.xml",
|
|
||||||
2);
|
|
||||||
}
|
|
||||||
static int testCompareFullvirtNewCDROMParse(const void *data ATTRIBUTE_UNUSED) {
|
|
||||||
return testCompareParseXML("xmconfigdata/test-fullvirt-new-cdrom.cfg",
|
|
||||||
"xmconfigdata/test-fullvirt-new-cdrom.xml",
|
|
||||||
2);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int testCompareFullvirtClockUTCFormat(const void *data ATTRIBUTE_UNUSED) {
|
|
||||||
return testCompareFormatXML("xmconfigdata/test-fullvirt-utc.cfg",
|
|
||||||
"xmconfigdata/test-fullvirt-utc.xml",
|
|
||||||
2);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int testCompareFullvirtClockUTCParse(const void *data ATTRIBUTE_UNUSED) {
|
|
||||||
return testCompareParseXML("xmconfigdata/test-fullvirt-utc.cfg",
|
|
||||||
"xmconfigdata/test-fullvirt-utc.xml",
|
|
||||||
2);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int testCompareFullvirtClockLocaltimeFormat(const void *data ATTRIBUTE_UNUSED) {
|
|
||||||
return testCompareFormatXML("xmconfigdata/test-fullvirt-localtime.cfg",
|
|
||||||
"xmconfigdata/test-fullvirt-localtime.xml",
|
|
||||||
2);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int testCompareFullvirtClockLocaltimeParse(const void *data ATTRIBUTE_UNUSED) {
|
|
||||||
return testCompareParseXML("xmconfigdata/test-fullvirt-localtime.cfg",
|
|
||||||
"xmconfigdata/test-fullvirt-localtime.xml",
|
|
||||||
2);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int testCompareFullvirtInputUSBTabletFormat(const void *data ATTRIBUTE_UNUSED) {
|
|
||||||
return testCompareFormatXML("xmconfigdata/test-fullvirt-usbtablet.cfg",
|
|
||||||
"xmconfigdata/test-fullvirt-usbtablet.xml",
|
|
||||||
2);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int testCompareFullvirtInputUSBTabletParse(const void *data ATTRIBUTE_UNUSED) {
|
|
||||||
return testCompareParseXML("xmconfigdata/test-fullvirt-usbtablet.cfg",
|
|
||||||
"xmconfigdata/test-fullvirt-usbtablet.xml",
|
|
||||||
2);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int testCompareFullvirtInputUSBTabletNoBusParse(const void *data ATTRIBUTE_UNUSED) {
|
|
||||||
return testCompareParseXML("xmconfigdata/test-fullvirt-usbtablet.cfg",
|
|
||||||
"xmconfigdata/test-fullvirt-usbtablet-no-bus.xml",
|
|
||||||
2);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int testCompareFullvirtInputUSBMouseFormat(const void *data ATTRIBUTE_UNUSED) {
|
|
||||||
return testCompareParseXML("xmconfigdata/test-fullvirt-usbmouse.cfg",
|
|
||||||
"xmconfigdata/test-fullvirt-usbmouse.xml",
|
|
||||||
2);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int testCompareFullvirtInputUSBMouseParse(const void *data ATTRIBUTE_UNUSED) {
|
|
||||||
return testCompareParseXML("xmconfigdata/test-fullvirt-usbmouse.cfg",
|
|
||||||
"xmconfigdata/test-fullvirt-usbmouse.xml",
|
|
||||||
2);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -266,6 +177,7 @@ int
|
|||||||
main(int argc, char **argv)
|
main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
char cwd[PATH_MAX];
|
||||||
|
|
||||||
progname = argv[0];
|
progname = argv[0];
|
||||||
|
|
||||||
@ -274,65 +186,31 @@ main(int argc, char **argv)
|
|||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
abs_top_srcdir = getenv("abs_top_srcdir");
|
abs_srcdir = getenv("abs_srcdir");
|
||||||
if (!abs_top_srcdir)
|
if (!abs_srcdir)
|
||||||
return 1;
|
abs_srcdir = getcwd(cwd, sizeof(cwd));
|
||||||
|
|
||||||
/* Config -> XML */
|
|
||||||
if (virtTestRun("Paravirt old PVFB (Format)",
|
|
||||||
1, testCompareParavirtOldPVFBFormat, NULL) != 0)
|
|
||||||
ret = -1;
|
|
||||||
if (virtTestRun("Paravirt new PVFB (Format)",
|
|
||||||
1, testCompareParavirtNewPVFBFormat, NULL) != 0)
|
|
||||||
ret = -1;
|
|
||||||
if (virtTestRun("Fullvirt old PVFB (Format)",
|
|
||||||
1, testCompareFullvirtOldCDROMFormat, NULL) != 0)
|
|
||||||
ret = -1;
|
|
||||||
if (virtTestRun("Fullvirt new PVFB (Format)",
|
|
||||||
1, testCompareFullvirtNewCDROMFormat, NULL) != 0)
|
|
||||||
ret = -1;
|
|
||||||
if (virtTestRun("Fullvirt clock Localtime (Format)",
|
|
||||||
1, testCompareFullvirtClockLocaltimeFormat, NULL) != 0)
|
|
||||||
ret = -1;
|
|
||||||
if (virtTestRun("Fullvirt clock UTC (Format)",
|
|
||||||
1, testCompareFullvirtClockUTCFormat, NULL) != 0)
|
|
||||||
ret = -1;
|
|
||||||
if (virtTestRun("Fullvirt USB mouse (Format)",
|
|
||||||
1, testCompareFullvirtInputUSBMouseFormat, NULL) != 0)
|
|
||||||
ret = -1;
|
|
||||||
if (virtTestRun("Fullvirt USB tablet (Format)",
|
|
||||||
1, testCompareFullvirtInputUSBTabletFormat, NULL) != 0)
|
|
||||||
ret = -1;
|
|
||||||
|
|
||||||
/* XML -> Config */
|
#define DO_TEST(name, version) \
|
||||||
if (virtTestRun("Paravirt old PVFB (Parse)",
|
do { \
|
||||||
1, testCompareParavirtOldPVFBParse, NULL) != 0)
|
struct testInfo info0 = { name, version, 0 }; \
|
||||||
ret = -1;
|
struct testInfo info1 = { name, version, 1 }; \
|
||||||
if (virtTestRun("Paravirt new PVFB (Parse)",
|
if (virtTestRun("Xen XM-2-XML Parse " name, \
|
||||||
1, testCompareParavirtNewPVFBParse, NULL) != 0)
|
1, testCompareHelper, &info0) < 0) \
|
||||||
ret = -1;
|
ret = -1; \
|
||||||
if (virtTestRun("Fullvirt old PVFB (Parse)",
|
if (virtTestRun("Xen XM-2-XML Format " name, \
|
||||||
1, testCompareFullvirtOldCDROMParse, NULL) != 0)
|
1, testCompareHelper, &info1) < 0) \
|
||||||
ret = -1;
|
ret = -1; \
|
||||||
if (virtTestRun("Fullvirt new PVFB (Parse)",
|
} while (0)
|
||||||
1, testCompareFullvirtNewCDROMParse, NULL) != 0)
|
|
||||||
ret = -1;
|
|
||||||
if (virtTestRun("Fullvirt clock Localtime (Parse)",
|
|
||||||
1, testCompareFullvirtClockLocaltimeParse, NULL) != 0)
|
|
||||||
ret = -1;
|
|
||||||
if (virtTestRun("Fullvirt clock UTC (Parse)",
|
|
||||||
1, testCompareFullvirtClockUTCParse, NULL) != 0)
|
|
||||||
ret = -1;
|
|
||||||
if (virtTestRun("Fullvirt USB mouse (Parse)",
|
|
||||||
1, testCompareFullvirtInputUSBMouseParse, NULL) != 0)
|
|
||||||
ret = -1;
|
|
||||||
if (virtTestRun("Fullvirt USB tablet (Parse)",
|
|
||||||
1, testCompareFullvirtInputUSBTabletParse, NULL) != 0)
|
|
||||||
ret = -1;
|
|
||||||
if (virtTestRun("Fullvirt USB tablet no bus (Parse)",
|
|
||||||
1, testCompareFullvirtInputUSBTabletNoBusParse, NULL) != 0)
|
|
||||||
ret = -1;
|
|
||||||
|
|
||||||
|
DO_TEST("paravirt-old-pvfb", 2);
|
||||||
|
DO_TEST("paravirt-new-pvfb", 3);
|
||||||
|
DO_TEST("fullvirt-old-cdrom", 1);
|
||||||
|
DO_TEST("fullvirt-new-cdrom", 2);
|
||||||
|
DO_TEST("fullvirt-utc", 2);
|
||||||
|
DO_TEST("fullvirt-localtime", 2);
|
||||||
|
DO_TEST("fullvirt-usbtablet", 2);
|
||||||
|
DO_TEST("fullvirt-usbmouse", 2);
|
||||||
|
|
||||||
exit(ret==0 ? EXIT_SUCCESS : EXIT_FAILURE);
|
exit(ret==0 ? EXIT_SUCCESS : EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user