example_test.py 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. from __future__ import unicode_literals
  2. import re
  3. import tiny_test_fw
  4. import ttfw_idf
  5. from tiny_test_fw import DUT
  6. @ttfw_idf.idf_example_test(env_tag='Example_GENERIC', target=['esp32s2'])
  7. def test_examples_ulp_riscv(env, extra_data): # type: (tiny_test_fw.Env.Env, None) -> None # pylint: disable=unused-argument
  8. dut = env.get_dut('ulp_riscv', 'examples/system/ulp_riscv/gpio')
  9. dut.start_app()
  10. dut.expect_all('Not a ULP-RISC-V wakeup, initializing it!',
  11. 'Entering in deep sleep',
  12. timeout=30)
  13. # Run two times to make sure device sleep
  14. # and wake up properly
  15. for i in range(0, 2):
  16. # Set GPIO0 using DTR
  17. dut.port_inst.setDTR(i % 2 == 0)
  18. dut.expect('ULP-RISC-V woke up the main CPU!', timeout=5)
  19. # Check GPIO state
  20. state = 'Low' if i % 2 == 0 else 'High'
  21. dut.expect(re.compile(r'ULP-RISC-V read changes in GPIO_0 current is: %s' % state), timeout=5)
  22. # Go back to sleep
  23. dut.expect('Entering in deep sleep', timeout=5)
  24. try:
  25. # We expect a timeout here, otherwise it means that
  26. # the main CPU woke up unexpectedly!
  27. dut.expect('ULP-RISC-V woke up the main CPU!', timeout=20)
  28. raise Exception('Main CPU woke up unexpectedly!')
  29. except DUT.ExpectTimeout:
  30. pass
  31. if __name__ == '__main__':
  32. test_examples_ulp_riscv()