[libvirt] [PATCH] Move the expected output data from virshdata/*.txt into virshtest.c.
by Jim Meyering
This is mainly just reorganization and factorization, with an eye
towards making it easier to add more tests in virshtest.c later.
>From 21352a07b073d52bcd3c442c76d7fb985aeef845 Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering(a)redhat.com>
Date: Thu, 20 Nov 2008 20:35:57 +0100
Subject: [PATCH] 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.
---
docs/testnode.xml | 2 +-
tests/Makefile.am | 2 +-
tests/virshdata/.cvsignore | 2 -
tests/virshdata/.gitignore | 2 -
tests/virshdata/Makefile.am | 2 -
tests/virshdata/domid-fc4.txt | 2 -
tests/virshdata/dominfo-fc4.txt | 10 --
tests/virshdata/domname-fc4.txt | 2 -
tests/virshdata/domstate-fc4.txt | 2 -
tests/virshdata/domuuid-fc4.txt | 2 -
tests/virshdata/list-custom.txt | 5 -
tests/virshdata/list-default.txt | 4 -
tests/virshdata/nodeinfo-custom.txt | 9 --
tests/virshdata/nodeinfo-default.txt | 9 --
tests/virshtest.c | 264 ++++++++++++++--------------------
15 files changed, 111 insertions(+), 208 deletions(-)
delete mode 100644 tests/virshdata/.cvsignore
delete mode 100644 tests/virshdata/.gitignore
delete mode 100644 tests/virshdata/Makefile.am
delete mode 100644 tests/virshdata/domid-fc4.txt
delete mode 100644 tests/virshdata/dominfo-fc4.txt
delete mode 100644 tests/virshdata/domname-fc4.txt
delete mode 100644 tests/virshdata/domstate-fc4.txt
delete mode 100644 tests/virshdata/domuuid-fc4.txt
delete mode 100644 tests/virshdata/list-custom.txt
delete mode 100644 tests/virshdata/list-default.txt
delete mode 100644 tests/virshdata/nodeinfo-custom.txt
delete mode 100644 tests/virshdata/nodeinfo-default.txt
diff --git a/docs/testnode.xml b/docs/testnode.xml
index 7df10b0..be7121d 100644
--- a/docs/testnode.xml
+++ b/docs/testnode.xml
@@ -1,6 +1,6 @@
<node>
<!-- 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
like:
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 3b4f0dc..bdbf927 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -2,7 +2,7 @@
SHELL = $(PREFERABLY_POSIX_SHELL)
-SUBDIRS = virshdata confdata sexpr2xmldata \
+SUBDIRS = confdata sexpr2xmldata \
xml2sexprdata xmconfigdata xencapsdata
INCLUDES = \
diff --git a/tests/virshdata/.cvsignore b/tests/virshdata/.cvsignore
deleted file mode 100644
index 282522d..0000000
--- a/tests/virshdata/.cvsignore
+++ /dev/null
@@ -1,2 +0,0 @@
-Makefile
-Makefile.in
diff --git a/tests/virshdata/.gitignore b/tests/virshdata/.gitignore
deleted file mode 100644
index 282522d..0000000
--- a/tests/virshdata/.gitignore
+++ /dev/null
@@ -1,2 +0,0 @@
-Makefile
-Makefile.in
diff --git a/tests/virshdata/Makefile.am b/tests/virshdata/Makefile.am
deleted file mode 100644
index c46fc93..0000000
--- a/tests/virshdata/Makefile.am
+++ /dev/null
@@ -1,2 +0,0 @@
-
-EXTRA_DIST = $(wildcard *.txt)
diff --git a/tests/virshdata/domid-fc4.txt b/tests/virshdata/domid-fc4.txt
deleted file mode 100644
index 9a7456b..0000000
--- a/tests/virshdata/domid-fc4.txt
+++ /dev/null
@@ -1,2 +0,0 @@
-2
-
diff --git a/tests/virshdata/dominfo-fc4.txt b/tests/virshdata/dominfo-fc4.txt
deleted file mode 100644
index 0cce9be..0000000
--- a/tests/virshdata/dominfo-fc4.txt
+++ /dev/null
@@ -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
-
diff --git a/tests/virshdata/domname-fc4.txt b/tests/virshdata/domname-fc4.txt
deleted file mode 100644
index fd55058..0000000
--- a/tests/virshdata/domname-fc4.txt
+++ /dev/null
@@ -1,2 +0,0 @@
-fc4
-
diff --git a/tests/virshdata/domstate-fc4.txt b/tests/virshdata/domstate-fc4.txt
deleted file mode 100644
index 9c724a4..0000000
--- a/tests/virshdata/domstate-fc4.txt
+++ /dev/null
@@ -1,2 +0,0 @@
-running
-
diff --git a/tests/virshdata/domuuid-fc4.txt b/tests/virshdata/domuuid-fc4.txt
deleted file mode 100644
index face70e..0000000
--- a/tests/virshdata/domuuid-fc4.txt
+++ /dev/null
@@ -1,2 +0,0 @@
-ef861801-45b9-11cb-88e3-afbfe5370493
-
diff --git a/tests/virshdata/list-custom.txt b/tests/virshdata/list-custom.txt
deleted file mode 100644
index 2b48b26..0000000
--- a/tests/virshdata/list-custom.txt
+++ /dev/null
@@ -1,5 +0,0 @@
- Id Name State
-----------------------------------
- 1 fv0 running
- 2 fc4 running
-
diff --git a/tests/virshdata/list-default.txt b/tests/virshdata/list-default.txt
deleted file mode 100644
index d05095c..0000000
--- a/tests/virshdata/list-default.txt
+++ /dev/null
@@ -1,4 +0,0 @@
- Id Name State
-----------------------------------
- 1 test running
-
diff --git a/tests/virshdata/nodeinfo-custom.txt b/tests/virshdata/nodeinfo-custom.txt
deleted file mode 100644
index 1e98d63..0000000
--- a/tests/virshdata/nodeinfo-custom.txt
+++ /dev/null
@@ -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
-
diff --git a/tests/virshdata/nodeinfo-default.txt b/tests/virshdata/nodeinfo-default.txt
deleted file mode 100644
index 99d9754..0000000
--- a/tests/virshdata/nodeinfo-default.txt
+++ /dev/null
@@ -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
-
diff --git a/tests/virshtest.c b/tests/virshtest.c
index c9ba6b2..2745df1 100644
--- a/tests/virshtest.c
+++ b/tests/virshtest.c
@@ -12,6 +12,24 @@ static char *progname;
static char *abs_srcdir;
#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,
const char *toRemove) {
char *start;
@@ -28,18 +46,10 @@ static int testFilterLine(char *buffer,
return 0;
}
-static int testCompareOutput(const char *expect_rel, const char *filter,
- const char *const argv[]) {
- char expectData[MAX_FILE];
+static int testCompareOutputLit(const char *expectData,
+ const char *filter, const char *const argv[]) {
char actualData[MAX_FILE];
- char *expectPtr = &(expectData[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)
return -1;
@@ -56,6 +66,21 @@ static int testCompareOutput(const char *expect_rel, const char *filter,
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", \
"--connect", \
@@ -67,40 +92,40 @@ static char *custom_uri;
"--connect", \
custom_uri
-
-
static int testCompareListDefault(const void *data ATTRIBUTE_UNUSED) {
- const char *const argv[] = {
- VIRSH_DEFAULT,
- "list",
- NULL
- };
- return testCompareOutput("virshdata/list-default.txt",
- NULL,
- argv);
+ const char *const argv[] = { VIRSH_DEFAULT, "list", NULL };
+ const char *exp = "\
+ Id Name State\n\
+----------------------------------\n\
+ 1 test running\n\
+\n";
+ return testCompareOutputLit(exp, NULL, argv);
}
static int testCompareListCustom(const void *data ATTRIBUTE_UNUSED) {
- const char *const argv[] = {
- VIRSH_CUSTOM,
- "list",
- NULL
- };
- return testCompareOutput("virshdata/list-custom.txt",
- NULL,
- argv);
+ const char *const argv[] = { VIRSH_CUSTOM, "list", NULL };
+ const char *exp = "\
+ Id Name State\n\
+----------------------------------\n\
+ 1 fv0 running\n\
+ 2 fc4 running\n\
+\n";
+ return testCompareOutputLit(exp, NULL, argv);
}
-
static int testCompareNodeinfoDefault(const void *data ATTRIBUTE_UNUSED) {
- const char *const argv[] = {
- VIRSH_DEFAULT,
- "nodeinfo",
- NULL
- };
- return testCompareOutput("virshdata/nodeinfo-default.txt",
- NULL,
- argv);
+ const char *const argv[] = { VIRSH_DEFAULT, "nodeinfo", NULL };
+ const char *exp = "\
+CPU model: i686\n\
+CPU(s): 16\n\
+CPU frequency: 1400 MHz\n\
+CPU socket(s): 2\n\
+Core(s) per socket: 2\n\
+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) {
@@ -109,160 +134,89 @@ static int testCompareNodeinfoCustom(const void *data ATTRIBUTE_UNUSED) {
"nodeinfo",
NULL
};
- return testCompareOutput("virshdata/nodeinfo-custom.txt",
- NULL,
- argv);
+ const char *exp = "\
+CPU model: i986\n\
+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) {
- const char *const argv[] = {
- VIRSH_CUSTOM,
- "dominfo",
- "2",
- NULL
- };
- return testCompareOutput("virshdata/dominfo-fc4.txt",
- "\nCPU time:",
- argv);
+ const char *const argv[] = { VIRSH_CUSTOM, "dominfo", "2", NULL };
+ const char *exp = dominfo_fc4;
+ return testCompareOutputLit(exp, "\nCPU time:", argv);
}
-
static int testCompareDominfoByUUID(const void *data ATTRIBUTE_UNUSED) {
- const char *const argv[] = {
- VIRSH_CUSTOM,
- "dominfo",
- "ef861801-45b9-11cb-88e3-afbfe5370493",
- NULL
- };
- return testCompareOutput("virshdata/dominfo-fc4.txt",
- "\nCPU time:",
- argv);
+ const char *const argv[] = { VIRSH_CUSTOM, "dominfo", DOM_UUID, NULL };
+ const char *exp = dominfo_fc4;
+ return testCompareOutputLit(exp, "\nCPU time:", argv);
}
-
static int testCompareDominfoByName(const void *data ATTRIBUTE_UNUSED) {
- const char *const argv[] = {
- VIRSH_CUSTOM,
- "dominfo",
- "fc4",
- NULL
- };
- return testCompareOutput("virshdata/dominfo-fc4.txt",
- "\nCPU time:",
- argv);
+ const char *const argv[] = { VIRSH_CUSTOM, "dominfo", "fc4", NULL };
+ const char *exp = dominfo_fc4;
+ return testCompareOutputLit(exp, "\nCPU time:", argv);
}
-
static int testCompareDomuuidByID(const void *data ATTRIBUTE_UNUSED) {
- const char *const argv[] = {
- VIRSH_CUSTOM,
- "domuuid",
- "2",
- NULL
- };
- return testCompareOutput("virshdata/domuuid-fc4.txt",
- NULL,
- argv);
+ const char *const argv[] = { VIRSH_CUSTOM, "domuuid", "2", NULL };
+ const char *exp = domuuid_fc4;
+ return testCompareOutputLit(exp, NULL, argv);
}
static int testCompareDomuuidByName(const void *data ATTRIBUTE_UNUSED) {
- const char *const argv[] = {
- VIRSH_CUSTOM,
- "domuuid",
- "fc4",
- NULL
- };
- return testCompareOutput("virshdata/domuuid-fc4.txt",
- NULL,
- argv);
+ const char *const argv[] = { VIRSH_CUSTOM, "domuuid", "fc4", NULL };
+ const char *exp = domuuid_fc4;
+ return testCompareOutputLit(exp, NULL, argv);
}
static int testCompareDomidByName(const void *data ATTRIBUTE_UNUSED) {
- const char *const argv[] = {
- VIRSH_CUSTOM,
- "domid",
- "fc4",
- NULL
- };
- return testCompareOutput("virshdata/domid-fc4.txt",
- NULL,
- argv);
+ const char *const argv[] = { VIRSH_CUSTOM, "domid", "fc4", NULL };
+ const char *exp = domid_fc4;
+ return testCompareOutputLit(exp, NULL, argv);
}
-
static int testCompareDomidByUUID(const void *data ATTRIBUTE_UNUSED) {
- const char *const argv[] = {
- VIRSH_CUSTOM,
- "domid",
- "ef861801-45b9-11cb-88e3-afbfe5370493",
- NULL
- };
- return testCompareOutput("virshdata/domid-fc4.txt",
- NULL,
- argv);
+ const char *const argv[] = { VIRSH_CUSTOM, "domid", DOM_UUID, NULL };
+ const char *exp = domid_fc4;
+ return testCompareOutputLit(exp, NULL, argv);
}
-
static int testCompareDomnameByID(const void *data ATTRIBUTE_UNUSED) {
- const char *const argv[] = {
- VIRSH_CUSTOM,
- "domname",
- "2",
- NULL
- };
- return testCompareOutput("virshdata/domname-fc4.txt",
- NULL,
- argv);
+ const char *const argv[] = { VIRSH_CUSTOM, "domname", "2", NULL };
+ const char *exp = domname_fc4;
+ return testCompareOutputLit(exp, NULL, argv);
}
-
static int testCompareDomnameByUUID(const void *data ATTRIBUTE_UNUSED) {
- const char *const argv[] = {
- VIRSH_CUSTOM,
- "domname",
- "ef861801-45b9-11cb-88e3-afbfe5370493",
- NULL
- };
- return testCompareOutput("virshdata/domname-fc4.txt",
- NULL,
- argv);
+ const char *const argv[] = { VIRSH_CUSTOM, "domname", DOM_UUID, NULL };
+ const char *exp = domname_fc4;
+ return testCompareOutputLit(exp, NULL, argv);
}
static int testCompareDomstateByID(const void *data ATTRIBUTE_UNUSED) {
- const char *const argv[] = {
- VIRSH_CUSTOM,
- "domstate",
- "2",
- NULL
- };
- return testCompareOutput("virshdata/domstate-fc4.txt",
- NULL,
- argv);
+ const char *const argv[] = { VIRSH_CUSTOM, "domstate", "2", NULL };
+ const char *exp = domstate_fc4;
+ return testCompareOutputLit(exp, NULL, argv);
}
-
static int testCompareDomstateByUUID(const void *data ATTRIBUTE_UNUSED) {
- const char *const argv[] = {
- VIRSH_CUSTOM,
- "domstate",
- "ef861801-45b9-11cb-88e3-afbfe5370493",
- NULL
- };
- return testCompareOutput("virshdata/domstate-fc4.txt",
- NULL,
- argv);
+ const char *const argv[] = { VIRSH_CUSTOM, "domstate", DOM_UUID, NULL };
+ const char *exp = domstate_fc4;
+ return testCompareOutputLit(exp, NULL, argv);
}
static int testCompareDomstateByName(const void *data ATTRIBUTE_UNUSED) {
- const char *const argv[] = {
- VIRSH_CUSTOM,
- "domstate",
- "fc4",
- NULL
- };
- return testCompareOutput("virshdata/domstate-fc4.txt",
- NULL,
- argv);
+ const char *const argv[] = { VIRSH_CUSTOM, "domstate", "fc4", NULL };
+ const char *exp = domstate_fc4;
+ return testCompareOutputLit(exp, NULL, argv);
}
static int
--
1.6.0.4.911.gc990
16 years, 4 months
[libvirt] [PATCH] tests: new test: virsh-synopsis
by Jim Meyering
I wanted help SYNOPSIS output that was regular enough to parse.
Enforcing/correcting the following is the first step:
>From fa58b801ea80f52a10d48ab75a359ffe06c4be40 Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering(a)redhat.com>
Date: Fri, 21 Nov 2008 10:58:36 +0100
Subject: [PATCH] tests: new test: virsh-synopsis
* tests/virsh-synopsis: new file
* tests/Makefile.am (test_scripts): Add virsh-synopsis.
* src/virsh.c: Correct help SYNOPSIS for each of seven commands.
When I first ran this script, "make check" failed like this:
...
invalid help SYNOPSIS for net-create:
create a network from an XML <file>
invalid help SYNOPSIS for net-define:
define a network from an XML <file>
invalid help SYNOPSIS for net-start:
start <network>
invalid help SYNOPSIS for pool-create:
create a pool from an XML <file>
invalid help SYNOPSIS for pool-define:
define a pool from an XML <file>
invalid help SYNOPSIS for pool-start:
start <pool>
invalid help SYNOPSIS for vol-create:
create <file>
FAIL: virsh-synopsis
---
src/virsh.c | 17 +++++++++--------
tests/Makefile.am | 1 +
tests/virsh-synopsis | 43 +++++++++++++++++++++++++++++++++++++++++++
3 files changed, 53 insertions(+), 8 deletions(-)
create mode 100755 tests/virsh-synopsis
diff --git a/src/virsh.c b/src/virsh.c
index 4195781..78c536e 100644
--- a/src/virsh.c
+++ b/src/virsh.c
@@ -2365,7 +2365,7 @@ cmdNetworkAutostart(vshControl *ctl, const vshCmd *cmd)
* "net-create" command
*/
static const vshCmdInfo info_network_create[] = {
- {"syntax", "create a network from an XML <file>"},
+ {"syntax", "net-create <file>"},
{"help", gettext_noop("create a network from an XML file")},
{"desc", gettext_noop("Create a network.")},
{NULL, NULL}
@@ -2413,7 +2413,7 @@ cmdNetworkCreate(vshControl *ctl, const vshCmd *cmd)
* "net-define" command
*/
static const vshCmdInfo info_network_define[] = {
- {"syntax", "define a network from an XML <file>"},
+ {"syntax", "net-define <file>"},
{"help", gettext_noop("define (but don't start) a network from an XML file")},
{"desc", gettext_noop("Define a network.")},
{NULL, NULL}
@@ -2697,7 +2697,7 @@ cmdNetworkName(vshControl *ctl, const vshCmd *cmd)
* "net-start" command
*/
static const vshCmdInfo info_network_start[] = {
- {"syntax", "start <network>"},
+ {"syntax", "net-start <network>"},
{"help", gettext_noop("start a (previously defined) inactive network")},
{"desc", gettext_noop("Start a network.")},
{NULL, NULL}
@@ -2862,14 +2862,15 @@ cmdPoolAutostart(vshControl *ctl, const vshCmd *cmd)
* "pool-create" command
*/
static const vshCmdInfo info_pool_create[] = {
- {"syntax", "create a pool from an XML <file>"},
+ {"syntax", "pool-create <file>"},
{"help", gettext_noop("create a pool from an XML file")},
{"desc", gettext_noop("Create a pool.")},
{NULL, NULL}
};
static const vshCmdOptDef opts_pool_create[] = {
- {"file", VSH_OT_DATA, VSH_OFLAG_REQ, gettext_noop("file containing an XML pool description")},
+ {"file", VSH_OT_DATA, VSH_OFLAG_REQ,
+ gettext_noop("file containing an XML pool description")},
{NULL, 0, 0, NULL}
};
@@ -3000,7 +3001,7 @@ cmdPoolCreateAs(vshControl *ctl, const vshCmd *cmd)
* "pool-define" command
*/
static const vshCmdInfo info_pool_define[] = {
- {"syntax", "define a pool from an XML <file>"},
+ {"syntax", "pool-define <file>"},
{"help", gettext_noop("define (but don't start) a pool from an XML file")},
{"desc", gettext_noop("Define a pool.")},
{NULL, NULL}
@@ -3727,7 +3728,7 @@ cmdPoolName(vshControl *ctl, const vshCmd *cmd)
* "pool-start" command
*/
static const vshCmdInfo info_pool_start[] = {
- {"syntax", "start <pool>"},
+ {"syntax", "pool-start <pool>"},
{"help", gettext_noop("start a (previously defined) inactive pool")},
{"desc", gettext_noop("Start a pool.")},
{NULL, NULL}
@@ -3965,7 +3966,7 @@ cmdPoolUuid(vshControl *ctl, const vshCmd *cmd)
* "vol-create" command
*/
static const vshCmdInfo info_vol_create[] = {
- {"syntax", "create <file>"},
+ {"syntax", "vol-create <file>"},
{"help", gettext_noop("create a vol from an XML file")},
{"desc", gettext_noop("Create a vol.")},
{NULL, NULL}
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 0b4eebd..bec3791 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -58,6 +58,7 @@ test_scripts += \
undefine \
vcpupin
virsh-all
+ virsh-synopsis
endif
EXTRA_DIST += $(test_scripts)
diff --git a/tests/virsh-synopsis b/tests/virsh-synopsis
new file mode 100755
index 0000000..6ce58a2
--- /dev/null
+++ b/tests/virsh-synopsis
@@ -0,0 +1,43 @@
+#!/bin/sh
+# ensure that each command's help "SYNOPSIS" line starts with the command name
+
+# Copyright (C) 2008 Free Software Foundation, Inc.
+
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+if test "$VERBOSE" = yes; then
+ set -x
+ virsh --version
+fi
+
+. $srcdir/test-lib.sh
+
+fail=0
+
+test_url=test:///default
+
+virsh -c $test_url help > cmds || framework_failure
+cmds=$(sed -n 's/^ \([^ ][^ ]*\) .*/\1/p' cmds) || framework_failure
+test -n "$cmds" || framework_failure
+
+for i in $cmds; do
+ virsh -c $test_url help $i > help || fail=1
+ grep -A1 '^ SYNOPSIS$' help > synopsis \
+ || { echo 1>&2 missing or invalid help SYNOPSIS for $i; fail=1; }
+ sed -n 2p synopsis > s2 || framework_failure
+ grep -E "^ $i( |$)" s2 > /dev/null \
+ || { echo 1>&2 "invalid help SYNOPSIS for $i:"; cat s2 1>&2; fail=1; }
+done
+
+(exit $fail); exit $fail
--
1.6.0.4.1021.g4320
16 years, 4 months
[libvirt] [PATCH] fix EventImpl-related error paths in remote driver
by David Lively
This patch makes the remote driver behave properly in the face of:
(a) no registered EventImpl, or
(b) an EventImpl that returns failure from AddHandle/Timeout
In both cases, we now cleanup properly (rather than always passing bogus
values to virEventRemoveHandle/Timeout) and fail attempts to register
for domain events (w/VIR_ERR_NO_SUPPORT rather than blissfully continue
when we can't possibly deliver events).
Dave
remote_internal.c | 15 +++++++++++----
1 file changed, 11 insertions(+), 4 deletions(-)
16 years, 4 months
[libvirt] [PATCH] fix libvirtd crash in qemu driver
by David Lively
I noticed that the following sequence of events would crash libvirtd
when using the qemu driver:
(1) establish a connection that successfully registers for domain
events (either of the event-test programs will do, though the
python one is currently broken -- another patch on the way for
that)
(2) close this connection
(3) open another connection
(4) do something (like start a domain) that issues a domain event
The problem is that qemudClose() isn't removing registered domain event
callbacks when the connection closes. This patch does that, and fixes
the crash.
Dave
domain_event.c | 38 ++++++++++++++++++++++++++++++++++++++
domain_event.h | 3 +++
qemu_driver.c | 5 ++++-
3 files changed, 45 insertions(+), 1 deletion(-)
16 years, 4 months
[libvirt] Relax requirement of bridge source device
by Jim Fehlig
Hi All,
I wanted to get folks thoughts on relaxing the requirement for bridge
source device in network interface of domain XML, e.g. allowing
<interface type="bridge">
<mac address="aa:bb:cc:cc:ee:ff"/>
</interface>
Currently, virDomainNetDefParseXML() in src/domain_conf.c will fail such
configuration. Since this is common code between backends I'm not sure
how allowing this config will affect the various virtualizers.
Xen's vif-bridge script will try to find a bridge if one is not
specified, which perhaps is dubious behavior, but nonetheless convenient
in migration scenarios where the target host may have a different bridge
name (br1 vs br0 for example). IIRC, qemu's qemu-ifup script is not as
forgiving in the absence of a bridge name.
I would be happy to provide a patch if relaxing the source device
requirement is acceptable.
Thanks,
Jim
16 years, 4 months