tests: timer_api: Fix duplicate timestamp update.

Remove duplicate "tdata.timestamp" update in duration_expire; this
value is already updated by k_uptime_delta.

Besides simply removing duplicate value update, this commit also
addresses the intermittent assertion failure that is caused by
updating "tdata.timestamp" at a later time than the actual execution
of the k_uptime_delta function.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
This commit is contained in:
Stephanos Ioannidis 2019-10-02 16:53:44 +09:00 committed by Anas Nashif
commit b3d6ac2e37

View file

@ -55,15 +55,15 @@ static void init_timer_data(void)
static void duration_expire(struct k_timer *timer)
{
/** TESTPOINT: expire function */
s64_t interval = k_uptime_delta(&tdata.timestamp);
tdata.expire_cnt++;
if (tdata.expire_cnt == 1) {
TIMER_ASSERT(k_uptime_delta(&tdata.timestamp) >= DURATION,
timer);
TIMER_ASSERT(interval >= DURATION, timer);
} else {
TIMER_ASSERT(k_uptime_delta(&tdata.timestamp) >= PERIOD, timer);
TIMER_ASSERT(interval >= PERIOD, timer);
}
tdata.timestamp = k_uptime_get();
if (tdata.expire_cnt >= EXPIRE_TIMES) {
k_timer_stop(timer);
}