pytest_sdio.py 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. # SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD
  2. # SPDX-License-Identifier: CC0-1.0
  3. import os.path
  4. from typing import Tuple
  5. import pytest
  6. from pytest_embedded_idf import IdfDut
  7. # Normal tests
  8. def test_sdio_flow(dut:Tuple[IdfDut, IdfDut]) -> None:
  9. dut[1].expect('Press ENTER to see the list of tests')
  10. dut[1].write('[sdio]')
  11. dut[1].expect('test_sdio: slave ready')
  12. dut[0].expect('Press ENTER to see the list of tests')
  13. dut[0].write('[sdio]')
  14. dut[1].expect_unity_test_output()
  15. dut[0].expect_unity_test_output()
  16. @pytest.mark.esp32c6
  17. @pytest.mark.sdio_multidev_32_c6
  18. @pytest.mark.parametrize('count', [2,], indirect=True)
  19. @pytest.mark.parametrize('app_path, target', [
  20. pytest.param(
  21. f'{os.path.join(os.path.dirname(__file__), "host_sdmmc")}|{os.path.join(os.path.dirname(__file__), "sdio")}',
  22. 'esp32|esp32c6'),
  23. ], indirect=True)
  24. def test_sdio_esp32_esp32c6(dut:Tuple[IdfDut, IdfDut]) -> None:
  25. test_sdio_flow(dut)
  26. @pytest.mark.esp32
  27. @pytest.mark.sdio_master_slave
  28. @pytest.mark.parametrize('count', [2,], indirect=True)
  29. @pytest.mark.parametrize('app_path, target', [
  30. pytest.param(
  31. f'{os.path.join(os.path.dirname(__file__), "host_sdmmc")}|{os.path.join(os.path.dirname(__file__), "sdio")}',
  32. 'esp32|esp32'),
  33. ], indirect=True)
  34. def test_sdio_esp32_esp32(dut:Tuple[IdfDut, IdfDut]) -> None:
  35. test_sdio_flow(dut)
  36. # From host speed tests
  37. def test_sdio_speed_frhost_flow(dut:Tuple[IdfDut, IdfDut], expected_4b_speed:int, expected_1b_speed:int) -> None:
  38. dut[1].expect('Press ENTER to see the list of tests')
  39. dut[1].write('"SDIO_Slave: test from host (Performance)"')
  40. dut[1].expect('test_sdio: slave ready')
  41. dut[0].expect('Press ENTER to see the list of tests')
  42. dut[0].write('"SDIO_SDMMC: test from host (Performance)"')
  43. dut[0].expect('Probe using SD 4-bit')
  44. res = dut[0].expect(r'Throughput: compensated (\d+)')
  45. frhost_speed_4bit = res.group(1).decode('utf8')
  46. assert (int(frhost_speed_4bit) > expected_4b_speed)
  47. dut[0].expect('Probe using SD 1-bit')
  48. res = dut[0].expect(r'Throughput: compensated (\d+)')
  49. frhost_speed_1bit = res.group(1).decode('utf8')
  50. assert (int(frhost_speed_1bit) > expected_1b_speed)
  51. @pytest.mark.esp32c6
  52. @pytest.mark.sdio_multidev_32_c6
  53. @pytest.mark.parametrize('count', [2,], indirect=True)
  54. @pytest.mark.parametrize('app_path, target', [
  55. pytest.param(
  56. f'{os.path.join(os.path.dirname(__file__), "host_sdmmc")}|{os.path.join(os.path.dirname(__file__), "sdio")}',
  57. 'esp32|esp32c6'),
  58. ], indirect=True)
  59. def test_sdio_speed_frhost_esp32_esp32c6(dut:Tuple[IdfDut, IdfDut]) -> None:
  60. test_sdio_speed_frhost_flow(dut, 10000, 4000)
  61. @pytest.mark.esp32
  62. @pytest.mark.sdio_master_slave
  63. @pytest.mark.parametrize('count', [2,], indirect=True)
  64. @pytest.mark.parametrize('app_path, target', [
  65. pytest.param(
  66. f'{os.path.join(os.path.dirname(__file__), "host_sdmmc")}|{os.path.join(os.path.dirname(__file__), "sdio")}',
  67. 'esp32|esp32'),
  68. ], indirect=True)
  69. def test_sdio_speed_frhost_esp32_esp32(dut:Tuple[IdfDut, IdfDut]) -> None:
  70. test_sdio_speed_frhost_flow(dut, 12200, 4000)
  71. # To host speed tests
  72. def test_sdio_speed_tohost_flow(dut:Tuple[IdfDut, IdfDut], expected_4b_speed:int, expected_1b_speed:int) -> None:
  73. dut[1].expect('Press ENTER to see the list of tests')
  74. dut[1].write('"SDIO_Slave: test to host (Performance)"')
  75. dut[1].expect('test_sdio: slave ready')
  76. dut[0].expect('Press ENTER to see the list of tests')
  77. dut[0].write('"SDIO_SDMMC: test to host (Performance)"')
  78. dut[0].expect('Probe using SD 4-bit')
  79. res = dut[0].expect(r'Throughput: compensated (\d+)')
  80. tohost_speed_4bit = res.group(1).decode('utf8')
  81. assert (int(tohost_speed_4bit) > expected_4b_speed)
  82. dut[0].expect('Probe using SD 1-bit')
  83. res = dut[0].expect(r'Throughput: compensated (\d+)')
  84. tohost_speed_1bit = res.group(1).decode('utf8')
  85. assert (int(tohost_speed_1bit) > expected_1b_speed)
  86. @pytest.mark.esp32c6
  87. @pytest.mark.sdio_multidev_32_c6
  88. @pytest.mark.parametrize('count', [2,], indirect=True)
  89. @pytest.mark.parametrize('app_path, target', [
  90. pytest.param(
  91. f'{os.path.join(os.path.dirname(__file__), "host_sdmmc")}|{os.path.join(os.path.dirname(__file__), "sdio")}',
  92. 'esp32|esp32c6'),
  93. ], indirect=True)
  94. def test_sdio_speed_tohost_esp32_esp32c6(dut:Tuple[IdfDut, IdfDut]) -> None:
  95. test_sdio_speed_tohost_flow(dut, 9000, 4000)
  96. @pytest.mark.esp32
  97. @pytest.mark.sdio_master_slave
  98. @pytest.mark.parametrize('count', [2,], indirect=True)
  99. @pytest.mark.parametrize('app_path, target', [
  100. pytest.param(
  101. f'{os.path.join(os.path.dirname(__file__), "host_sdmmc")}|{os.path.join(os.path.dirname(__file__), "sdio")}',
  102. 'esp32|esp32'),
  103. ], indirect=True)
  104. def test_sdio_speed_tohost_esp32_esp32(dut:Tuple[IdfDut, IdfDut]) -> None:
  105. test_sdio_speed_tohost_flow(dut, 12200, 4000)