pytest_ulp_fsm_adc.py 1.0 KB

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