pytest_memprot.py 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. # SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD
  2. # SPDX-License-Identifier: CC0-1.0
  3. import logging
  4. import pytest
  5. from pytest_embedded import Dut
  6. MEM_TEST_UNICORE = {
  7. 'esp32s2': [
  8. ['IRAM0_SRAM', 'WRX'],
  9. ['IRAM0_RTCFAST', 'WRX'],
  10. ['DRAM0_SRAM', 'WR'],
  11. ['DRAM0_RTCFAST', 'WR'],
  12. ['PERI1_RTCSLOW', 'WR'],
  13. ['PERI2_RTCSLOW_0', 'WRX'],
  14. ['PERI2_RTCSLOW_1', 'WRX']
  15. ],
  16. 'esp32c3': [
  17. ['IRAM0_SRAM', 'WRX'],
  18. ['DRAM0_SRAM', 'WR'],
  19. ['IRAM0_RTCFAST', 'WRX']
  20. ],
  21. 'esp32s3': [
  22. ['IRAM0_SRAM (core 0)', 'WRX'],
  23. ['DRAM0_SRAM (core 0)', 'WR']
  24. # temporarily disabled unless IDF-5208 gets merged
  25. # ['IRAM0_RTCFAST', 'WR'],
  26. ],
  27. }
  28. MEM_TEST_MULTICORE = {
  29. 'esp32s3': [
  30. # instruction execute test temporarily disabled
  31. # ['IRAM0_SRAM (core 0)', 'WRX'],
  32. ['IRAM0_SRAM (core 0)', 'WR'],
  33. ['DRAM0_SRAM (core 0)', 'WR'],
  34. # instruction execute test temporarily disabled
  35. # ['IRAM0_SRAM (core 1)', 'WRX'],
  36. ['IRAM0_SRAM (core 1)', 'WR'],
  37. ['DRAM0_SRAM (core 1)', 'WR']
  38. # temporarily disabled unless IDF-5208 gets merged
  39. # ['IRAM0_RTCFAST', 'WR'],
  40. ]
  41. }
  42. @pytest.mark.esp32s2
  43. @pytest.mark.esp32s3
  44. @pytest.mark.esp32c3
  45. @pytest.mark.generic
  46. def test_sys_memprot(dut: Dut) -> None:
  47. current_target = dut.target
  48. unicore = dut.app.sdkconfig.get('FREERTOS_UNICORE')
  49. mem_test_cfg = MEM_TEST_UNICORE if unicore else MEM_TEST_MULTICORE
  50. logging.info(f'Test cfg: {current_target}')
  51. for i in mem_test_cfg[current_target]:
  52. if 'R' in i[1]:
  53. dut.expect_exact(i[0] + ' read low: OK')
  54. dut.expect_exact(i[0] + ' read high: OK')
  55. if 'W' in i[1]:
  56. dut.expect_exact(i[0] + ' write low: OK')
  57. dut.expect_exact(i[0] + ' write high: OK')
  58. if 'X' in i[1]:
  59. dut.expect_exact(i[0] + ' exec low: OK')
  60. dut.expect_exact(i[0] + ' exec high: OK')