Skip to content

Commit

Permalink
refactor(test/esptool): Updated tests according to SHA recomputation …
Browse files Browse the repository at this point in the history
…for binary
  • Loading branch information
jakub-kocka authored and radimkarnis committed Mar 5, 2024
1 parent 8d26375 commit 598b703
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 14 deletions.
4 changes: 1 addition & 3 deletions esptool/cmds.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,9 +239,7 @@ def detect_flash_size(esp, args=None):
return flash_size


def _update_image_flash_params(
esp, address, args, image
): # TODO check the flash params if they are valid
def _update_image_flash_params(esp, address, args, image):
"""
Modify the flash mode & size bytes if this looks like an executable bootloader image
"""
Expand Down
17 changes: 6 additions & 11 deletions test/test_esptool.py
Original file line number Diff line number Diff line change
Expand Up @@ -1043,11 +1043,7 @@ def test_detect_size_changes_size(self):
)
readback = self.readback(self.flash_offset, 8)
assert self.header[:3] == readback[:3] # first 3 bytes unchanged
if arg_chip in ["esp8266", "esp32"]:
assert self.header[3] != readback[3] # size_freq byte changed
else:
# Not changed because protected by SHA256 digest
assert self.header[3] == readback[3] # size_freq byte unchanged
assert self.header[3] != readback[3] # size_freq byte changed
assert self.header[4:] == readback[4:] # rest unchanged

@pytest.mark.skipif(
Expand Down Expand Up @@ -1171,13 +1167,12 @@ def test_flash_header_rewrite(self):
f"write_flash -fm dout -ff 20m {bl_offset:#x} {bl_image}"
)
if arg_chip in ["esp8266", "esp32"]:
# There is no SHA256 digest so the header can be changed - ESP8266 doesn't
# support this; The test image for ESP32 just doesn't have it.
"Flash params set to" in output
# ESP8266 doesn't support this; The test image for ESP32 just doesn't have it.
assert "Flash params set to" in output
else:
assert "Flash params set to" not in output
"not changing the flash mode setting" in output
"not changing the flash frequency setting" in output
assert "Flash params set to" in output
# Since SHA recalculation is supported for changed bootloader header
assert "SHA digest in image updated" in output

def test_flash_header_no_magic_no_rewrite(self):
# first image doesn't start with magic byte, second image does
Expand Down

0 comments on commit 598b703

Please sign in to comment.