pytest_spiffsgen_example.py 838 B

1234567891011121314151617181920212223
  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. def test_spiffsgen_example(dut: Dut) -> None:
  9. # Test with default build configurations
  10. base_dir = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'spiffs_image')
  11. # Expect hello.txt is read successfully
  12. with open(os.path.join(base_dir, 'hello.txt'), 'r') as hello_txt:
  13. dut.expect('Read from hello.txt: ' + hello_txt.read().rstrip())
  14. # Expect alice.txt MD5 hash is computed accurately
  15. with open(os.path.join(base_dir, 'sub', 'alice.txt'), 'rb') as alice_txt:
  16. alice_md5 = hashlib.md5(alice_txt.read()).hexdigest()
  17. dut.expect('Computed MD5 hash of alice.txt: ' + alice_md5)