]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
Unset copied environment variables in qemuxml2argvtest
authorMatthias Bolte <matthias.bolte@googlemail.com>
Mon, 28 Dec 2009 15:21:15 +0000 (16:21 +0100)
committerMatthias Bolte <matthias.bolte@googlemail.com>
Wed, 20 Jan 2010 22:22:15 +0000 (23:22 +0100)
The test expected all environment variables copied in qemudBuildCommandLine
to have known values. So all of them have to be either set to a known value
or be unset. SDL_VIDEODRIVER and QEMU_AUDIO_DRV are not handled at all but
should be handled. Unset both, otherwise the test will fail if they are set
in the testing environment.

* src/qemu/qemu_conf.c: add a comment about copied environment variables
  and qemuxml2argvtest
* tests/qemuxml2argvtest.c: unset SDL_VIDEODRIVER and QEMU_AUDIO_DRV

src/qemu/qemu_conf.c
tests/qemuxml2argvtest.c

index 47732aba7bb7e476591fe68aeef605848d8f0b1d..ba31cccc6f3cdc07d1829eac34e50be2e0a69dc7 100644 (file)
@@ -2879,6 +2879,8 @@ int qemudBuildCommandLine(virConnectPtr conn,
         qenv[qenvc++] = envval;                                         \
     } while (0)
 
+    /* Make sure to unset or set all envvars in qemuxml2argvtest.c that
+     * are copied here using this macro, otherwise the test may fail */
 #define ADD_ENV_COPY(envname)                                           \
     do {                                                                \
         char *val = getenv(envname);                                    \
index 41e5749fb094bb91af8697747049f06ef61f19c3..fc237c212437d6bebeb0675d6413f367f3046bae 100644 (file)
@@ -184,6 +184,9 @@ mymain(int argc, char **argv)
 #define DO_TEST(name, extraFlags)                       \
         DO_TEST_FULL(name, extraFlags, NULL)
 
+    /* Unset or set all envvars here that are copied in qemudBuildCommandLine
+     * using ADD_ENV_COPY, otherwise these tests may fail due to unexpected
+     * values for these envvars */
     setenv("PATH", "/bin", 1);
     setenv("USER", "test", 1);
     setenv("LOGNAME", "test", 1);
@@ -191,6 +194,8 @@ mymain(int argc, char **argv)
     unsetenv("TMPDIR");
     unsetenv("LD_PRELOAD");
     unsetenv("LD_LIBRARY_PATH");
+    unsetenv("QEMU_AUDIO_DRV");
+    unsetenv("SDL_AUDIODRIVER");
 
     DO_TEST("minimal", QEMUD_CMD_FLAG_NAME);
     DO_TEST("machine-aliases1", 0);