mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-08 04:31:33 +00:00
Move the expected output data from virshdata/*.txt into virshtest.c.
* tests/virshtest.c: Embed literal, expected output here, rather than using virshdata/*.txt file names. Factor out some common constructs. (testCompareOutputLit): New function. (testCompareOutput): #ifdef-out, not that it's unused. * tests/Makefile.am (SUBDIRS): Remove virshdata/ and all files in it. * docs/testnode.xml: Fix typo in a comment. * configure.in (AC_OUTPUT): Remove tests/virshdata/Makefile.
This commit is contained in:
parent
4733f0a781
commit
5b5393f27a
12
ChangeLog
12
ChangeLog
@ -1,3 +1,15 @@
|
|||||||
|
Mon Nov 24 08:10:49 +0100 2008 Jim Meyering <meyering@redhat.com>
|
||||||
|
|
||||||
|
Move the expected output data from virshdata/*.txt into virshtest.c.
|
||||||
|
* tests/virshtest.c: Embed literal, expected output here, rather than
|
||||||
|
using virshdata/*.txt file names.
|
||||||
|
Factor out some common constructs.
|
||||||
|
(testCompareOutputLit): New function.
|
||||||
|
(testCompareOutput): #ifdef-out, not that it's unused.
|
||||||
|
* tests/Makefile.am (SUBDIRS): Remove virshdata/ and all files in it.
|
||||||
|
* docs/testnode.xml: Fix typo in a comment.
|
||||||
|
* configure.in (AC_OUTPUT): Remove tests/virshdata/Makefile.
|
||||||
|
|
||||||
Fri Nov 21 23:51:19 +0100 2008 Jim Meyering <meyering@redhat.com>
|
Fri Nov 21 23:51:19 +0100 2008 Jim Meyering <meyering@redhat.com>
|
||||||
|
|
||||||
* gnulib/tests/test-EOVERFLOW: Remove.
|
* gnulib/tests/test-EOVERFLOW: Remove.
|
||||||
|
@ -1227,7 +1227,7 @@ AC_OUTPUT(Makefile src/Makefile include/Makefile docs/Makefile \
|
|||||||
tests/sexpr2xmldata/Makefile \
|
tests/sexpr2xmldata/Makefile \
|
||||||
tests/xmconfigdata/Makefile \
|
tests/xmconfigdata/Makefile \
|
||||||
tests/xencapsdata/Makefile \
|
tests/xencapsdata/Makefile \
|
||||||
tests/virshdata/Makefile tests/confdata/Makefile \
|
tests/confdata/Makefile \
|
||||||
examples/domain-events/events-c/Makefile)
|
examples/domain-events/events-c/Makefile)
|
||||||
|
|
||||||
AC_MSG_NOTICE([])
|
AC_MSG_NOTICE([])
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<node>
|
<node>
|
||||||
<!-- This file gives an example config for the mock 'test' backend
|
<!-- This file gives an example config for the mock 'test' backend
|
||||||
driver to libvirt. This is intended to allow relible unit testing
|
driver to libvirt. This is intended to allow reliable unit testing
|
||||||
of applications using libvirt. To use this with virsh, run something
|
of applications using libvirt. To use this with virsh, run something
|
||||||
like:
|
like:
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
SHELL = $(PREFERABLY_POSIX_SHELL)
|
SHELL = $(PREFERABLY_POSIX_SHELL)
|
||||||
|
|
||||||
SUBDIRS = virshdata confdata sexpr2xmldata \
|
SUBDIRS = confdata sexpr2xmldata \
|
||||||
xml2sexprdata xmconfigdata xencapsdata
|
xml2sexprdata xmconfigdata xencapsdata
|
||||||
|
|
||||||
INCLUDES = \
|
INCLUDES = \
|
||||||
|
@ -1,2 +0,0 @@
|
|||||||
Makefile
|
|
||||||
Makefile.in
|
|
2
tests/virshdata/.gitignore
vendored
2
tests/virshdata/.gitignore
vendored
@ -1,2 +0,0 @@
|
|||||||
Makefile
|
|
||||||
Makefile.in
|
|
@ -1,2 +0,0 @@
|
|||||||
|
|
||||||
EXTRA_DIST = $(wildcard *.txt)
|
|
@ -1,2 +0,0 @@
|
|||||||
2
|
|
||||||
|
|
@ -1,10 +0,0 @@
|
|||||||
Id: 2
|
|
||||||
Name: fc4
|
|
||||||
UUID: ef861801-45b9-11cb-88e3-afbfe5370493
|
|
||||||
OS Type: linux
|
|
||||||
State: running
|
|
||||||
CPU(s): 1
|
|
||||||
Max memory: 261072 kB
|
|
||||||
Used memory: 131072 kB
|
|
||||||
Autostart: disable
|
|
||||||
|
|
@ -1,2 +0,0 @@
|
|||||||
fc4
|
|
||||||
|
|
@ -1,2 +0,0 @@
|
|||||||
running
|
|
||||||
|
|
@ -1,2 +0,0 @@
|
|||||||
ef861801-45b9-11cb-88e3-afbfe5370493
|
|
||||||
|
|
@ -1,5 +0,0 @@
|
|||||||
Id Name State
|
|
||||||
----------------------------------
|
|
||||||
1 fv0 running
|
|
||||||
2 fc4 running
|
|
||||||
|
|
@ -1,4 +0,0 @@
|
|||||||
Id Name State
|
|
||||||
----------------------------------
|
|
||||||
1 test running
|
|
||||||
|
|
@ -1,9 +0,0 @@
|
|||||||
CPU model: i986
|
|
||||||
CPU(s): 50
|
|
||||||
CPU frequency: 6000 MHz
|
|
||||||
CPU socket(s): 4
|
|
||||||
Core(s) per socket: 4
|
|
||||||
Thread(s) per core: 2
|
|
||||||
NUMA cell(s): 4
|
|
||||||
Memory size: 8192000 kB
|
|
||||||
|
|
@ -1,9 +0,0 @@
|
|||||||
CPU model: i686
|
|
||||||
CPU(s): 16
|
|
||||||
CPU frequency: 1400 MHz
|
|
||||||
CPU socket(s): 2
|
|
||||||
Core(s) per socket: 2
|
|
||||||
Thread(s) per core: 2
|
|
||||||
NUMA cell(s): 2
|
|
||||||
Memory size: 3145728 kB
|
|
||||||
|
|
@ -12,6 +12,24 @@ static char *progname;
|
|||||||
static char *abs_srcdir;
|
static char *abs_srcdir;
|
||||||
#define MAX_FILE 4096
|
#define MAX_FILE 4096
|
||||||
|
|
||||||
|
#define DOM_UUID "ef861801-45b9-11cb-88e3-afbfe5370493"
|
||||||
|
|
||||||
|
static const char *dominfo_fc4 = "\
|
||||||
|
Id: 2\n\
|
||||||
|
Name: fc4\n\
|
||||||
|
UUID: " DOM_UUID "\n\
|
||||||
|
OS Type: linux\n\
|
||||||
|
State: running\n\
|
||||||
|
CPU(s): 1\n\
|
||||||
|
Max memory: 261072 kB\n\
|
||||||
|
Used memory: 131072 kB\n\
|
||||||
|
Autostart: disable\n\
|
||||||
|
\n";
|
||||||
|
static const char *domuuid_fc4 = DOM_UUID "\n\n";
|
||||||
|
static const char *domid_fc4 = "2\n\n";
|
||||||
|
static const char *domname_fc4 = "fc4\n\n";
|
||||||
|
static const char *domstate_fc4 = "running\n\n";
|
||||||
|
|
||||||
static int testFilterLine(char *buffer,
|
static int testFilterLine(char *buffer,
|
||||||
const char *toRemove) {
|
const char *toRemove) {
|
||||||
char *start;
|
char *start;
|
||||||
@ -28,18 +46,10 @@ static int testFilterLine(char *buffer,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int testCompareOutput(const char *expect_rel, const char *filter,
|
static int testCompareOutputLit(const char *expectData,
|
||||||
const char *const argv[]) {
|
const char *filter, const char *const argv[]) {
|
||||||
char expectData[MAX_FILE];
|
|
||||||
char actualData[MAX_FILE];
|
char actualData[MAX_FILE];
|
||||||
char *expectPtr = &(expectData[0]);
|
|
||||||
char *actualPtr = &(actualData[0]);
|
char *actualPtr = &(actualData[0]);
|
||||||
char expect[PATH_MAX];
|
|
||||||
|
|
||||||
snprintf(expect, sizeof expect - 1, "%s/%s", abs_srcdir, expect_rel);
|
|
||||||
|
|
||||||
if (virtTestLoadFile(expect, &expectPtr, MAX_FILE) < 0)
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
if (virtTestCaptureProgramOutput(argv, &actualPtr, MAX_FILE) < 0)
|
if (virtTestCaptureProgramOutput(argv, &actualPtr, MAX_FILE) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
@ -56,6 +66,21 @@ static int testCompareOutput(const char *expect_rel, const char *filter,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if unused
|
||||||
|
static int testCompareOutput(const char *expect_rel, const char *filter,
|
||||||
|
const char *const argv[]) {
|
||||||
|
char expectData[MAX_FILE];
|
||||||
|
char *expectPtr = &(expectData[0]);
|
||||||
|
char expect[PATH_MAX];
|
||||||
|
|
||||||
|
snprintf(expect, sizeof expect - 1, "%s/%s", abs_srcdir, expect_rel);
|
||||||
|
|
||||||
|
if (virtTestLoadFile(expect, &expectPtr, MAX_FILE) < 0)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
return testCompareOutputLit(expectData, filter, argv);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#define VIRSH_DEFAULT "../src/virsh", \
|
#define VIRSH_DEFAULT "../src/virsh", \
|
||||||
"--connect", \
|
"--connect", \
|
||||||
@ -67,40 +92,40 @@ static char *custom_uri;
|
|||||||
"--connect", \
|
"--connect", \
|
||||||
custom_uri
|
custom_uri
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static int testCompareListDefault(const void *data ATTRIBUTE_UNUSED) {
|
static int testCompareListDefault(const void *data ATTRIBUTE_UNUSED) {
|
||||||
const char *const argv[] = {
|
const char *const argv[] = { VIRSH_DEFAULT, "list", NULL };
|
||||||
VIRSH_DEFAULT,
|
const char *exp = "\
|
||||||
"list",
|
Id Name State\n\
|
||||||
NULL
|
----------------------------------\n\
|
||||||
};
|
1 test running\n\
|
||||||
return testCompareOutput("virshdata/list-default.txt",
|
\n";
|
||||||
NULL,
|
return testCompareOutputLit(exp, NULL, argv);
|
||||||
argv);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int testCompareListCustom(const void *data ATTRIBUTE_UNUSED) {
|
static int testCompareListCustom(const void *data ATTRIBUTE_UNUSED) {
|
||||||
const char *const argv[] = {
|
const char *const argv[] = { VIRSH_CUSTOM, "list", NULL };
|
||||||
VIRSH_CUSTOM,
|
const char *exp = "\
|
||||||
"list",
|
Id Name State\n\
|
||||||
NULL
|
----------------------------------\n\
|
||||||
};
|
1 fv0 running\n\
|
||||||
return testCompareOutput("virshdata/list-custom.txt",
|
2 fc4 running\n\
|
||||||
NULL,
|
\n";
|
||||||
argv);
|
return testCompareOutputLit(exp, NULL, argv);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int testCompareNodeinfoDefault(const void *data ATTRIBUTE_UNUSED) {
|
static int testCompareNodeinfoDefault(const void *data ATTRIBUTE_UNUSED) {
|
||||||
const char *const argv[] = {
|
const char *const argv[] = { VIRSH_DEFAULT, "nodeinfo", NULL };
|
||||||
VIRSH_DEFAULT,
|
const char *exp = "\
|
||||||
"nodeinfo",
|
CPU model: i686\n\
|
||||||
NULL
|
CPU(s): 16\n\
|
||||||
};
|
CPU frequency: 1400 MHz\n\
|
||||||
return testCompareOutput("virshdata/nodeinfo-default.txt",
|
CPU socket(s): 2\n\
|
||||||
NULL,
|
Core(s) per socket: 2\n\
|
||||||
argv);
|
Thread(s) per core: 2\n\
|
||||||
|
NUMA cell(s): 2\n\
|
||||||
|
Memory size: 3145728 kB\n\
|
||||||
|
\n";
|
||||||
|
return testCompareOutputLit(exp, NULL, argv);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int testCompareNodeinfoCustom(const void *data ATTRIBUTE_UNUSED) {
|
static int testCompareNodeinfoCustom(const void *data ATTRIBUTE_UNUSED) {
|
||||||
@ -109,160 +134,89 @@ static int testCompareNodeinfoCustom(const void *data ATTRIBUTE_UNUSED) {
|
|||||||
"nodeinfo",
|
"nodeinfo",
|
||||||
NULL
|
NULL
|
||||||
};
|
};
|
||||||
return testCompareOutput("virshdata/nodeinfo-custom.txt",
|
const char *exp = "\
|
||||||
NULL,
|
CPU model: i986\n\
|
||||||
argv);
|
CPU(s): 50\n\
|
||||||
|
CPU frequency: 6000 MHz\n\
|
||||||
|
CPU socket(s): 4\n\
|
||||||
|
Core(s) per socket: 4\n\
|
||||||
|
Thread(s) per core: 2\n\
|
||||||
|
NUMA cell(s): 4\n\
|
||||||
|
Memory size: 8192000 kB\n\
|
||||||
|
\n";
|
||||||
|
return testCompareOutputLit(exp, NULL, argv);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int testCompareDominfoByID(const void *data ATTRIBUTE_UNUSED) {
|
static int testCompareDominfoByID(const void *data ATTRIBUTE_UNUSED) {
|
||||||
const char *const argv[] = {
|
const char *const argv[] = { VIRSH_CUSTOM, "dominfo", "2", NULL };
|
||||||
VIRSH_CUSTOM,
|
const char *exp = dominfo_fc4;
|
||||||
"dominfo",
|
return testCompareOutputLit(exp, "\nCPU time:", argv);
|
||||||
"2",
|
|
||||||
NULL
|
|
||||||
};
|
|
||||||
return testCompareOutput("virshdata/dominfo-fc4.txt",
|
|
||||||
"\nCPU time:",
|
|
||||||
argv);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int testCompareDominfoByUUID(const void *data ATTRIBUTE_UNUSED) {
|
static int testCompareDominfoByUUID(const void *data ATTRIBUTE_UNUSED) {
|
||||||
const char *const argv[] = {
|
const char *const argv[] = { VIRSH_CUSTOM, "dominfo", DOM_UUID, NULL };
|
||||||
VIRSH_CUSTOM,
|
const char *exp = dominfo_fc4;
|
||||||
"dominfo",
|
return testCompareOutputLit(exp, "\nCPU time:", argv);
|
||||||
"ef861801-45b9-11cb-88e3-afbfe5370493",
|
|
||||||
NULL
|
|
||||||
};
|
|
||||||
return testCompareOutput("virshdata/dominfo-fc4.txt",
|
|
||||||
"\nCPU time:",
|
|
||||||
argv);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int testCompareDominfoByName(const void *data ATTRIBUTE_UNUSED) {
|
static int testCompareDominfoByName(const void *data ATTRIBUTE_UNUSED) {
|
||||||
const char *const argv[] = {
|
const char *const argv[] = { VIRSH_CUSTOM, "dominfo", "fc4", NULL };
|
||||||
VIRSH_CUSTOM,
|
const char *exp = dominfo_fc4;
|
||||||
"dominfo",
|
return testCompareOutputLit(exp, "\nCPU time:", argv);
|
||||||
"fc4",
|
|
||||||
NULL
|
|
||||||
};
|
|
||||||
return testCompareOutput("virshdata/dominfo-fc4.txt",
|
|
||||||
"\nCPU time:",
|
|
||||||
argv);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int testCompareDomuuidByID(const void *data ATTRIBUTE_UNUSED) {
|
static int testCompareDomuuidByID(const void *data ATTRIBUTE_UNUSED) {
|
||||||
const char *const argv[] = {
|
const char *const argv[] = { VIRSH_CUSTOM, "domuuid", "2", NULL };
|
||||||
VIRSH_CUSTOM,
|
const char *exp = domuuid_fc4;
|
||||||
"domuuid",
|
return testCompareOutputLit(exp, NULL, argv);
|
||||||
"2",
|
|
||||||
NULL
|
|
||||||
};
|
|
||||||
return testCompareOutput("virshdata/domuuid-fc4.txt",
|
|
||||||
NULL,
|
|
||||||
argv);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int testCompareDomuuidByName(const void *data ATTRIBUTE_UNUSED) {
|
static int testCompareDomuuidByName(const void *data ATTRIBUTE_UNUSED) {
|
||||||
const char *const argv[] = {
|
const char *const argv[] = { VIRSH_CUSTOM, "domuuid", "fc4", NULL };
|
||||||
VIRSH_CUSTOM,
|
const char *exp = domuuid_fc4;
|
||||||
"domuuid",
|
return testCompareOutputLit(exp, NULL, argv);
|
||||||
"fc4",
|
|
||||||
NULL
|
|
||||||
};
|
|
||||||
return testCompareOutput("virshdata/domuuid-fc4.txt",
|
|
||||||
NULL,
|
|
||||||
argv);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int testCompareDomidByName(const void *data ATTRIBUTE_UNUSED) {
|
static int testCompareDomidByName(const void *data ATTRIBUTE_UNUSED) {
|
||||||
const char *const argv[] = {
|
const char *const argv[] = { VIRSH_CUSTOM, "domid", "fc4", NULL };
|
||||||
VIRSH_CUSTOM,
|
const char *exp = domid_fc4;
|
||||||
"domid",
|
return testCompareOutputLit(exp, NULL, argv);
|
||||||
"fc4",
|
|
||||||
NULL
|
|
||||||
};
|
|
||||||
return testCompareOutput("virshdata/domid-fc4.txt",
|
|
||||||
NULL,
|
|
||||||
argv);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int testCompareDomidByUUID(const void *data ATTRIBUTE_UNUSED) {
|
static int testCompareDomidByUUID(const void *data ATTRIBUTE_UNUSED) {
|
||||||
const char *const argv[] = {
|
const char *const argv[] = { VIRSH_CUSTOM, "domid", DOM_UUID, NULL };
|
||||||
VIRSH_CUSTOM,
|
const char *exp = domid_fc4;
|
||||||
"domid",
|
return testCompareOutputLit(exp, NULL, argv);
|
||||||
"ef861801-45b9-11cb-88e3-afbfe5370493",
|
|
||||||
NULL
|
|
||||||
};
|
|
||||||
return testCompareOutput("virshdata/domid-fc4.txt",
|
|
||||||
NULL,
|
|
||||||
argv);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int testCompareDomnameByID(const void *data ATTRIBUTE_UNUSED) {
|
static int testCompareDomnameByID(const void *data ATTRIBUTE_UNUSED) {
|
||||||
const char *const argv[] = {
|
const char *const argv[] = { VIRSH_CUSTOM, "domname", "2", NULL };
|
||||||
VIRSH_CUSTOM,
|
const char *exp = domname_fc4;
|
||||||
"domname",
|
return testCompareOutputLit(exp, NULL, argv);
|
||||||
"2",
|
|
||||||
NULL
|
|
||||||
};
|
|
||||||
return testCompareOutput("virshdata/domname-fc4.txt",
|
|
||||||
NULL,
|
|
||||||
argv);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int testCompareDomnameByUUID(const void *data ATTRIBUTE_UNUSED) {
|
static int testCompareDomnameByUUID(const void *data ATTRIBUTE_UNUSED) {
|
||||||
const char *const argv[] = {
|
const char *const argv[] = { VIRSH_CUSTOM, "domname", DOM_UUID, NULL };
|
||||||
VIRSH_CUSTOM,
|
const char *exp = domname_fc4;
|
||||||
"domname",
|
return testCompareOutputLit(exp, NULL, argv);
|
||||||
"ef861801-45b9-11cb-88e3-afbfe5370493",
|
|
||||||
NULL
|
|
||||||
};
|
|
||||||
return testCompareOutput("virshdata/domname-fc4.txt",
|
|
||||||
NULL,
|
|
||||||
argv);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int testCompareDomstateByID(const void *data ATTRIBUTE_UNUSED) {
|
static int testCompareDomstateByID(const void *data ATTRIBUTE_UNUSED) {
|
||||||
const char *const argv[] = {
|
const char *const argv[] = { VIRSH_CUSTOM, "domstate", "2", NULL };
|
||||||
VIRSH_CUSTOM,
|
const char *exp = domstate_fc4;
|
||||||
"domstate",
|
return testCompareOutputLit(exp, NULL, argv);
|
||||||
"2",
|
|
||||||
NULL
|
|
||||||
};
|
|
||||||
return testCompareOutput("virshdata/domstate-fc4.txt",
|
|
||||||
NULL,
|
|
||||||
argv);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int testCompareDomstateByUUID(const void *data ATTRIBUTE_UNUSED) {
|
static int testCompareDomstateByUUID(const void *data ATTRIBUTE_UNUSED) {
|
||||||
const char *const argv[] = {
|
const char *const argv[] = { VIRSH_CUSTOM, "domstate", DOM_UUID, NULL };
|
||||||
VIRSH_CUSTOM,
|
const char *exp = domstate_fc4;
|
||||||
"domstate",
|
return testCompareOutputLit(exp, NULL, argv);
|
||||||
"ef861801-45b9-11cb-88e3-afbfe5370493",
|
|
||||||
NULL
|
|
||||||
};
|
|
||||||
return testCompareOutput("virshdata/domstate-fc4.txt",
|
|
||||||
NULL,
|
|
||||||
argv);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int testCompareDomstateByName(const void *data ATTRIBUTE_UNUSED) {
|
static int testCompareDomstateByName(const void *data ATTRIBUTE_UNUSED) {
|
||||||
const char *const argv[] = {
|
const char *const argv[] = { VIRSH_CUSTOM, "domstate", "fc4", NULL };
|
||||||
VIRSH_CUSTOM,
|
const char *exp = domstate_fc4;
|
||||||
"domstate",
|
return testCompareOutputLit(exp, NULL, argv);
|
||||||
"fc4",
|
|
||||||
NULL
|
|
||||||
};
|
|
||||||
return testCompareOutput("virshdata/domstate-fc4.txt",
|
|
||||||
NULL,
|
|
||||||
argv);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
Loading…
x
Reference in New Issue
Block a user