Skip to content

Commit c6bbf4d

Browse files
Hieu Nguyenkartben
authored andcommitted
tests: counter: Handle zero tick_us for very short timer ticks
Ensure tick_us is at least 1 for very short timer ticks Signed-off-by: Hieu Nguyen <[email protected]> Signed-off-by: Tien Nguyen <[email protected]>
1 parent 34d863a commit c6bbf4d

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

tests/drivers/counter/counter_basic_api/src/test_counter.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -819,6 +819,9 @@ static void test_late_alarm_instance(const struct device *dev)
819819
.user_data = NULL
820820
};
821821

822+
/* for timers with very short ticks, counter_ticks_to_us() returns 0 */
823+
tick_us = MAX(tick_us, 1);
824+
822825
err = counter_set_guard_period(dev, guard,
823826
COUNTER_GUARD_PERIOD_LATE_TO_SET);
824827
zassert_equal(0, err, "%s: Unexpected error", dev->name);
@@ -870,6 +873,9 @@ static void test_late_alarm_error_instance(const struct device *dev)
870873
.user_data = NULL
871874
};
872875

876+
/* for timers with very short ticks, counter_ticks_to_us() returns 0 */
877+
tick_us = MAX(tick_us, 1);
878+
873879
err = counter_set_guard_period(dev, guard,
874880
COUNTER_GUARD_PERIOD_LATE_TO_SET);
875881
zassert_equal(0, err, "%s: Unexpected error", dev->name);

0 commit comments

Comments
 (0)