@@ -455,22 +455,50 @@ def test_active_flash_format_is_v20(self):
455455 "release (7.15 = V17) and moves in the release commit that tags "
456456 "7.16, not when a format lands in the tree." % self .last_shipped )
457457
458- def test_burned_versions_have_no_reader (self ):
459- """18 and 19 must never be parsed by 7.16.
458+ def test_burned_versions_are_dispatched_to_the_wipe_path (self ):
459+ """18 and 19 must never be PARSED by 7.16.
460460
461461 They were real formats in alpha builds before the 7.15 revert, so
462462 devices carrying them exist. A reader for either would parse a
463- clear-sign identity block or a PIN-KDF blob as passkey state. The
464- absence of a case in the dispatch is what sends them to the wipe path,
465- and this test is what stops one being added back by someone tidying up
466- the switch.
463+ clear-sign identity block or a PIN-KDF blob as passkey state.
464+
465+ This used to assert the absence of a `case StorageVersion_18:` label,
466+ on the theory that falling to the default is what sends them to the
467+ wipe path. That was wrong twice over: storage_fromFlash has NO default
468+ case -- deliberately, so -Werror=switch names any version we forget --
469+ so an unlisted version does not fall anywhere, it fails the ARM build.
470+
471+ So the labels must exist. What must NOT exist is a reader behind them.
472+ Assert the real property: 18 and 19 are dispatched, and what they
473+ dispatch to is SUS_Invalid rather than any storage_readVxx call.
467474 """
468- self .assertNotIn ("case StorageVersion_18:" , self .c ,
469- "18 is a burned format; a reader would misparse blobs "
470- "written by pre-revert alpha builds" )
471- self .assertNotIn ("case StorageVersion_19:" , self .c ,
472- "19 is a burned format; a reader would misparse blobs "
473- "written by pre-revert alpha builds" )
475+ for burned in (18 , 19 ):
476+ label = "case StorageVersion_%d:" % burned
477+ self .assertIn (
478+ label , self .c ,
479+ "%s must be listed; storage_fromFlash has no default case, so "
480+ "an unlisted version breaks the -Werror=switch build" % label )
481+
482+ # The two labels must sit together and return SUS_Invalid before any
483+ # other case begins. Slice from the first burned label to the next
484+ # `case ` that is not one of the burned ones.
485+ i = self .c .index ("case StorageVersion_18:" )
486+ rest = self .c [i :]
487+ j = len (rest )
488+ for m in re .finditer (r"\n\s*case StorageVersion_(\w+):" , rest ):
489+ if m .group (1 ) not in ("18" , "19" ):
490+ j = m .start ()
491+ break
492+ arm = rest [:j ]
493+
494+ self .assertIn (
495+ "SUS_Invalid" , arm ,
496+ "the burned versions must return SUS_Invalid (the wipe path); "
497+ "arm was:\n %s" % arm )
498+ self .assertNotIn (
499+ "storage_read" , arm ,
500+ "a reader behind a burned version would misparse blobs written by "
501+ "pre-revert alpha builds; arm was:\n %s" % arm )
474502
475503 def test_version_never_drops_below_a_shipped_release (self ):
476504 """Lowering STORAGE_VERSION wipes every device upgrading FROM a shipped
0 commit comments