parttool: added tests to check the external interface (parsing) of the parttool commands

The existing tests detect errors in the internal interface (eg. parttool read-write functions) and did not check for any possible breakages in the args parsing of the parttool commands.
This commit is contained in:
harshal.patil 2022-09-15 19:03:11 +05:30
parent aca27c8db2
commit b95decd465
2 changed files with 20 additions and 0 deletions

View File

@ -3,4 +3,5 @@
nvs, data, nvs, 0x9000, 0x6000,
phy_init, data, phy, 0xf000, 0x1000,
factory, app, factory, 0x10000, 1M,
custom, data, nvs, , 0x1000,
storage, data, spiffs, , 0x10000,

1 # Name, Type, SubType, Offset, Size, Flags
3 nvs, data, nvs, 0x9000, 0x6000,
4 phy_init, data, phy, 0xf000, 0x1000,
5 factory, app, factory, 0x10000, 1M,
6 custom, data, nvs, , 0x1000,
7 storage, data, spiffs, , 0x10000,

View File

@ -26,3 +26,22 @@ def test_examples_parttool(dut: Dut) -> None:
script_path = os.path.join(idf_path, 'examples', 'storage', 'parttool', 'parttool_example.py')
binary_path = os.path.join(dut.app.binary_path, 'parttool.bin')
subprocess.check_call([sys.executable, script_path, '--binary', binary_path, '--port', dut.serial.port])
# following tests check the external interface (parsing) of the parttool commands
with open('custom.bin', 'wb') as f:
f.write(b'0' * 1024 * 4)
PARTTOOL = os.path.join(idf_path, 'components', 'partition_table', 'parttool.py')
BASE_CMD = [sys.executable, PARTTOOL, '--port', dut.serial.port]
cmds = ['read_partition --partition-type=data --partition-subtype=nvs --output custom1.bin',
'erase_partition --partition-name=custom',
'write_partition --partition-name=custom --input custom.bin',
'get_partition_info --partition-boot-default --info size']
for cmd in cmds:
subprocess.check_call(BASE_CMD + cmd.split())
clean_files = ['custom.bin', 'custom1.bin']
for clean_file in clean_files:
os.unlink(clean_file)