[patch][core] Fix test_default_session_servicedirs on Unix

Simon McVittie simon.mcvittie at collabora.co.uk
Tue May 22 05:33:49 PDT 2007

Hash: SHA1

bus/config-parser.c r1.50 reordered the expected order of service directories
on Unix (breaking the test), apparently in the interests of simplifying the
Unix vs Windows #ifdefs. This patch reverts the re-ordering to make the test
pass again.

Also, r1.50 added some calls to _dbus_string_free for a DBusString
that's only initialized on Windows (well, strictly speaking: when
$CommonProgramFiles is in the environment). Rather than making the
_dbus_string_free conditional, I've just moved the initialization of the
DBusString outside the Windows-specific code.

Finally, I've ensured that the Windows-specific code is only run if, in
fact, running Windows (and not if a Unix user happens to have
$CommonProgramFiles in their environment for some reason).

make check and make distcheck now pass on Unix - Ralf, could you check
that I haven't broken the tests on Windows?


Index: bus/config-parser.c
RCS file: /cvs/dbus/dbus/bus/config-parser.c,v
retrieving revision 1.50
diff -u -u -r1.50 config-parser.c
- --- bus/config-parser.c	17 May 2007 11:47:48 -0000	1.50
+++ bus/config-parser.c	22 May 2007 12:31:01 -0000
@@ -3077,12 +3077,14 @@
 static const char *test_service_dir_matches[] = 
- -         DBUS_DATADIR"/dbus-1/services",
 #ifdef DBUS_UNIX
- -         "/testhome/foo/.testlocal/testshare/dbus-1/services",         
- -#endif 
+         DBUS_DATADIR"/dbus-1/services",
+#ifdef DBUS_UNIX
+         "/testhome/foo/.testlocal/testshare/dbus-1/services",
@@ -3095,12 +3097,15 @@
   const char *common_progs;
   int i;
+  /* On Unix we don't actually use this variable, but it's easier to handle the
+   * deallocation if we always allocate it, whether needed or not */
+  if (!_dbus_string_init (&progs))
+    _dbus_assert_not_reached ("OOM allocating progs");
   common_progs = _dbus_getenv ("CommonProgramFiles");
+#ifndef DBUS_UNIX
   if (common_progs) 
- -      if (!_dbus_string_init (&progs))
- -        return FALSE;
- -
       if (!_dbus_string_append (&progs, common_progs)) 
           _dbus_string_free (&progs);
@@ -3114,6 +3119,7 @@
       test_service_dir_matches[1] = _dbus_string_get_const_data(&progs);
   dirs = NULL;
   printf ("Testing retrieving the default session service directories\n");
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: OpenPGP key: http://www.pseudorandom.co.uk/2003/contact/ or pgp.net


More information about the dbus mailing list