posix-test:fix times test
Applications should use sysconf(_SC_CLK_TCK) to determine the number of clock ticks per second as it may vary from system to system.
This commit is contained in:
parent
a9db0ea184
commit
88c79fc9e9
1 changed files with 4 additions and 1 deletions
|
@ -318,11 +318,14 @@ void test2g()
|
||||||
|
|
||||||
time_t t1, t2;
|
time_t t1, t2;
|
||||||
clock_t t3, t4;
|
clock_t t3, t4;
|
||||||
|
long clocks_per_sec;
|
||||||
struct tms tmsbuf;
|
struct tms tmsbuf;
|
||||||
|
|
||||||
subtest = 7;
|
subtest = 7;
|
||||||
errno = -7000;
|
errno = -7000;
|
||||||
|
|
||||||
|
clocks_per_sec = sysconf(_SC_CLK_TCK);
|
||||||
|
|
||||||
/* First time(). */
|
/* First time(). */
|
||||||
t1 = -1;
|
t1 = -1;
|
||||||
t2 = -2;
|
t2 = -2;
|
||||||
|
@ -341,7 +344,7 @@ void test2g()
|
||||||
/* Now times(). */
|
/* Now times(). */
|
||||||
t4 = times(&tmsbuf);
|
t4 = times(&tmsbuf);
|
||||||
if ( t4 == (clock_t) -1) e(6);
|
if ( t4 == (clock_t) -1) e(6);
|
||||||
if (t4 - t3 < CLOCKS_PER_SEC) e(7);
|
if (t4 - t3 < clocks_per_sec) e(7);
|
||||||
if (tmsbuf.tms_utime < 0) e(8);
|
if (tmsbuf.tms_utime < 0) e(8);
|
||||||
if (tmsbuf.tms_stime < 0) e(9);
|
if (tmsbuf.tms_stime < 0) e(9);
|
||||||
if (tmsbuf.tms_cutime < 0) e(10);
|
if (tmsbuf.tms_cutime < 0) e(10);
|
||||||
|
|
Loading…
Reference in a new issue