libvir-list-bounces@redhat.com wrote on 10/22/2010
01:02:15 PM:
>
> ---
> tests/qemuxml2argvtest.c | 240 ++++++++++++++++++++++++
> +---------------------
> 1 files changed, 132 insertions(+), 108 deletions(-)
>
> diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
> index 551d6c4..4eb3cc6 100644
> --- a/tests/qemuxml2argvtest.c
> +++ b/tests/qemuxml2argvtest.c
> @@ -4,6 +4,7 @@
> #include <stdlib.h>
> #include <unistd.h>
> #include <string.h>
> +#include <stdbool.h>
>
> #include <sys/types.h>
> #include <fcntl.h>
> @@ -26,7 +27,8 @@ static struct qemud_driver driver;
> static int testCompareXMLToArgvFiles(const char *xml,
>
const char
*cmd,
>
unsigned
long long extraFlags,
> -
const char *migrateFrom)
{
> +
const char *migrateFrom,
> +
bool expectError)
{
> char argvData[MAX_FILE];
> char *expectargv = &(argvData[0]);
> char *actualargv = NULL;
> @@ -38,6 +40,7 @@ static int testCompareXMLToArgvFiles(const char
*xml,
> virDomainDefPtr vmdef = NULL;
> virDomainChrDef monitor_chr;
> virConnectPtr conn;
> + char *log = NULL;
>
> if (!(conn = virGetConnect()))
> goto fail;
> @@ -80,12 +83,28 @@ static int testCompareXMLToArgvFiles(const char
*xml,
> }
>
>
> + free(virtTestLogContentAndReset());
> +
> if (qemudBuildCommandLine(conn, &driver,
>
vmdef, &monitor_chr, 0, flags,
>
&argv, &qenv,
>
NULL, NULL, migrateFrom, NULL)
< 0)
> goto fail;
>
> + if ((log = virtTestLogContentAndReset()) == NULL)
> + goto fail;
> +
> + if (!!strstr(log, ": error :") != expectError)
{
> + if (virTestGetDebug())
> + fprintf(stderr, "\n%s",
log);
> + goto fail;
> + }
> +
> + if (expectError) {
> + /* need to suppress the errors */
> + virResetLastError();
> + }
> +
> len = 1; /* for trailing newline */
> tmp = qenv;
> while (*tmp) {
> @@ -125,6 +144,7 @@ static int testCompareXMLToArgvFiles(const char
*xml,
> ret = 0;
>
> fail:
> + free(log);
> free(actualargv);
> if (argv) {
> tmp = argv;
> @@ -152,6 +172,7 @@ struct testInfo {
> const char *name;
> unsigned long long extraFlags;
> const char *migrateFrom;
> + bool expectError;
> };
>
> static int testCompareXMLToArgvHelper(const void *data) {
> @@ -162,7 +183,8 @@ static int testCompareXMLToArgvHelper(const void
*data) {
> abs_srcdir, info->name);
> snprintf(args, PATH_MAX, "%s/qemuxml2argvdata/qemuxml2argv-%s.args",
> abs_srcdir, info->name);
> - return testCompareXMLToArgvFiles(xml, args, info->extraFlags,
> info->migrateFrom);
> + return testCompareXMLToArgvFiles(xml, args, info->extraFlags,
> +
info->migrateFrom,
info->expectError);
> }
>
>
> @@ -193,16 +215,18 @@ mymain(int argc, char **argv)
> if ((driver.hugepage_path = strdup("/dev/hugepages/libvirt/
> qemu")) == NULL)
> return EXIT_FAILURE;
>
> -# define DO_TEST_FULL(name, extraFlags, migrateFrom)
\
> +# define DO_TEST_FULL(name, extraFlags, migrateFrom, expectError)
\
> do {
\
> - const struct testInfo info = { name,
extraFlags, migrateFrom }; \
> + const struct testInfo info = {
\
> + name, extraFlags, migrateFrom,
expectError \
> + };
\
> if (virtTestRun("QEMU XML-2-ARGV
" name,
\
>
1, testCompareXMLToArgvHelper, &info) < 0)
\
> ret = -1;
\
> } while (0)
>
> -# define DO_TEST(name, extraFlags)
\
> - DO_TEST_FULL(name, extraFlags, NULL)
> +# define DO_TEST(name, extraFlags, expectError)
\
> + DO_TEST_FULL(name, extraFlags, NULL,
expectError)
>
> /* Unset or set all envvars here that are copied
in qemudBuildCommandLine
> * using ADD_ENV_COPY, otherwise these tests may
fail due to unexpected
> @@ -217,175 +241,175 @@ mymain(int argc, char **argv)
> unsetenv("QEMU_AUDIO_DRV");
> unsetenv("SDL_AUDIODRIVER");
>
> - DO_TEST("minimal", QEMUD_CMD_FLAG_NAME);
> - DO_TEST("machine-aliases1", 0);
[...]
look good to me -- ACK
Stefan