Eric Blake wrote: > Jim Meyering <jim <at> meyering.net> writes: >> FYI, here's the new test, in case anyone feels like reviewing: >> >> +static struct posixtm_test T[] = >> + { >> + { "12131415.16", 13, " 1039788916 Fri Dec 13 14:15:16 2002" }, >> + { "12131415.16", 13, " 1039788916 Fri Dec 13 14:15:16 2002" }, > > I like how you made the test independent of the year, later on.
I've just noticed that those two lines are identical. Humph. I suppose one should have lacked the .SS suffix, for coverage of that case. >> + { "000001010000.00", 13, "-62167132800 Sun Jan 1 00:00:00 0000" }, >> + { "190112132045.52", 13, " -2147483648 Fri Dec 13 20:45:52 1901" }, >> + { "190112132045.53", 13, " -2147483647 Fri Dec 13 20:45:53 1901" }, >> + { "190112132046.52", 13, " -2147483588 Fri Dec 13 20:46:52 1901" }, >> + { "190112132145.52", 13, " -2147480048 Fri Dec 13 21:45:52 1901" }, >> + { "190112142045.52", 13, " -2147397248 Sat Dec 14 20:45:52 1901" }, >> + { "190201132045.52", 13, " -2144805248 Mon Jan 13 20:45:52 1902" }, > > I would feel more comfortable if we split this into two arrays, one supported > by 32-bit signed time_t run on all hosts, and another for 39+-bit time_t run > only on supporting hosts. That way, even 32-bit time_t gets some test > exposure, for the values which are in range. Ok. I'll do that. >> + /* This test data also assumes that time_t is signed and is at least >> + 39 bits wide, so that it can represent all years from 0000 through >> + 9999. A host with 32-bit signed time_t can represent only time >> + stamps in the range 1901-12-13 20:45:52 through 2038-01-18 >> + 03:14:07 UTC, assuming POSIX time_t with no leap seconds, so test >> + cases outside this range will not work on such a host. */ >> + if ( ! TYPE_SIGNED (time_t)) >> + { >> + fprintf (stderr, "%s: this test requires signed time_t\n"); >> + return 77; >> + } > > Is this true? It seems like unsigned 64-bit time_t will still pass this test. I don't know off hand. I trusted the comment ;-) >> + if (sizeof (time_t) * CHAR_BIT < 39) >> + { >> + fprintf (stderr, "%s: this test requires time_t at least 39 bits > wide\n"); >> + return 77; >> + } > > Given my above idea for splitting into two arrays, it would be nice if this > message occurred after testing the first array, and included wording such > as "skipping remainder of test". Sure.