pytest_spiffsgen_example.py 859 B

123456789101112131415161718192021222324
  1. # SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD
  2. # SPDX-License-Identifier: Unlicense OR CC0-1.0
  3. import hashlib
  4. import os
  5. import pytest
  6. from pytest_embedded import Dut
  7. @pytest.mark.esp32
  8. @pytest.mark.esp32c3
  9. def test_spiffsgen_example(dut: Dut) -> None:
  10. # Test with default build configurations
  11. base_dir = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'spiffs_image')
  12. # Expect hello.txt is read successfully
  13. with open(os.path.join(base_dir, 'hello.txt'), 'r') as hello_txt:
  14. dut.expect('Read from hello.txt: ' + hello_txt.read().rstrip())
  15. # Expect alice.txt MD5 hash is computed accurately
  16. with open(os.path.join(base_dir, 'sub', 'alice.txt'), 'rb') as alice_txt:
  17. alice_md5 = hashlib.md5(alice_txt.read()).hexdigest()
  18. dut.expect('Computed MD5 hash of alice.txt: ' + alice_md5)