From 201ca770413ef8b9780e5754023341069a9a0ab4 Mon Sep 17 00:00:00 2001 From: beck Date: Wed, 9 Nov 2022 18:11:45 +0000 Subject: [PATCH] Add tests for boundary conditions of struct tm. Struct tm is limited by it's year being an int. --- .../lib/libc/time/time_conversion/timetest.c | 126 +++++++++++++++++- 1 file changed, 125 insertions(+), 1 deletion(-) diff --git a/regress/lib/libc/time/time_conversion/timetest.c b/regress/lib/libc/time/time_conversion/timetest.c index 825315c4643..77a7cbe1151 100644 --- a/regress/lib/libc/time/time_conversion/timetest.c +++ b/regress/lib/libc/time/time_conversion/timetest.c @@ -1,4 +1,4 @@ -/* $OpenBSD: timetest.c,v 1.1 2022/11/06 12:57:08 beck Exp $ */ +/* $OpenBSD: timetest.c,v 1.2 2022/11/09 18:11:45 beck Exp $ */ /* * Copyright (c) 2022 Bob Beck @@ -764,6 +764,130 @@ struct timetest timetests[] = { .tm_zone="FAILURE" }, }, + { + .descr="maxint struct tm", + .timezone="right/America/Edmonton", + .time=67767976204675199, + .local_tm= { + .tm_year=2147481747, + .tm_mon=0, + .tm_mday=31, + .tm_hour=16, + .tm_min=59, + .tm_sec=32, + .tm_wday=4, + .tm_yday=30, + .tm_isdst=0, + .tm_gmtoff=-25200, + .tm_zone="MST" + }, + .gmt_tm= { + .tm_year=2147481747, + .tm_mon=0, + .tm_mday=31, + .tm_hour=23, + .tm_min=59, + .tm_sec=59, + .tm_wday=4, + .tm_yday=30, + .tm_isdst=0, + .tm_gmtoff=0, + .tm_zone="GMT" + }, + }, + { + .descr="minint struct tm", + .timezone="right/America/Edmonton", + .time=-67768038398073601, + .local_tm= { + .tm_year=-2147483578, + .tm_mon=0, + .tm_mday=31, + .tm_hour=16, + .tm_min=26, + .tm_sec=7, + .tm_wday=2, + .tm_yday=30, + .tm_isdst=0, + .tm_gmtoff=-27232, + .tm_zone="LMT" + }, + .gmt_tm= { + .tm_year=-2147483578, + .tm_mon=0, + .tm_mday=31, + .tm_hour=23, + .tm_min=59, + .tm_sec=59, + .tm_wday=2, + .tm_yday=30, + .tm_isdst=0, + .tm_gmtoff=0, + .tm_zone="GMT" + }, + }, + { + .descr="maxint struct tm", + .timezone="right/UTC", + .time=67767976204675199, + .local_tm= { + .tm_year=2147481747, + .tm_mon=0, + .tm_mday=31, + .tm_hour=23, + .tm_min=59, + .tm_sec=32, + .tm_wday=4, + .tm_yday=30, + .tm_isdst=0, + .tm_gmtoff=0, + .tm_zone="UTC" + }, + .gmt_tm= { + .tm_year=2147481747, + .tm_mon=0, + .tm_mday=31, + .tm_hour=23, + .tm_min=59, + .tm_sec=59, + .tm_wday=4, + .tm_yday=30, + .tm_isdst=0, + .tm_gmtoff=0, + .tm_zone="GMT" + }, + }, + { + .descr="minint struct tm", + .timezone="right/UTC", + .time=-67768038398073601, + .local_tm= { + .tm_year=-2147483578, + .tm_mon=0, + .tm_mday=31, + .tm_hour=23, + .tm_min=59, + .tm_sec=59, + .tm_wday=2, + .tm_yday=30, + .tm_isdst=0, + .tm_gmtoff=0, + .tm_zone="UTC" + }, + .gmt_tm= { + .tm_year=-2147483578, + .tm_mon=0, + .tm_mday=31, + .tm_hour=23, + .tm_min=59, + .tm_sec=59, + .tm_wday=2, + .tm_yday=30, + .tm_isdst=0, + .tm_gmtoff=0, + .tm_zone="GMT" + }, + }, { .descr="0000", .timezone="posix/America/Edmonton", -- 2.20.1