"Daniel P. Berrange" <berrange(a)redhat.com> wrote:
> >From 560e27e1576a4c0ebe7db3e697ed9b6d8aa88fbc Mon Sep 17
00:00:00 2001
> From: Jim Meyering <meyering(a)redhat.com>
> Date: Fri, 30 Jan 2009 20:06:48 +0100
> Subject: [PATCH] tests: diagnose open failure
>
> * tests/qemuxml2argvtest.c (testCompareXMLToArgvFiles): Diagnose
> failure to open an input file.
> ---
> tests/qemuxml2argvtest.c | 4 +++-
> 1 files changed, 3 insertions(+), 1 deletions(-)
>
> diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
> index 90b4740..1d7aeb9 100644
> --- a/tests/qemuxml2argvtest.c
> +++ b/tests/qemuxml2argvtest.c
> @@ -36,8 +36,10 @@ static int testCompareXMLToArgvFiles(const char *xml,
> virDomainDefPtr vmdef = NULL;
> virDomainObj vm;
>
> - if (virtTestLoadFile(cmd, &expectargv, MAX_FILE) < 0)
> + if (virtTestLoadFile(cmd, &expectargv, MAX_FILE) < 0) {
> + fprintf(stderr, "failed to open %s: %s\n", cmd, strerror
(errno));
> goto fail;
> + }
>
> if (!(vmdef = virDomainDefParseFile(NULL, driver.caps, xml,
> VIR_DOMAIN_XML_INACTIVE)))
ACK
Applied.
But as John Levon pointed out, there are many more tests/*test.c
programs that use virtTestLoadFile in exactly the same way:
$ git grep -h 'if (virtTestLoadFile'
if (virtTestLoadFile(outputfile, &expect, MAX_FILE) < 0)
if (virtTestLoadFile(cmd, &expectargv, MAX_FILE) < 0) {
if (virtTestLoadFile(xml, &xmlPtr, MAX_FILE) < 0)
if (virtTestLoadFile(xml, &xmlPtr, MAX_FILE) < 0)
if (virtTestLoadFile(sexpr, &sexprPtr, MAX_FILE) < 0)
if (virtTestLoadFile(expect, &expectPtr, MAX_FILE) < 0)
if (virtTestLoadFile(xml, &expectxml, MAX_FILE) < 0)
if (virtTestLoadFile(xml, &xmlPtr, MAX_FILE) < 0)
if (virtTestLoadFile(xmcfg, &xmcfgPtr, MAX_FILE) < 0)
if (virtTestLoadFile(xml, &xmlPtr, MAX_FILE) < 0)
if (virtTestLoadFile(xmcfg, &xmcfgPtr, MAX_FILE) < 0)
if (virtTestLoadFile(xml, &xmlPtr, MAX_FILE) < 0)
if (virtTestLoadFile(sexpr, &sexprPtr, MAX_FILE) < 0)
So rather than applying the same multi-line fix to all of those uses,
I expect to revert that patch and move the error reporting
into virtTestLoadFile itself.