pytest_nvs_rw_value.py 940 B

123456789101112131415161718192021
  1. # SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD
  2. # SPDX-License-Identifier: Unlicense OR CC0-1.0
  3. import logging
  4. from itertools import zip_longest
  5. import pytest
  6. from pytest_embedded import Dut
  7. @pytest.mark.esp32
  8. @pytest.mark.esp32c3
  9. def test_examples_nvs_rw_value(dut: Dut) -> None:
  10. for i, counter_state in zip_longest(range(4), ('The value is not initialized yet!',), fillvalue='Done'):
  11. dut.expect('Opening Non-Volatile Storage \\(NVS\\) handle... Done', timeout=20)
  12. dut.expect('Reading restart counter from NVS ... {}'.format(counter_state), timeout=20)
  13. dut.expect('Restart counter = {}'.format(i) if i > 0 else '', timeout=20)
  14. dut.expect('Updating restart counter in NVS ... Done', timeout=20)
  15. dut.expect('Committing updates in NVS ... Done', timeout=20)
  16. dut.expect('Restarting in 10 seconds...', timeout=20)
  17. logging.info('loop {} has finished'.format(i))