pytest_ulp_fsm_adc.py 1.0 KB

12345678910111213141516171819202122232425262728
  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. @pytest.mark.esp32
  7. @pytest.mark.generic
  8. def test_ulp_fsm_adc(dut: Dut) -> None:
  9. dut.expect_exact('Not ULP wakeup')
  10. dut.expect_exact('Entering deep sleep')
  11. for _ in range(5):
  12. dut.expect_exact('Deep sleep wakeup', timeout=60)
  13. measurements_str = dut.expect(r'ULP did (\d+) measurements', timeout=5).group(1)
  14. assert measurements_str is not None
  15. measurements = int(measurements_str)
  16. logging.info('ULP did {} measurements'.format(measurements))
  17. dut.expect_exact('Thresholds: low=1500 high=2000', timeout=5)
  18. value_str = dut.expect(r'Value=(\d+) was (above|below) threshold', timeout=5).group(1)
  19. assert value_str is not None
  20. value = int(value_str)
  21. logging.info('Value {} was outside the boundaries'.format(value))
  22. dut.expect_exact('Entering deep sleep', timeout=60)