[PATCH] tst: Provide Y2038 tests for mktime (tst-mktime4.c)
Lukasz Majewski
lukma@denx.de
Mon Jan 25 21:31:50 GMT 2021
Hi Joseph,
> On Mon, 25 Jan 2021, Lukasz Majewski wrote:
>
> > + /* Check that mktime(1970-01-01 00:00:00) returns 0. */
> > + test_mktime_helper (&tm0, 0);
> > +
> > + /* Check that mktime(2038-01-19 03:14:07) returns 0x7FFFFFFF. */
> > + test_mktime_helper (&tmY2038, 0x7fffffff);
> > +
> > + /* Check that mktime(2038-01-19 03:14:08) returns 0x80000000
> > + (time_t overflow). */
> > + if (sizeof (time_t) > 4)
> > + {
> > + tmY2038.tm_sec++;
> > + test_mktime_helper (&tmY2038, 0x80000000);
> > + }
> > + else
> > + FAIL_UNSUPPORTED ("32-bit time_t");
>
> FAIL_UNSUPPORTED causes the whole test to report an UNSUPPORTED
> status. If a test has a mixture of assertions that work with 32-bit
> time and assertions that only work for 64-bit time, I think those
> should be split into separate tests so that those tests that make
> sense with 32-bit time still produce results in that case.
>
The idea behind this FAIL_UNSUPPORTED when sizeof(time_t) <= 4 is to:
1. On 32 bit ports - check correct operation of mktime for 32 bit
time_t. If those checks fail, then we fail the test. Tests which require
64 bit size of time_t will not be supported until -D_TIME_BITS=64 is
supported in glibc.
2. On 64 bit ports - the test will either end without errors or fail.
3. I do have corresponding test - tst-mktime4-y2038.c [1] which only has
following lines:
#define _TIME_BITS 64
#define _FILE_OFFSET_BITS 64
#include "tst-mktime4.c"
Which will either pass or fail when 64 bit time_t support is added on
ports with __WORDSIZE=32 && __TIMESIZE != 64.
However, there is no point to send tst-mktime4-y2038.c until the
above feature is supported.
Links:
[1] - https://github.com/lmajewski/y2038_glibc/commits/y2038_edge
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/0d213fdf/attachment.sig>
More information about the Libc-alpha
mailing list