pytest_heap.py 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. # SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD
  2. # SPDX-License-Identifier: CC0-1.0
  3. import pytest
  4. from pytest_embedded import Dut
  5. @pytest.mark.generic
  6. @pytest.mark.supported_targets
  7. @pytest.mark.nightly_run
  8. @pytest.mark.parametrize(
  9. 'config',
  10. [
  11. 'no_poisoning',
  12. 'light_poisoning',
  13. 'comprehensive_poisoning',
  14. ]
  15. )
  16. def test_heap_poisoning(dut: Dut) -> None:
  17. dut.run_all_single_board_cases()
  18. @pytest.mark.esp32
  19. @pytest.mark.esp32c3
  20. @pytest.mark.host_test
  21. @pytest.mark.qemu
  22. @pytest.mark.parametrize(
  23. 'config, embedded_services',
  24. [
  25. ('no_poisoning', 'idf,qemu'),
  26. ('light_poisoning', 'idf,qemu'),
  27. ('comprehensive_poisoning', 'idf,qemu')
  28. ]
  29. )
  30. def test_heap_poisoning_qemu(dut: Dut) -> None:
  31. for case in dut.test_menu:
  32. if 'qemu-ignore' not in case.groups and not case.is_ignored and case.type == 'normal':
  33. dut._run_normal_case(case)
  34. @pytest.mark.generic
  35. @pytest.mark.supported_targets
  36. @pytest.mark.parametrize(
  37. 'config',
  38. [
  39. 'in_flash'
  40. ]
  41. )
  42. def test_heap_in_flash(dut: Dut) -> None:
  43. dut.run_all_single_board_cases()
  44. @pytest.mark.generic
  45. @pytest.mark.esp32
  46. @pytest.mark.esp32s2
  47. @pytest.mark.esp32s3
  48. @pytest.mark.parametrize(
  49. 'config',
  50. [
  51. 'psram',
  52. 'psram_all_ext'
  53. ]
  54. )
  55. def test_heap(dut: Dut) -> None:
  56. dut.run_all_single_board_cases()
  57. @pytest.mark.generic
  58. @pytest.mark.esp32
  59. @pytest.mark.parametrize(
  60. 'config',
  61. [
  62. 'misc_options'
  63. ]
  64. )
  65. def test_heap_misc_options(dut: Dut) -> None:
  66. dut.expect_exact('Press ENTER to see the list of tests')
  67. dut.write('"IRAM_8BIT capability test"')
  68. dut.expect_unity_test_output()
  69. dut.expect_exact("Enter next test, or 'enter' to see menu")
  70. dut.write('"test allocation and free function hooks"')
  71. dut.expect_unity_test_output()
  72. dut.expect_exact("Enter next test, or 'enter' to see menu")
  73. dut.write('"When enabled, allocation operation failure generates an abort"')
  74. dut.expect('Backtrace: ')
  75. @pytest.mark.generic
  76. @pytest.mark.esp32
  77. @pytest.mark.parametrize(
  78. 'config',
  79. [
  80. 'heap_trace',
  81. 'heap_trace_hashmap'
  82. ]
  83. )
  84. def test_heap_trace_dump(dut: Dut) -> None:
  85. dut.expect_exact('Press ENTER to see the list of tests')
  86. dut.write('[trace-dump][internal]')
  87. dut.expect('Internal')
  88. dut.expect_exact('Enter next test, or \'enter\' to see menu')
  89. dut.write('[trace-dump][external]')
  90. dut.expect('PSRAM')
  91. dut.expect_exact('Enter next test, or \'enter\' to see menu')
  92. dut.write('[trace-dump][all]')
  93. dut.expect('Internal')
  94. dut.expect('PSRAM')
  95. dut.expect_exact('Enter next test, or \'enter\' to see menu')
  96. dut.write('[heap-trace]')
  97. dut.expect_unity_test_output(timeout=100)
  98. @pytest.mark.generic
  99. @pytest.mark.supported_targets
  100. @pytest.mark.parametrize(
  101. 'config',
  102. [
  103. 'mem_prot'
  104. ]
  105. )
  106. def test_memory_protection(dut: Dut) -> None:
  107. dut.expect_exact('Press ENTER to see the list of tests')
  108. dut.write('[heap][mem_prot]')
  109. dut.expect_unity_test_output(timeout=300)