[libvirt] [PATCH] tests: avoid crash when run under gcov

Daniel P. Berrange berrange at redhat.com
Wed May 11 16:13:06 UTC 2011


On Wed, May 11, 2011 at 09:57:46AM -0600, Eric Blake wrote:
> Running ./autobuild.sh failed when gcov is installed, because
> commandtest ended up crashing during gcov's getenv() call after
> exit() had already started.  I traced this nasty bug back to
> a scoping issue present since the test introduction.
> 
> * tests/commandtest.c (mymain): Move newenv...
> (newenv): ...to a scope that is still useful during exit().
> ---
> 
> Pushing under the build-breaker rule.
> 
>  tests/commandtest.c |   25 ++++++++++++++-----------
>  1 files changed, 14 insertions(+), 11 deletions(-)
> 
> diff --git a/tests/commandtest.c b/tests/commandtest.c
> index caad698..429a026 100644
> --- a/tests/commandtest.c
> +++ b/tests/commandtest.c
> @@ -748,6 +748,18 @@ cleanup:
>      return ret;
>  }
> 
> +static const char *const newenv[] = {
> +    "PATH=/usr/bin:/bin",
> +    "HOSTNAME=test",
> +    "LANG=C",
> +    "HOME=/home/test",
> +    "USER=test",
> +    "LOGNAME=test"
> +    "TMPDIR=/tmp",
> +    "DISPLAY=:0.0",
> +    NULL
> +};
> +
>  static int
>  mymain(void)
>  {
> @@ -771,18 +783,9 @@ mymain(void)
> 
>      virInitialize();
> 
> -    const char *const newenv[] = {
> -        "PATH=/usr/bin:/bin",
> -        "HOSTNAME=test",
> -        "LANG=C",
> -        "HOME=/home/test",
> -        "USER=test",
> -        "LOGNAME=test"
> -        "TMPDIR=/tmp",
> -        "DISPLAY=:0.0",
> -        NULL
> -    };
>      environ = (char **)newenv;
> 
>  # define DO_TEST(NAME)                                                \
>      if (virtTestRun("Command Exec " #NAME " test",                    \
> -- 

ACK


Daniel
-- 
|: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org              -o-             http://virt-manager.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org       -o-       http://live.gnome.org/gtk-vnc :|




More information about the libvir-list mailing list