mirror of
git://git.gnupg.org/gnupg.git
synced 2025-01-08 12:44:23 +01:00
tests: Fix end-of-all-ticks test for Western locales.
* common/t-timestuff.c (test_timegm): Use timegm if available. (main): Set TX to UTC if timegm is not available. -- On OpenBSD 5.3 i386 that test failed due to the use of mktime. Reported-by: Claus Assmann
This commit is contained in:
parent
b51af333bd
commit
3533860ee3
@ -112,7 +112,11 @@ test_timegm (void)
|
|||||||
tbuf.tm_hour = tvalues[tidx].hour;
|
tbuf.tm_hour = tvalues[tidx].hour;
|
||||||
tbuf.tm_min = tvalues[tidx].min;
|
tbuf.tm_min = tvalues[tidx].min;
|
||||||
tbuf.tm_sec = tvalues[tidx].sec;
|
tbuf.tm_sec = tvalues[tidx].sec;
|
||||||
|
#ifdef HAVE_TIMEGM
|
||||||
|
now = timegm (&tbuf);
|
||||||
|
#else
|
||||||
now = mktime (&tbuf);
|
now = mktime (&tbuf);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
if (now == (time_t)(-1))
|
if (now == (time_t)(-1))
|
||||||
fail (tidx);
|
fail (tidx);
|
||||||
@ -122,7 +126,11 @@ test_timegm (void)
|
|||||||
fail (tidx);
|
fail (tidx);
|
||||||
tbuf = *tp;
|
tbuf = *tp;
|
||||||
tbuf2 = tbuf;
|
tbuf2 = tbuf;
|
||||||
|
#ifdef HAVE_TIMEGM
|
||||||
atime = timegm (&tbuf);
|
atime = timegm (&tbuf);
|
||||||
|
#else
|
||||||
|
atime = mktime (&tbuf);
|
||||||
|
#endif
|
||||||
if (atime == (time_t)(-1))
|
if (atime == (time_t)(-1))
|
||||||
fail (tidx);
|
fail (tidx);
|
||||||
if (atime != now)
|
if (atime != now)
|
||||||
@ -146,6 +154,14 @@ main (int argc, char **argv)
|
|||||||
(void)argc;
|
(void)argc;
|
||||||
(void)argv;
|
(void)argv;
|
||||||
|
|
||||||
|
/* If we do not have timegm, we use mktime. However, we need to use
|
||||||
|
UTC in this case so that the 20380118T235959 test does not fail
|
||||||
|
for other timezones. */
|
||||||
|
#ifndef HAVE_TIMEGM
|
||||||
|
setenv ("TZ", "UTC", 1);
|
||||||
|
tzset ();
|
||||||
|
#endif
|
||||||
|
|
||||||
test_timegm ();
|
test_timegm ();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user