example_test.py 1.2 KB

1234567891011121314151617181920212223242526272829303132333435
  1. from __future__ import unicode_literals
  2. import re
  3. from typing import Any
  4. import ttfw_idf
  5. @ttfw_idf.idf_example_test(env_tag='Example_GENERIC')
  6. def test_examples_timergroup(env, extra_data): # type: (Any, Any) -> None
  7. dut = env.get_dut('timer_group', 'examples/peripherals/timer_group')
  8. dut.start_app()
  9. # check auto reload function
  10. with_auto_reload = dut.expect(re.compile(r'Timer Group (\S+) auto reload'), timeout=30)[0]
  11. assert with_auto_reload == 'with'
  12. select_groups = dut.expect(re.compile(r'Group\[(\d)\], timer\[(\d)\] alarm event'))
  13. timer_group_num = int(select_groups[0])
  14. timer_instance_num = int(select_groups[1])
  15. assert timer_group_num == 0 and timer_instance_num == 0
  16. dut.expect('EVENT TIME')
  17. counter_value = dut.expect(re.compile(r'Counter:\s+(0x\d+)'))[0]
  18. counter_value = int(counter_value, 16)
  19. print('counter value at auto reload event: ', counter_value)
  20. assert counter_value < 20
  21. # check timer interval
  22. dut.expect('Timer Group without auto reload', timeout=5)
  23. dut.expect('EVENT TIME')
  24. event_time0 = dut.expect(re.compile(r'Time\s+:\s+(\d+\.\d+)\s+s'))[0]
  25. print('event0={}'.format(event_time0))
  26. if __name__ == '__main__':
  27. test_examples_timergroup()