sd_card_example_test.py 1.2 KB

12345678910111213141516171819202122232425262728293031323334
  1. from tiny_test_fw import Utility
  2. import ttfw_idf
  3. import re
  4. @ttfw_idf.idf_example_test(env_tag='UT_T1_SDMODE')
  5. def test_examples_sd_card(env, extra_data):
  6. dut = env.get_dut('sd_card', 'examples/storage/sd_card')
  7. dut.start_app()
  8. dut.expect('example: Initializing SD card', timeout=20)
  9. peripheral = dut.expect(re.compile(r'example: Using (\w+) peripheral'), timeout=5)[0]
  10. Utility.console_log('peripheral {} detected'.format(peripheral))
  11. assert peripheral in ('SDMMC', 'SPI')
  12. # These lines are matched separately because of ASCII color codes in the output
  13. name = dut.expect(re.compile(r'Name: (\w+)'), timeout=5)[0]
  14. _type = dut.expect(re.compile(r'Type: (\S+)'), timeout=5)[0]
  15. speed = dut.expect(re.compile(r'Speed: (\S+)'), timeout=5)[0]
  16. size = dut.expect(re.compile(r'Size: (\S+)'), timeout=5)[0]
  17. Utility.console_log('Card {} {} {}MHz {} found'.format(name, _type, speed, size))
  18. dut.expect_all('Opening file',
  19. 'File written',
  20. 'Renaming file',
  21. 'Reading file',
  22. "Read from file: 'Hello {}!".format(name),
  23. 'Card unmounted',
  24. timeout=5)
  25. if __name__ == '__main__':
  26. test_examples_sd_card()