[NFC]: supported-card parsers have no test coverage and the unit-test harness cannot reach them
Describe the bug.
None of the 41 supported-card parsers in applications/main/nfc/plugins/supported_cards/ has any test coverage, and the existing harness cannot currently reach them. This is what allowed #1091 — a checker that rejected roughly nine of ten genuine cards — to ship for four releases undetected.
The gap is structural rather than neglect:
- The unit-test firmware does not contain the NFC app.
FIRMWARE_APPS["unit_tests"]infbt_options.pyomitsmain_apps, which is what providesnfc. Andapplications/main/nfcisapptype=FlipperAppType.MENUEXTERNAL, registered withglobal_lookup=Falseinscripts/fbt/appmanifest.py, so it cannot be pulled in by appid the wayjs_appcan. - Parser internals are
staticand live in.falplugins of that FAP, so no other translation unit can link them. - Runtime plugin loading does not help.
nfc_supported_cards.cresolves plugin imports through aCompositeApiResolverof the firmware API plus the NFC app's private table (applications/main/nfc/api/nfc_app_api_table.cpp). The unit-test app has no equivalent table, so a parser.falwould not resolve. - CI never runs the suite anyway. None of the workflows in
.github/workflows/invokesscripts/testops.py run_units; it needs a dedicated firmware build, flashed by hand and driven over serial.
What does exist and works: applications/debug/unit_tests/ is a real minunit harness with roughly 30 suites, and .nfc fixtures are already supported — applications/debug/unit_tests/resources/unit_tests/nfc/ holds 14 dumps loaded via nfc_device_load(). There is also precedent for testing a pure function that lives in firmware core: mf_plus_crypto_cmac_rfc4493 works because the symbol is in lib/ and was hand-added to applications/debug/unit_tests/unit_test_api_table_i.h.
Reproduction
Not a runtime bug. grep -rni "supported_card\|social_moscow" applications/debug/unit_tests/ returns nothing.
Found in version
dev
Anything else?
Filed as a tracked gap rather than a proposal, because the fix is a real design decision and none of the options is obviously right:
- Hoist the pure, testable arithmetic out of parsers into
lib/(wherebit_lib_bytes_to_num_bcdalready lives, already tested) and test it there. Cheapest, but covers helpers rather than parse logic. - Pull the NFC app into the unit-test firmware and export parser internals through a test API table. Invasive.
- Host-side tests over saved dumps, outside the on-device harness. Needs new infrastructure, but is the only option CI could actually gate on.
Note that real card dumps make poor committed fixtures: the ones that exposed #1091 carry real card numbers and OMC numbers belonging to identifiable people, so any fixture would have to be synthesised with a recomputed check digit.
Found during review of #1092 / #1091.
Source: DarkFlippers/unleashed-firmware