Skip to content

Commit 0d4bfc3

Browse files
committed
tests: posix: common: clock: remove poorly conditioned tests
The test assumed initial equality between CLOCK_MONOTONIC and CLOCK_REALTIME and also assumed coarse granularity for each clock. Neither of those assumptions are solid. Furthermore, the test failed on multiple vendor boards which caused some concern. Remove the poorly conditioned tests and remove some comments / printks. Fixes zephyrproject-rtos#35703 Signed-off-by: Christopher Friedt <[email protected]>
1 parent ebfb239 commit 0d4bfc3

File tree

1 file changed

+0
-20
lines changed

1 file changed

+0
-20
lines changed

tests/posix/common/src/clock.c

-20
Original file line numberDiff line numberDiff line change
@@ -46,34 +46,16 @@ void test_posix_clock(void)
4646

4747
void test_posix_realtime(void)
4848
{
49-
/* Make sure the realtime and monotonic clocks start out the
50-
* same. This is not true on posix and where there is a
51-
* realtime clock, so don't keep this code.
52-
*/
53-
5449
int ret;
5550
struct timespec rts, mts;
5651
struct timeval tv;
5752

58-
printk("POSIX clock set APIs\n");
59-
60-
/* Minimal sleep to align us to the next tick interval. This
61-
* helps with a case that 2 consecutive calls to clock_gettime()
62-
* below return different values. Note that the tick alignment
63-
* approach may break, in which case follow the suggestion in the
64-
* comment above.
65-
*/
66-
k_usleep(1);
67-
6853
ret = clock_gettime(CLOCK_MONOTONIC, &mts);
6954
zassert_equal(ret, 0, "Fail to get monotonic clock");
7055

7156
ret = clock_gettime(CLOCK_REALTIME, &rts);
7257
zassert_equal(ret, 0, "Fail to get realtime clock");
7358

74-
zassert_equal(rts.tv_sec, mts.tv_sec, "Seconds not equal");
75-
zassert_equal(rts.tv_nsec, mts.tv_nsec, "Nanoseconds not equal");
76-
7759
/* Set a particular time. In this case, the output of:
7860
* `date +%s -d 2018-01-01T15:45:01Z`
7961
*/
@@ -141,6 +123,4 @@ void test_posix_realtime(void)
141123
" provide correct result");
142124
zassert_true(rts.tv_nsec >= tv.tv_usec * NSEC_PER_USEC,
143125
"gettimeofday didn't provide correct result");
144-
145-
printk("POSIX clock set APIs test done\n");
146126
}

0 commit comments

Comments
 (0)