pytest_emmc_example.py 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. # SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD
  2. # SPDX-License-Identifier: Unlicense OR CC0-1.0
  3. import logging
  4. import re
  5. import pytest
  6. from pytest_embedded import Dut
  7. @pytest.mark.esp32s3
  8. @pytest.mark.emmc
  9. @pytest.mark.parametrize(
  10. 'config',
  11. [
  12. '1line',
  13. '4line',
  14. '8line',
  15. ],
  16. indirect=True,
  17. )
  18. def test_examples_sd_card_sdmmc(dut: Dut) -> None:
  19. dut.expect('example: Initializing eMMC', timeout=20)
  20. dut.expect('example: Using SDMMC peripheral', timeout=10)
  21. # Provide enough time for possible SD card formatting
  22. dut.expect('Filesystem mounted', timeout=60)
  23. # These lines are matched separately because of ASCII color codes in the output
  24. name = dut.expect(re.compile(rb'Name: (\w+)\r'), timeout=10).group(1).decode()
  25. _type = dut.expect(re.compile(rb'Type: (\S+)'), timeout=10).group(1).decode()
  26. speed = dut.expect(re.compile(rb'Speed: (\S+)'), timeout=10).group(1).decode()
  27. size = dut.expect(re.compile(rb'Size: (\S+)'), timeout=10).group(1).decode()
  28. logging.info('Card {} {} {}MHz {} found'.format(name, _type, speed, size))
  29. message_list = ('Opening file /eMMC/hello.txt',
  30. 'File written',
  31. 'Renaming file /eMMC/hello.txt to /eMMC/foo.txt',
  32. 'Reading file /eMMC/foo.txt',
  33. "Read from file: 'Hello {}!'".format(name),
  34. 'Card unmounted')
  35. for msg in message_list:
  36. dut.expect(msg, timeout=10)