Skip to content

Commit f1ad379

Browse files
Add test case for ASN1_TIME_to_tm fix.
1 parent 6930179 commit f1ad379

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

tests/api.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33143,6 +33143,7 @@ static int test_wolfSSL_ASN1_TIME_to_tm(void)
3314333143
defined(OPENSSL_ALL)) && !defined(NO_ASN_TIME)
3314433144
ASN1_TIME asnTime;
3314533145
struct tm tm;
33146+
time_t testTime = 1683926567; /* Fri May 12 09:22:47 PM UTC 2023 */
3314633147

3314733148
XMEMSET(&asnTime, 0, sizeof(ASN1_TIME));
3314833149
AssertIntEQ(ASN1_TIME_set_string(&asnTime, "000222211515Z"), 1);
@@ -33188,6 +33189,22 @@ static int test_wolfSSL_ASN1_TIME_to_tm(void)
3318833189
AssertIntEQ(ASN1_TIME_set_string(&asnTime, "20000222211515U"), 1);
3318933190
AssertIntEQ(ASN1_TIME_to_tm(&asnTime, &tm), 0);
3319033191

33192+
#ifdef XMKTIME
33193+
AssertNotNull(ASN1_TIME_adj(&asnTime, testTime, 0, 0));
33194+
AssertIntEQ(ASN1_TIME_to_tm(&asnTime, &tm), 1);
33195+
AssertIntEQ(tm.tm_sec, 47);
33196+
AssertIntEQ(tm.tm_min, 22);
33197+
AssertIntEQ(tm.tm_hour, 21);
33198+
AssertIntEQ(tm.tm_mday, 12);
33199+
AssertIntEQ(tm.tm_mon, 4);
33200+
AssertIntEQ(tm.tm_year, 123);
33201+
AssertIntEQ(tm.tm_wday, 5);
33202+
AssertIntEQ(tm.tm_yday, 131);
33203+
/* Confirm that when used with a tm struct from ASN1_TIME_adj, all other
33204+
fields are zeroed out as expected. */
33205+
AssertIntEQ(tm.tm_isdst, 0);
33206+
#endif
33207+
3319133208
res = TEST_RES_CHECK(1);
3319233209
#endif
3319333210
return res;

0 commit comments

Comments
 (0)