Skip to content

Commit

Permalink
test: flash_test: crc test and chip/page erase decision fixes.
Browse files Browse the repository at this point in the history
- Skip fast verify test if CRC analyser isn't supported by the flash algo.
- Change fast verify test pass predicate to just check the flash result info's analyser type.
- The chip and sector erase decision tests no longer require a particular erase type, since that is highly flaky over a wide range of test targets. Instead, the total byte count is checked.
  • Loading branch information
flit committed Dec 19, 2021
1 parent cffcc86 commit e7214ee
Showing 1 changed file with 25 additions and 10 deletions.
35 changes: 25 additions & 10 deletions test/flash_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,13 +246,16 @@ def flash_test(board_id):
test_count += 1

print("\n------ Test Fast Verify ------")
info = flash.flash_block(addr, new_data, progress_cb=print_progress(), fast_verify=True)
if info.program_type == FlashBuilder.FLASH_SECTOR_ERASE:
print("TEST PASSED")
test_pass_count += 1
if flash.get_flash_info().crc_supported:
info = flash.flash_block(addr, new_data, progress_cb=print_progress(), fast_verify=True)
if info.analyze_type == FlashBuilder.FLASH_ANALYSIS_CRC32:
print("TEST PASSED")
test_pass_count += 1
else:
print("TEST FAILED")
test_count += 1
else:
print("TEST FAILED")
test_count += 1
print("Skipping because analyser isn't supported for this algo")

print("\n------ Test Offset Write ------")
addr = rom_start + rom_size // 2
Expand Down Expand Up @@ -339,8 +342,11 @@ def flash_test(board_id):
print("\n------ Test Chip Erase Decision ------")
new_data = list(data)
new_data.extend([flash.region.erased_byte_value] * unused) # Pad with erased value
data_size = len(new_data)
info = flash.flash_block(addr, new_data, progress_cb=print_progress())
if info.program_type == FlashBuilder.FLASH_CHIP_ERASE:
print(f"Selected erase type is {info.program_type}")
print(f"Total byte count = {info.total_byte_count} (expected {data_size})")
if info.total_byte_count == data_size:
print("TEST PASSED")
test_pass_count += 1
result.chip_erase_rate_erased = float(len(new_data)) / float(info.program_time)
Expand All @@ -351,8 +357,11 @@ def flash_test(board_id):
print("\n------ Test Chip Erase Decision 2 ------")
new_data = list(data)
new_data.extend([unerasedValue] * unused) # Pad with unerased value
data_size = len(new_data)
info = flash.flash_block(addr, new_data, progress_cb=print_progress())
if info.program_type == FlashBuilder.FLASH_CHIP_ERASE:
print(f"Selected erase type is {info.program_type}")
print(f"Total byte count = {info.total_byte_count} (expected {data_size})")
if info.total_byte_count == data_size:
print("TEST PASSED")
test_pass_count += 1
result.chip_erase_rate = float(len(new_data)) / float(info.program_time)
Expand All @@ -363,8 +372,11 @@ def flash_test(board_id):
print("\n------ Test Page Erase Decision ------")
new_data = list(data)
new_data.extend([unerasedValue] * unused) # Pad with unerased value
data_size = len(new_data)
info = flash.flash_block(addr, new_data, progress_cb=print_progress())
if info.program_type == FlashBuilder.FLASH_SECTOR_ERASE:
print(f"Selected erase type is {info.program_type}")
print(f"Total byte count = {info.total_byte_count} (expected {data_size})")
if info.total_byte_count == data_size:
print("TEST PASSED")
test_pass_count += 1
result.page_erase_rate_same = float(len(new_data)) / float(info.program_time)
Expand All @@ -381,8 +393,11 @@ def flash_test(board_id):
size_differ = unused - size_same
new_data.extend([unerasedValue] * size_same) # Pad 5/6 with unerased value and 1/6 with 0x55
new_data.extend([0x55] * size_differ)
data_size = len(new_data)
info = flash.flash_block(addr, new_data, progress_cb=print_progress())
if info.program_type == FlashBuilder.FLASH_SECTOR_ERASE:
print(f"Selected erase type is {info.program_type}")
print(f"Total byte count = {info.total_byte_count} (expected {data_size})")
if info.total_byte_count == data_size:
print("TEST PASSED")
test_pass_count += 1
else:
Expand Down

0 comments on commit e7214ee

Please sign in to comment.