diff options
author | Rich Salz <rsalz@akamai.com> | 2015-08-26 16:22:10 -0400 |
---|---|---|
committer | Rich Salz <rsalz@openssl.org> | 2015-09-02 23:03:43 -0400 |
commit | 3a3cb629d9ef66639198f6130f58e30f0606adc8 (patch) | |
tree | 72c9c8736c4ef32d007b3029728a771c4b79dbf1 /crypto/o_time.c | |
parent | b51bce942023325e727ca4225252d06c49d8f2b7 (diff) |
Check OPENSSL_gmtime_diff
It's test code that only runs on 64bit time_t machines.
Move it to a standalone test/gmdifftest
Reviewed-by: Richard Levitte <levitte@openssl.org>
Diffstat (limited to 'crypto/o_time.c')
-rw-r--r-- | crypto/o_time.c | 60 |
1 files changed, 0 insertions, 60 deletions
diff --git a/crypto/o_time.c b/crypto/o_time.c index 4e3dff3cbe..3bd2748bae 100644 --- a/crypto/o_time.c +++ b/crypto/o_time.c @@ -378,63 +378,3 @@ static void julian_to_date(long jd, int *y, int *m, int *d) *m = j + 2 - (12 * L); *y = 100 * (n - 49) + i + L; } - -#ifdef OPENSSL_TIME_TEST - -# include <stdio.h> - -/* - * Time checking test code. Check times are identical for a wide range of - * offsets. This should be run on a machine with 64 bit time_t or it will - * trigger the very errors the routines fix. - */ - -int main(int argc, char **argv) -{ - long offset; - for (offset = 0; offset < 1000000; offset++) { - check_time(offset); - check_time(-offset); - check_time(offset * 1000); - check_time(-offset * 1000); - } -} - -int check_time(long offset) -{ - struct tm tm1, tm2, o1; - int off_day, off_sec; - long toffset; - time_t t1, t2; - time(&t1); - t2 = t1 + offset; - OPENSSL_gmtime(&t2, &tm2); - OPENSSL_gmtime(&t1, &tm1); - o1 = tm1; - OPENSSL_gmtime_adj(&tm1, 0, offset); - if ((tm1.tm_year != tm2.tm_year) || - (tm1.tm_mon != tm2.tm_mon) || - (tm1.tm_mday != tm2.tm_mday) || - (tm1.tm_hour != tm2.tm_hour) || - (tm1.tm_min != tm2.tm_min) || (tm1.tm_sec != tm2.tm_sec)) { - fprintf(stderr, "TIME ERROR!!\n"); - fprintf(stderr, "Time1: %d/%d/%d, %d:%02d:%02d\n", - tm2.tm_mday, tm2.tm_mon + 1, tm2.tm_year + 1900, - tm2.tm_hour, tm2.tm_min, tm2.tm_sec); - fprintf(stderr, "Time2: %d/%d/%d, %d:%02d:%02d\n", - tm1.tm_mday, tm1.tm_mon + 1, tm1.tm_year + 1900, - tm1.tm_hour, tm1.tm_min, tm1.tm_sec); - return 0; - } - OPENSSL_gmtime_diff(&o1, &tm1, &off_day, &off_sec); - toffset = (long)off_day *SECS_PER_DAY + off_sec; - if (offset != toffset) { - fprintf(stderr, "TIME OFFSET ERROR!!\n"); - fprintf(stderr, "Expected %ld, Got %ld (%d:%d)\n", - offset, toffset, off_day, off_sec); - return 0; - } - return 1; -} - -#endif |