]> xenbits.xensource.com Git - libvirt.git/commitdiff
tests: avoid crash when run under gcov
authorEric Blake <eblake@redhat.com>
Wed, 11 May 2011 15:51:30 +0000 (09:51 -0600)
committerEric Blake <eblake@redhat.com>
Wed, 11 May 2011 15:58:35 +0000 (09:58 -0600)
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().

tests/commandtest.c

index caad69832af339d6dfbef49fc094d0688ca1ecca..67572535268cd9526c4ac7b4949b610af5d104db 100644 (file)
@@ -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,17 +783,6 @@ 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)                                                \