2019-01-31 06:54:45 -05:00
|
|
|
from __future__ import print_function
|
2021-01-25 21:49:01 -05:00
|
|
|
|
2019-01-31 06:54:45 -05:00
|
|
|
import hashlib
|
2021-01-25 21:49:01 -05:00
|
|
|
import os
|
2019-01-31 06:54:45 -05:00
|
|
|
|
2019-11-26 22:58:07 -05:00
|
|
|
import ttfw_idf
|
2019-01-31 06:54:45 -05:00
|
|
|
|
|
|
|
|
2021-03-12 01:05:17 -05:00
|
|
|
@ttfw_idf.idf_example_test(env_tag='Example_GENERIC', target=['esp32', 'esp32c3'])
|
2019-01-31 06:54:45 -05:00
|
|
|
def test_examples_spiffsgen(env, extra_data):
|
|
|
|
# Test with default build configurations
|
2021-03-12 01:05:17 -05:00
|
|
|
dut = env.get_dut('spiffsgen', 'examples/storage/spiffsgen')
|
2019-01-31 06:54:45 -05:00
|
|
|
dut.start_app()
|
|
|
|
|
|
|
|
base_dir = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'spiffs_image')
|
|
|
|
|
|
|
|
# Expect hello.txt is read successfully
|
|
|
|
with open(os.path.join(base_dir, 'hello.txt'), 'r') as hello_txt:
|
2020-11-17 02:01:49 -05:00
|
|
|
dut.expect('Read from hello.txt: ' + hello_txt.read().rstrip())
|
2019-01-31 06:54:45 -05:00
|
|
|
|
|
|
|
# Expect alice.txt MD5 hash is computed accurately
|
|
|
|
with open(os.path.join(base_dir, 'sub', 'alice.txt'), 'rb') as alice_txt:
|
|
|
|
alice_md5 = hashlib.md5(alice_txt.read()).hexdigest()
|
|
|
|
dut.expect('Computed MD5 hash of alice.txt: ' + alice_md5)
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
test_examples_spiffsgen()
|