mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
timer_group: added example test
This commit is contained in:
parent
fcbde13755
commit
089801cd7f
39
examples/peripherals/timer_group/example_test.py
Normal file
39
examples/peripherals/timer_group/example_test.py
Normal file
@ -0,0 +1,39 @@
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import re
|
||||
from typing import Any
|
||||
|
||||
import ttfw_idf
|
||||
|
||||
|
||||
@ttfw_idf.idf_example_test(env_tag='Example_GENERIC')
|
||||
def test_examples_timergroup(env, extra_data): # type: (Any, Any) -> None
|
||||
dut = env.get_dut('timer_group', 'examples/peripherals/timer_group')
|
||||
dut.start_app()
|
||||
|
||||
# check auto reload function
|
||||
with_auto_reload = dut.expect(re.compile(r'Timer Group (\S+) auto reload'), timeout=30)[0]
|
||||
assert with_auto_reload == 'with'
|
||||
select_groups = dut.expect(re.compile(r'Group\[(\d)\], timer\[(\d)\] alarm event'))
|
||||
timer_group_num = int(select_groups[0])
|
||||
timer_instance_num = int(select_groups[1])
|
||||
assert timer_group_num == 0 and timer_instance_num == 0
|
||||
dut.expect('EVENT TIME')
|
||||
counter_value = dut.expect(re.compile(r'Counter:\s+(0x\d+)'))[0]
|
||||
counter_value = int(counter_value, 16)
|
||||
print('counter value at auto reload event: ', counter_value)
|
||||
assert counter_value < 20
|
||||
|
||||
# check timer interval
|
||||
dut.expect('Timer Group without auto reload', timeout=5)
|
||||
dut.expect('EVENT TIME')
|
||||
event_time0 = dut.expect(re.compile(r'Time\s+:\s+(\d+\.\d+)\s+s'))[0]
|
||||
dut.expect('Timer Group without auto reload', timeout=6)
|
||||
dut.expect('EVENT TIME')
|
||||
event_time1 = dut.expect(re.compile(r'Time\s+:\s+(\d+\.\d+)\s+s'))[0]
|
||||
print('event0={}, event1={}'.format(event_time0, event_time1))
|
||||
assert float(event_time1) - float(event_time0) < 5.001
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
test_examples_timergroup()
|
Loading…
Reference in New Issue
Block a user