iPXE
Data Structures | Macros | Functions | Variables
time_test.c File Reference

Date and time self-tests. More...

#include <time.h>
#include <ipxe/test.h>

Go to the source code of this file.

Data Structures

struct  mktime_test
 A mktime() test. More...
 

Macros

#define MKTIME_TEST(name, SEC, MIN, HOUR, MDAY, MON, YEAR, WDAY, YDAY, ISDST, TIME)
 Define a mktime() test. More...
 
#define mktime_ok(test)
 Report mktime() test result. More...
 

Functions

 FILE_LICENCE (GPL2_OR_LATER_OR_UBDL)
 
 MKTIME_TEST (mktime_epoch, 00, 00, 00, 01, 00, 70, 4, 0, 0, 0)
 
 MKTIME_TEST (mktime_ipxe, 01, 15, 20, 19, 03, 110, 1, 108, 0, 1271708101ULL)
 
 MKTIME_TEST (mktime_0, 4, 17, 20, 1, 0, 150, 6, 0, 0, 2524681024ULL)
 
 MKTIME_TEST (mktime_1, 22, 47, 21, 27, 11, 77, 2, 360, 0, 252107242ULL)
 
 MKTIME_TEST (mktime_2, 26, 10, 0, 7, 2, 196, 3, 66, 0, 3981917426ULL)
 
 MKTIME_TEST (mktime_3, 44, 44, 23, 15, 9, 261, 4, 287, 0, 6052319084ULL)
 
 MKTIME_TEST (mktime_4, 3, 22, 18, 8, 9, 296, 6, 281, 0, 7156232523ULL)
 
 MKTIME_TEST (mktime_5, 27, 26, 16, 18, 11, 338, 2, 351, 0, 8487649587ULL)
 
 MKTIME_TEST (mktime_6, 31, 36, 22, 3, 3, 293, 3, 92, 0, 7045310191ULL)
 
 MKTIME_TEST (mktime_7, 2, 0, 6, 25, 5, 289, 4, 175, 0, 6926191202ULL)
 
 MKTIME_TEST (mktime_8, 43, 50, 1, 8, 0, 210, 3, 7, 0, 4418589043ULL)
 
 MKTIME_TEST (mktime_9, 48, 14, 20, 23, 3, 86, 3, 112, 0, 514671288ULL)
 
 MKTIME_TEST (mktime_10, 4, 43, 5, 29, 11, 173, 5, 362, 0, 3281751784ULL)
 
 MKTIME_TEST (mktime_11, 47, 26, 21, 12, 7, 177, 4, 223, 0, 3396029207ULL)
 
 MKTIME_TEST (mktime_12, 18, 55, 20, 26, 11, 88, 1, 360, 0, 599172918ULL)
 
 MKTIME_TEST (mktime_13, 8, 32, 13, 15, 7, 314, 1, 226, 0, 7719456728ULL)
 
 MKTIME_TEST (mktime_14, 0, 16, 11, 20, 6, 138, 2, 200, 0, 2163237360ULL)
 
 MKTIME_TEST (mktime_15, 48, 0, 9, 31, 2, 202, 5, 89, 0, 4173238848ULL)
 
 MKTIME_TEST (mktime_16, 51, 55, 0, 15, 1, 323, 6, 45, 0, 7987769751ULL)
 
 MKTIME_TEST (mktime_17, 36, 10, 7, 11, 5, 301, 4, 161, 0, 7303590636ULL)
 
 MKTIME_TEST (mktime_18, 22, 39, 11, 21, 9, 233, 3, 293, 0, 5169181162ULL)
 
 MKTIME_TEST (mktime_19, 48, 29, 8, 31, 7, 207, 3, 242, 0, 4344222588ULL)
 
 MKTIME_TEST (mktime_20, 4, 53, 22, 8, 8, 165, 2, 250, 0, 3019675984ULL)
 
 MKTIME_TEST (mktime_21, 14, 16, 8, 10, 5, 298, 0, 160, 0, 7208900174ULL)
 
 MKTIME_TEST (mktime_22, 10, 35, 3, 12, 3, 188, 1, 102, 0, 3732579310ULL)
 
 MKTIME_TEST (mktime_23, 47, 12, 18, 22, 2, 103, 6, 80, 0, 1048356767ULL)
 
 MKTIME_TEST (mktime_24, 23, 29, 17, 23, 10, 201, 3, 326, 0, 4162210163ULL)
 
 MKTIME_TEST (mktime_25, 58, 35, 23, 24, 3, 111, 0, 113, 0, 1303688158ULL)
 
 MKTIME_TEST (mktime_26, 34, 56, 15, 24, 11, 154, 4, 357, 0, 2681740594ULL)
 
 MKTIME_TEST (mktime_27, 7, 11, 22, 28, 1, 243, 4, 58, 0, 5464447867ULL)
 
 MKTIME_TEST (mktime_28, 25, 45, 23, 29, 11, 90, 6, 362, 0, 662514325ULL)
 
 MKTIME_TEST (mktime_29, 31, 20, 12, 24, 1, 146, 6, 54, 0, 2403087631ULL)
 
 MKTIME_TEST (mktime_30, 49, 7, 18, 16, 10, 271, 6, 319, 0, 6370596469ULL)
 
 MKTIME_TEST (mktime_31, 31, 55, 2, 25, 5, 141, 2, 175, 0, 2255741731ULL)
 
static void time_test_exec (void)
 Perform date and time self-tests. More...
 

Variables

struct self_test time_test __self_test
 Date and time self-test. More...
 

Detailed Description

Date and time self-tests.

Definition in file time_test.c.

Macro Definition Documentation

◆ MKTIME_TEST

#define MKTIME_TEST (   name,
  SEC,
  MIN,
  HOUR,
  MDAY,
  MON,
  YEAR,
  WDAY,
  YDAY,
  ISDST,
  TIME 
)
Value:
static struct mktime_test name = { \
.tm = { \
.tm_sec = SEC, \
.tm_min = MIN, \
.tm_hour = HOUR, \
.tm_mday = MDAY, \
.tm_mon = MON, \
.tm_year = YEAR, \
.tm_isdst = ISDST, \
}, \
.wday = WDAY, \
.yday = YDAY, \
.time = TIME, \
}
const char * name
Definition: ath9k_hw.c:1984
A mktime() test.
Definition: time_test.c:39
#define MIN(a, b)
Definition: sfc_hunt.c:44

Define a mktime() test.

Parameters
nameTest name
SECSeconds [0,60]
MINMinutes [0,59]
HOURHour [0,23]
MDAYDay of month [1,31]
MONMonth of year [0,11]
YEARYears since 1900
WDAYDay of week [0,6] (Sunday=0)
YDAYDay of year [0,365]
ISDSTDaylight savings flag (ignored)
TIMESeconds since the Epoch
Return values
testmktime() test

This macro is designed to make it easy to generate test vectors in Perl using

print join ", ", gmtime ( $time ), $time."ULL";

Definition at line 72 of file time_test.c.

◆ mktime_ok

#define mktime_ok (   test)
Value:
do { \
time_t time = mktime ( &(test)->tm ); \
ok ( time == (test)->time ); \
ok ( (test)->tm.tm_wday == (test)->wday ); \
ok ( (test)->tm.tm_yday == (test)->yday ); \
} while ( 0 )
time_t mktime(struct tm *tm)
Calculate seconds since the Epoch.
Definition: time.c:117
Broken-down time.
Definition: time.h:15
int tm_wday
Day of week [0,6] (Sunday=0)
Definition: time.h:29
int tm_yday
Day of year [0,365].
Definition: time.h:31
uint64_t time
Current time.
Definition: ntlm.h:20
static int test
Definition: epic100.c:73

Report mktime() test result.

Parameters
testmktime() test

Definition at line 94 of file time_test.c.

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL  )

◆ MKTIME_TEST() [1/34]

MKTIME_TEST ( mktime_epoch  ,
00  ,
00  ,
00  ,
01  ,
00  ,
70  ,
,
,
,
 
)

◆ MKTIME_TEST() [2/34]

MKTIME_TEST ( mktime_ipxe  ,
01  ,
15  ,
20  ,
19  ,
03  ,
110  ,
,
108  ,
,
1271708101ULL   
)

◆ MKTIME_TEST() [3/34]

MKTIME_TEST ( mktime_0  ,
,
17  ,
20  ,
,
,
150  ,
,
,
,
2524681024ULL   
)

◆ MKTIME_TEST() [4/34]

MKTIME_TEST ( mktime_1  ,
22  ,
47  ,
21  ,
27  ,
11  ,
77  ,
,
360  ,
,
252107242ULL   
)

◆ MKTIME_TEST() [5/34]

MKTIME_TEST ( mktime_2  ,
26  ,
10  ,
,
,
,
196  ,
,
66  ,
,
3981917426ULL   
)

◆ MKTIME_TEST() [6/34]

MKTIME_TEST ( mktime_3  ,
44  ,
44  ,
23  ,
15  ,
,
261  ,
,
287  ,
,
6052319084ULL   
)

◆ MKTIME_TEST() [7/34]

MKTIME_TEST ( mktime_4  ,
,
22  ,
18  ,
,
,
296  ,
,
281  ,
,
7156232523ULL   
)

◆ MKTIME_TEST() [8/34]

MKTIME_TEST ( mktime_5  ,
27  ,
26  ,
16  ,
18  ,
11  ,
338  ,
,
351  ,
,
8487649587ULL   
)

◆ MKTIME_TEST() [9/34]

MKTIME_TEST ( mktime_6  ,
31  ,
36  ,
22  ,
,
,
293  ,
,
92  ,
,
7045310191ULL   
)

◆ MKTIME_TEST() [10/34]

MKTIME_TEST ( mktime_7  ,
,
,
,
25  ,
,
289  ,
,
175  ,
,
6926191202ULL   
)

◆ MKTIME_TEST() [11/34]

MKTIME_TEST ( mktime_8  ,
43  ,
50  ,
,
,
,
210  ,
,
,
,
4418589043ULL   
)

◆ MKTIME_TEST() [12/34]

MKTIME_TEST ( mktime_9  ,
48  ,
14  ,
20  ,
23  ,
,
86  ,
,
112  ,
,
514671288ULL   
)

◆ MKTIME_TEST() [13/34]

MKTIME_TEST ( mktime_10  ,
,
43  ,
,
29  ,
11  ,
173  ,
,
362  ,
,
3281751784ULL   
)

◆ MKTIME_TEST() [14/34]

MKTIME_TEST ( mktime_11  ,
47  ,
26  ,
21  ,
12  ,
,
177  ,
,
223  ,
,
3396029207ULL   
)

◆ MKTIME_TEST() [15/34]

MKTIME_TEST ( mktime_12  ,
18  ,
55  ,
20  ,
26  ,
11  ,
88  ,
,
360  ,
,
599172918ULL   
)

◆ MKTIME_TEST() [16/34]

MKTIME_TEST ( mktime_13  ,
,
32  ,
13  ,
15  ,
,
314  ,
,
226  ,
,
7719456728ULL   
)

◆ MKTIME_TEST() [17/34]

MKTIME_TEST ( mktime_14  ,
,
16  ,
11  ,
20  ,
,
138  ,
,
200  ,
,
2163237360ULL   
)

◆ MKTIME_TEST() [18/34]

MKTIME_TEST ( mktime_15  ,
48  ,
,
,
31  ,
,
202  ,
,
89  ,
,
4173238848ULL   
)

◆ MKTIME_TEST() [19/34]

MKTIME_TEST ( mktime_16  ,
51  ,
55  ,
,
15  ,
,
323  ,
,
45  ,
,
7987769751ULL   
)

◆ MKTIME_TEST() [20/34]

MKTIME_TEST ( mktime_17  ,
36  ,
10  ,
,
11  ,
,
301  ,
,
161  ,
,
7303590636ULL   
)

◆ MKTIME_TEST() [21/34]

MKTIME_TEST ( mktime_18  ,
22  ,
39  ,
11  ,
21  ,
,
233  ,
,
293  ,
,
5169181162ULL   
)

◆ MKTIME_TEST() [22/34]

MKTIME_TEST ( mktime_19  ,
48  ,
29  ,
,
31  ,
,
207  ,
,
242  ,
,
4344222588ULL   
)

◆ MKTIME_TEST() [23/34]

MKTIME_TEST ( mktime_20  ,
,
53  ,
22  ,
,
,
165  ,
,
250  ,
,
3019675984ULL   
)

◆ MKTIME_TEST() [24/34]

MKTIME_TEST ( mktime_21  ,
14  ,
16  ,
,
10  ,
,
298  ,
,
160  ,
,
7208900174ULL   
)

◆ MKTIME_TEST() [25/34]

MKTIME_TEST ( mktime_22  ,
10  ,
35  ,
,
12  ,
,
188  ,
,
102  ,
,
3732579310ULL   
)

◆ MKTIME_TEST() [26/34]

MKTIME_TEST ( mktime_23  ,
47  ,
12  ,
18  ,
22  ,
,
103  ,
,
80  ,
,
1048356767ULL   
)

◆ MKTIME_TEST() [27/34]

MKTIME_TEST ( mktime_24  ,
23  ,
29  ,
17  ,
23  ,
10  ,
201  ,
,
326  ,
,
4162210163ULL   
)

◆ MKTIME_TEST() [28/34]

MKTIME_TEST ( mktime_25  ,
58  ,
35  ,
23  ,
24  ,
,
111  ,
,
113  ,
,
1303688158ULL   
)

◆ MKTIME_TEST() [29/34]

MKTIME_TEST ( mktime_26  ,
34  ,
56  ,
15  ,
24  ,
11  ,
154  ,
,
357  ,
,
2681740594ULL   
)

◆ MKTIME_TEST() [30/34]

MKTIME_TEST ( mktime_27  ,
,
11  ,
22  ,
28  ,
,
243  ,
,
58  ,
,
5464447867ULL   
)

◆ MKTIME_TEST() [31/34]

MKTIME_TEST ( mktime_28  ,
25  ,
45  ,
23  ,
29  ,
11  ,
90  ,
,
362  ,
,
662514325ULL   
)

◆ MKTIME_TEST() [32/34]

MKTIME_TEST ( mktime_29  ,
31  ,
20  ,
12  ,
24  ,
,
146  ,
,
54  ,
,
2403087631ULL   
)

◆ MKTIME_TEST() [33/34]

MKTIME_TEST ( mktime_30  ,
49  ,
,
18  ,
16  ,
10  ,
271  ,
,
319  ,
,
6370596469ULL   
)

◆ MKTIME_TEST() [34/34]

MKTIME_TEST ( mktime_31  ,
31  ,
55  ,
,
25  ,
,
141  ,
,
175  ,
,
2255741731ULL   
)

◆ time_test_exec()

static void time_test_exec ( void  )
static

Perform date and time self-tests.

Definition at line 145 of file time_test.c.

145  {
146 
147  mktime_ok ( &mktime_epoch );
148  mktime_ok ( &mktime_ipxe );
149  mktime_ok ( &mktime_0 );
150  mktime_ok ( &mktime_1 );
151  mktime_ok ( &mktime_2 );
152  mktime_ok ( &mktime_3 );
153  mktime_ok ( &mktime_4 );
154  mktime_ok ( &mktime_5 );
155  mktime_ok ( &mktime_6 );
156  mktime_ok ( &mktime_7 );
157  mktime_ok ( &mktime_8 );
158  mktime_ok ( &mktime_9 );
159  mktime_ok ( &mktime_10 );
160  mktime_ok ( &mktime_11 );
161  mktime_ok ( &mktime_12 );
162  mktime_ok ( &mktime_13 );
163  mktime_ok ( &mktime_14 );
164  mktime_ok ( &mktime_15 );
165  mktime_ok ( &mktime_16 );
166  mktime_ok ( &mktime_17 );
167  mktime_ok ( &mktime_18 );
168  mktime_ok ( &mktime_19 );
169  mktime_ok ( &mktime_20 );
170  mktime_ok ( &mktime_21 );
171  mktime_ok ( &mktime_22 );
172  mktime_ok ( &mktime_23 );
173  mktime_ok ( &mktime_24 );
174  mktime_ok ( &mktime_25 );
175  mktime_ok ( &mktime_26 );
176  mktime_ok ( &mktime_27 );
177  mktime_ok ( &mktime_28 );
178  mktime_ok ( &mktime_29 );
179  mktime_ok ( &mktime_30 );
180  mktime_ok ( &mktime_31 );
181 }
#define mktime_ok(test)
Report mktime() test result.
Definition: time_test.c:94

References mktime_ok.

Variable Documentation

◆ __self_test

struct self_test time_test __self_test
Initial value:
= {
.name = "time",
.exec = time_test_exec,
}
static void time_test_exec(void)
Perform date and time self-tests.
Definition: time_test.c:145

Date and time self-test.

Definition at line 184 of file time_test.c.