mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
fix(fatfsgen): Fix incompatibility with the latest version of construct
This commit is contained in:
parent
0717e0e4a3
commit
d4d3e83d3c
@ -100,7 +100,7 @@ def remove_wear_levelling_if_exists(fs_: bytes) -> bytes:
|
||||
boot_sector__.parse_boot_sector(fs_)
|
||||
if boot_sector__.boot_sector_state.size == len(fs_):
|
||||
return fs_
|
||||
except UnicodeDecodeError:
|
||||
except (UnicodeDecodeError, construct.core.StringError):
|
||||
pass
|
||||
plain_fs: bytes = remove_wl(fs_)
|
||||
return plain_fs
|
||||
|
@ -1,5 +1,5 @@
|
||||
#!/usr/bin/env python
|
||||
# SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD
|
||||
# SPDX-FileCopyrightText: 2021-2024 Espressif Systems (Shanghai) CO LTD
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import os
|
||||
@ -32,13 +32,13 @@ class FatFSGen(unittest.TestCase):
|
||||
@staticmethod
|
||||
def test_gen_parse() -> None:
|
||||
run([
|
||||
'python',
|
||||
sys.executable,
|
||||
f'{os.path.join(os.path.dirname(__file__), "..", "fatfsgen.py")}',
|
||||
'output_data/tst_str'
|
||||
], stderr=STDOUT)
|
||||
|
||||
run(['python', '../fatfsgen.py', 'output_data/tst_str'], stderr=STDOUT)
|
||||
run(['python', '../fatfsparse.py', 'fatfs_image.img'], stderr=STDOUT)
|
||||
run([sys.executable, '../fatfsgen.py', 'output_data/tst_str'], stderr=STDOUT)
|
||||
run([sys.executable, '../fatfsparse.py', 'fatfs_image.img'], stderr=STDOUT)
|
||||
|
||||
assert set(os.listdir('Espressif')) == {'TEST', 'TESTFILE'}
|
||||
with open('Espressif/TESTFILE', 'rb') as in_:
|
||||
@ -59,7 +59,7 @@ class FatFSGen(unittest.TestCase):
|
||||
fatfs.write_content(path_from_root=['WRITEF.TXT'], content=4096 * b'a' + b'a')
|
||||
fatfs.write_filesystem('fatfs_image.img')
|
||||
|
||||
run(['python', '../fatfsparse.py', 'fatfs_image.img'], stderr=STDOUT)
|
||||
run([sys.executable, '../fatfsparse.py', 'fatfs_image.img'], stderr=STDOUT)
|
||||
with open('Espressif/WRITEF.TXT', 'rb') as in_:
|
||||
assert in_.read() == 4097 * b'a'
|
||||
|
||||
@ -74,7 +74,7 @@ class FatFSGen(unittest.TestCase):
|
||||
fatfs.write_content(path_from_root=['TESTFOLD', 'A255'], content=b'last')
|
||||
fatfs.write_filesystem('fatfs_image.img')
|
||||
|
||||
run(['python', '../fatfsparse.py', 'fatfs_image.img'], stderr=STDOUT)
|
||||
run([sys.executable, '../fatfsparse.py', 'fatfs_image.img'], stderr=STDOUT)
|
||||
assert set(os.listdir('Espressif')) == {'TESTFOLD'}
|
||||
assert set(os.listdir('Espressif/TESTFOLD')) == {f'A{str(i).upper()}' for i in range(256)}
|
||||
|
||||
@ -88,7 +88,7 @@ class FatFSGen(unittest.TestCase):
|
||||
def test_empty_fat16() -> None:
|
||||
fatfs = fatfsgen.FATFS(size=17 * 1024 * 1024)
|
||||
fatfs.write_filesystem('fatfs_image.img')
|
||||
run(['python', '../fatfsparse.py', 'fatfs_image.img'], stderr=STDOUT)
|
||||
run([sys.executable, '../fatfsparse.py', 'fatfs_image.img'], stderr=STDOUT)
|
||||
|
||||
@staticmethod
|
||||
def test_chaining_fat16() -> None:
|
||||
@ -96,7 +96,7 @@ class FatFSGen(unittest.TestCase):
|
||||
fatfs.create_file('WRITEF', extension='TXT')
|
||||
fatfs.write_content(path_from_root=['WRITEF.TXT'], content=4096 * b'a' + b'a')
|
||||
fatfs.write_filesystem('fatfs_image.img')
|
||||
run(['python', '../fatfsparse.py', 'fatfs_image.img'], stderr=STDOUT)
|
||||
run([sys.executable, '../fatfsparse.py', 'fatfs_image.img'], stderr=STDOUT)
|
||||
with open('Espressif/WRITEF.TXT', 'rb') as in_:
|
||||
assert in_.read() == 4097 * b'a'
|
||||
|
||||
@ -109,7 +109,7 @@ class FatFSGen(unittest.TestCase):
|
||||
fatfs.write_content(path_from_root=['TESTFOLD', 'A0'], content=b'first')
|
||||
fatfs.write_content(path_from_root=['TESTFOLD', 'A126'], content=b'later')
|
||||
fatfs.write_filesystem('fatfs_image.img')
|
||||
run(['python', '../fatfsparse.py', 'fatfs_image.img'], stderr=STDOUT)
|
||||
run([sys.executable, '../fatfsparse.py', 'fatfs_image.img'], stderr=STDOUT)
|
||||
assert set(os.listdir('Espressif')) == {'TESTFOLD'}
|
||||
assert set(os.listdir('Espressif/TESTFOLD')) == {f'A{str(i).upper()}' for i in range(128)}
|
||||
with open('Espressif/TESTFOLD/A0', 'rb') as in_:
|
||||
@ -134,20 +134,20 @@ class FatFSGen(unittest.TestCase):
|
||||
}
|
||||
generate_local_folder_structure(struct_, path_='.')
|
||||
run([
|
||||
'python',
|
||||
sys.executable,
|
||||
f'{os.path.join(os.path.dirname(__file__), "..", "fatfsgen.py")}',
|
||||
'testf'
|
||||
], stderr=STDOUT)
|
||||
run(['python', '../fatfsparse.py', 'fatfs_image.img'], stderr=STDOUT)
|
||||
run([sys.executable, '../fatfsparse.py', 'fatfs_image.img'], stderr=STDOUT)
|
||||
assert compare_folders('testf', 'Espressif')
|
||||
shutil.rmtree('Espressif', ignore_errors=True)
|
||||
|
||||
run([
|
||||
'python',
|
||||
sys.executable,
|
||||
f'{os.path.join(os.path.dirname(__file__), "..", "wl_fatfsgen.py")}',
|
||||
'testf'
|
||||
], stderr=STDOUT)
|
||||
run(['python', '../fatfsparse.py', 'fatfs_image.img'], stderr=STDOUT)
|
||||
run([sys.executable, '../fatfsparse.py', 'fatfs_image.img'], stderr=STDOUT)
|
||||
assert compare_folders('testf', 'Espressif')
|
||||
|
||||
def test_e2e_deeper(self) -> None:
|
||||
@ -173,20 +173,20 @@ class FatFSGen(unittest.TestCase):
|
||||
|
||||
generate_local_folder_structure(struct_, path_='.')
|
||||
run([
|
||||
'python',
|
||||
sys.executable,
|
||||
f'{os.path.join(os.path.dirname(__file__), "..", "fatfsgen.py")}',
|
||||
'testf'
|
||||
], stderr=STDOUT)
|
||||
run(['python', '../fatfsparse.py', 'fatfs_image.img'], stderr=STDOUT)
|
||||
run([sys.executable, '../fatfsparse.py', 'fatfs_image.img'], stderr=STDOUT)
|
||||
assert compare_folders('testf', 'Espressif')
|
||||
shutil.rmtree('Espressif', ignore_errors=True)
|
||||
|
||||
run([
|
||||
'python',
|
||||
sys.executable,
|
||||
f'{os.path.join(os.path.dirname(__file__), "..", "wl_fatfsgen.py")}',
|
||||
'testf'
|
||||
], stderr=STDOUT)
|
||||
run(['python', '../fatfsparse.py', 'fatfs_image.img'], stderr=STDOUT)
|
||||
run([sys.executable, '../fatfsparse.py', 'fatfs_image.img'], stderr=STDOUT)
|
||||
assert compare_folders('testf', 'Espressif')
|
||||
|
||||
def test_e2e_deeper_large(self) -> None:
|
||||
@ -229,20 +229,20 @@ class FatFSGen(unittest.TestCase):
|
||||
}
|
||||
generate_local_folder_structure(struct_, path_='.')
|
||||
run([
|
||||
'python',
|
||||
sys.executable,
|
||||
f'{os.path.join(os.path.dirname(__file__), "..", "fatfsgen.py")}',
|
||||
'testf'
|
||||
], stderr=STDOUT)
|
||||
run(['python', '../fatfsparse.py', 'fatfs_image.img'], stderr=STDOUT)
|
||||
run([sys.executable, '../fatfsparse.py', 'fatfs_image.img'], stderr=STDOUT)
|
||||
assert compare_folders('testf', 'Espressif')
|
||||
shutil.rmtree('Espressif', ignore_errors=True)
|
||||
|
||||
run([
|
||||
'python',
|
||||
sys.executable,
|
||||
f'{os.path.join(os.path.dirname(__file__), "..", "wl_fatfsgen.py")}',
|
||||
'testf'
|
||||
], stderr=STDOUT)
|
||||
run(['python', '../fatfsparse.py', 'fatfs_image.img'], stderr=STDOUT)
|
||||
run([sys.executable, '../fatfsparse.py', 'fatfs_image.img'], stderr=STDOUT)
|
||||
assert compare_folders('testf', 'Espressif')
|
||||
|
||||
def test_e2e_very_deep(self) -> None:
|
||||
@ -287,11 +287,11 @@ class FatFSGen(unittest.TestCase):
|
||||
}
|
||||
generate_local_folder_structure(struct_, path_='.')
|
||||
run([
|
||||
'python',
|
||||
sys.executable,
|
||||
f'{os.path.join(os.path.dirname(__file__), "..", "fatfsgen.py")}',
|
||||
'testf'
|
||||
], stderr=STDOUT)
|
||||
run(['python', '../fatfsparse.py', 'fatfs_image.img'], stderr=STDOUT)
|
||||
run([sys.executable, '../fatfsparse.py', 'fatfs_image.img'], stderr=STDOUT)
|
||||
assert compare_folders('testf', 'Espressif')
|
||||
|
||||
def test_e2e_very_deep_long(self) -> None:
|
||||
@ -317,11 +317,11 @@ class FatFSGen(unittest.TestCase):
|
||||
}
|
||||
generate_local_folder_structure(struct_, path_='.')
|
||||
run([
|
||||
'python',
|
||||
sys.executable,
|
||||
f'{os.path.join(os.path.dirname(__file__), "..", "fatfsgen.py")}',
|
||||
'testf', '--long_name_support'
|
||||
], stderr=STDOUT)
|
||||
run(['python', '../fatfsparse.py', 'fatfs_image.img'], stderr=STDOUT)
|
||||
run([sys.executable, '../fatfsparse.py', 'fatfs_image.img'], stderr=STDOUT)
|
||||
assert compare_folders('testf', 'Espressif')
|
||||
|
||||
def test_parse_long_name(self) -> None:
|
||||
|
Loading…
Reference in New Issue
Block a user