2 * Copyright (c) 2012 Your File System Inc. All rights reserved.
5 /* Some trivial tests for the very straightforwards OPR 100ns time
10 #include <afs/param.h>
14 #include <tests/tap/basic.h>
19 main(int argc
, char **argv
)
21 struct opr_time oprTime
;
22 struct timeval osTimeval
;
26 /* Check that FromSecs, then ToSecs results in the same value coming out */
28 opr_time_FromSecs(&oprTime
, 1337065355);
29 osTime
= opr_time_ToSecs(&oprTime
);
30 ok(osTime
== 1337065355, "ToSecs(FromSecs(time)) == time");
32 /* Check the FromTimeval, then ToTimeval result in the same value. Note that
33 * our chosen microseconds field is very close to overflow */
35 osTimeval
.tv_sec
= 1337065355;
36 osTimeval
.tv_usec
= 999;
37 opr_time_FromTimeval(&oprTime
, &osTimeval
);
38 opr_time_ToTimeval(&oprTime
, &osTimeval
);
39 ok(osTimeval
.tv_sec
== 1337065355 && osTimeval
.tv_usec
== 999,
40 "ToTimeval(FromTimeval(timeval) == timeval)");
42 /* Check that opr_time_Now looks reasonable */
43 is_int(0, opr_time_Now(&oprTime
), "opr_time_Now succeeds");
45 osTime
= opr_time_ToSecs(&oprTime
);
46 ok(labs(osTime
- osNow
) < 2, "opr_time_Now returns a reasonable value");