example_test.py 898 B

123456789101112131415161718192021222324252627
  1. from __future__ import print_function
  2. import os
  3. import hashlib
  4. import ttfw_idf
  5. @ttfw_idf.idf_example_test(env_tag='Example_WIFI')
  6. def test_examples_spiffsgen(env, extra_data):
  7. # Test with default build configurations
  8. dut = env.get_dut('spiffsgen', 'examples/storage/spiffsgen')
  9. dut.start_app()
  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())
  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)
  18. if __name__ == '__main__':
  19. test_examples_spiffsgen()