On 05/21/2014 07:26 AM, Daniel P. Berrange wrote: > On Wed, May 21, 2014 at 04:16:29PM +0300, Laine Stump wrote: >> Since there isn't a single libc API to get this value, this patch >> supplies one which gets the value by grabbing current UTC, then >> converting that into a struct tm with localtime_r(), then back to a >> time_t using mktime; it again does the same operation, but using >> gmtime_r() instead (for UTC). It then subtracts utc time from the >> localtime, and finally adjusts if dst is set in the localtime timeinfo >> (because for some reason mktime doesn't take that into account). > > I think we ought to be able to unit test this code to make sure it is > doing what we want. ie setenv("TZ", "EDT") in the start of the test > suite to force a predictable timezone, then check the delta is > correct. Even better than "EDT" (which is not POSIX-compliant), reuse what we have done in other situations where we want to guarantee a known non-zero timezone that uses just POSIX functionality: tests/qemuxml2argvtest.c: if (setenv("TZ", "VIR00:30", 1) < 0) { -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
Attachment:
signature.asc
Description: OpenPGP digital signature
-- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list