Re: glib2 GDateTime API tests fail on Mac OS X



Marius,

You didn't try "make check", I bet.

I added a bunch of printf's to g_time_zone_new() in glib/gtimezone.c, as well as to test_GDateTime_equal() in glib/tests/gdatetime.c.  When I run the gdatetime test, I get:

$ glib/tests/gdatetime
<snip>
/GDateTime/diff: 
--->g_time_zone_new: Time zone "(null)" not found in time_zones hash table

<snip>
--->g_time_zone_new: Time zone "America/Recife" not found in time_zones hash table


--->g_time_zone_new: zoneinfo not found in zone_for_constant_offset()


--->g_time_zone_new: Obtain zoneinfo from g_mapped_file_new( "/usr/share/zoneinfo/America/Recife", FALSE, NULL )


--->g_time_zone_new: zoneinfo file is version 


--->g_time_zone_new: Throwing away zoneinfo file (glib only supports version 2)


--->America/Recife time zone abbreviation: UTC


--->UTC offset: 0

**
ERROR:gdatetime.c:196:test_GDateTime_equal: assertion failed (g_date_time_get_utc_offset (dt1) / G_USEC_PER_SEC == (-3 * 3600)): (0 == -10800)
Abort trap

I found that g_time_zone_new() in glib/gtimezone.c only supports TZif2 format zoneinfo files:

          /* we only bother to support version 2 */
          if (size < sizeof (struct tzhead) || memcmp (header, "TZif2", 5))

The zoneinfo files on my Mac (10.5.8) are TZif format:

$ hexdump -C /etc/localtime
00000000  54 5a 69 66 00 00 00 00  00 00 00 00 00 00 00 00  |TZif............|

Bad.  I think glib should test this in configure and disable all the GDateTime APIs rather than silently fail at run time.

Larry Baker
US Geological Survey
650-329-5608

On 27 Oct 2011, at 6:51 PM, Marius Schamschula wrote:

Larry,

glib 2.31.0 is the bleeding edge beta release ( all odd numbered, e.g. 31, versions, e.g. 31, are developmental). In fact I'm currently using glib2 2.28.8 for my production builds.

There are several incompatibilities introduced for glib >= 2.30.0 for gtk+ 2.x applications. If you need to build >= gtk+ 3.x, however, you need glib 2.30.0 or greater.

I vaguely recall that there is some magic on the Mac related to setting the TZ. A quick search found

http://support.apple.com/kb/TS2538

and

http://www.keiths-place.com/blogs/keith/2007/gmt-timezone-problem-mac-os-x

On Oct 27, 2011, at 8:22 PM, Larry Baker wrote:

Marius,

I stumbled across your name in the glib2 package README on the Huntsville Macintosh User's Group web site.  I wonder if I can ask you for some help with glib2.

I have downloaded and compiled glib2 2.31.0.  That took quite a while because I first had to download and install expat and GNU gettxt.  Those libraries compiled fine and passed their make check tests.  However, glib2 fails the GDateTime make check tests.  It seems not to be reading any of the time zone info files in /usr/share/zoneinfo.  The America/Recife tzinfo file is there:

$ ls -l /usr/share/zoneinfo/America/Recife
-rw-r--r--  1 root  wheel  276 Dec  5  2007 /usr/share/zoneinfo/America/Recife

I tried defining the TZDIR envonment variable, but that did not help.  For example,

$ TZDIR=/usr/share/zoneinfo glib/tests/gdatetime

I added a couple printf()'s in the test that fails, which clearly show that the time zone structure is coming back as UTC:

$ TZDIR=/usr/share/zoneinfo glib/tests/gdatetime
/GDateTime/add_days: OK
/GDateTime/add_full: OK
/GDateTime/add_hours: OK
/GDateTime/add_minutes: OK
/GDateTime/add_months: OK
/GDateTime/add_seconds: OK
/GDateTime/add_weeks: OK
/GDateTime/add_years: OK
/GDateTime/compare: OK
/GDateTime/diff: OK
/GDateTime/equal:
--->America/Recife time zone abbreviation: UTC


--->UTC offset: 0

**
ERROR:gdatetime.c:196:test_GDateTime_equal: assertion failed (g_date_time_get_utc_offset (dt1) / G_USEC_PER_SEC == (-3 * 3600)): (0 == -10800)
Abort trap

I don't actually plan to use the GDateTime routines.  All I'm trying to do is compile the ARM QEMU emulators.  I just don't like it when make check's fail.

I'm running Mac OS X 10.5.8, Xcode 3.1.3, but I don't think that matters.

$ uname -a
Darwin savaii.wr.usgs.gov 9.8.0 Darwin Kernel Version 9.8.0: Wed Jul 15 16:55:01 PDT 2009; root:xnu-1228.15.4~1/RELEASE_I386 i386

$ gcc -v
Using built-in specs.
Target: i686-apple-darwin9
Configured with: /var/tmp/gcc_42/gcc_42-5574~1/src/configure --disable-checking --enable-werror --prefix=/usr --mandir=/usr/share/man --enable-languages=c,objc,c++,obj-c++ --program-transform-name=/^[cg][^.-]*$/s/$/-4.2/ --with-slibdir=/usr/lib --build=i686-apple-darwin9 --with-gxx-include-dir=/usr/include/c++/4.0.0 --host=i686-apple-darwin9 --target=i686-apple-darwin9
Thread model: posix
gcc version 4.2.1 (Apple Inc. build 5574)

$ env | grep TZ

I must be missing something simple.  Do you have any ideas?

Larry Baker
US Geological Survey
650-329-5608
baker usgs gov


Marius Schamschula







[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]