[PATCH] tst: Provide Y2038 tests for mktime (tst-mktime4.c)
Lukasz Majewski
lukma@denx.de
Mon Jan 25 22:28:19 GMT 2021
Hi Florian,
> * Paul Eggert:
>
> > On 1/25/21 5:03 AM, Lukasz Majewski wrote:
> >
> >> + /* Set time zone for the test. */
> >> + TEST_VERIFY_EXIT (setenv ("TZ", "Europe/Warsaw", 1) == 0);
> >> + tzset ();
> >
> > Your test data assume UTC, so why set the time zone to Warsaw's?
I thought that I do need to explicitly set TZ here (either "TZ=UTC" or
"TZ=Europe/Warsaw").
When I poke on the manuals (like [1]) - it is all written that by
default (when TZ is not set) the UTC is used.
Hence, my question - why cannot I just check if TZ is set and if not
set it to default "TZ=UTC" ?
In that way I would have reproductible setup no matter if I run this
test on HOST or TARGET (VM) machines.
Another question - why in ./time/tst-y2039.c the
setenv ("TZ", "PST8PDT,M3.2.0,M11.1.0", 1) is set?
According to [2] the PST8PDT is deprecated. Why the UTC cannot be just
used?
> >
> > Also, there's no need to call tzset; mktime is supposed to do that.
Yes. Correct __tzset() is called in __mktime64() implementation.
> >
> > I suggest also testing 2**32 - 1 and 2**32, when using 64-bit
> > time_t.
Ok.
>
> Furthermore, if the test can't use UTC for some reason, please add a
> custom time zone for it, so that it does not depend on real tzdata
> files for future dates, which can change.
Sorry, but I'm confused - how shall I evaluate if I cannot use UTC for
some reason? As fair as I can tell the UTC is a default fallback (and
is assumed) for several time related calls [2].
Could you point me to some test case, which I could use as an example?
For example in ./time/tst-y2039.c the TZ is set to some arbitrary value
to have some non UTC (i.e. default) TZ, so the test will be more
reliable (detached from default TZ).
Is there any issue with using "TZ=UTC" for Y2038 related tests?
Links:
[1] - https://linux.die.net/man/3/mktime
[2] - https://en.wikipedia.org/wiki/List_of_tz_database_time_zones
>
> Thanks,
> Florian
Best regards,
Lukasz Majewski
--
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email: lukma@denx.de
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 488 bytes
Desc: OpenPGP digital signature
URL: <https://sourceware.org/pipermail/libc-alpha/attachments/20210125/875a372f/attachment.sig>
More information about the Libc-alpha
mailing list