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

Eric Blake eblake at redhat.com
Wed May 11 15:57:46 UTC 2011


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",                    \
-- 
1.7.4.4




More information about the libvir-list mailing list