example_test.py 1.1 KB

12345678910111213141516171819202122232425262728293031323334
  1. from __future__ import unicode_literals
  2. import re
  3. import ttfw_idf
  4. from tiny_test_fw import Utility
  5. @ttfw_idf.idf_example_test(env_tag='Example_GENERIC', target=['esp32'])
  6. def test_examples_ulp_adc(env, extra_data):
  7. dut = env.get_dut('ulp_adc', 'examples/system/ulp_adc')
  8. dut.start_app()
  9. dut.expect_all('Not ULP wakeup',
  10. 'Entering deep sleep',
  11. timeout=30)
  12. for _ in range(5):
  13. dut.expect('Deep sleep wakeup', timeout=60)
  14. measurements_str = dut.expect(re.compile(r'ULP did (\d+) measurements'), timeout=5)[0]
  15. assert measurements_str is not None
  16. measurements = int(measurements_str)
  17. Utility.console_log('ULP did {} measurements'.format(measurements))
  18. dut.expect('Thresholds: low=1500 high=2000', timeout=5)
  19. value_str = dut.expect(re.compile(r'Value=(\d+) was (above|below) threshold'), timeout=5)[0]
  20. assert value_str is not None
  21. value = int(value_str)
  22. Utility.console_log('Value {} was outside the boundaries'.format(value))
  23. dut.expect('Entering deep sleep', timeout=60)
  24. if __name__ == '__main__':
  25. test_examples_ulp_adc()